Edgewall Software

Ticket #5718: 5718-download-link-all-r8173.patch

File 5718-download-link-all-r8173.patch, 1.8 KB (added by rblank, 3 years ago)

Patch adding a download icon to all links to attachments.

  • trac/attachment.py

    diff --git a/trac/attachment.py b/trac/attachment.py
    a b  
    730730        if attachment and 'ATTACHMENT_VIEW' in formatter.perm(attachment): 
    731731            try: 
    732732                model = Attachment(self.env, attachment) 
    733                 format = None 
     733                raw_href = get_resource_url(self.env, attachment, 
     734                                            formatter.href, format='raw') 
    734735                if ns.startswith('raw'): 
    735                     format = 'raw' 
    736                 href = get_resource_url(self.env, attachment, formatter.href, 
    737                                         format=format) 
    738                 return tag.a(label, class_='attachment', href=href + params, 
    739                              title=get_resource_name(self.env, attachment)) 
     736                    return tag.a(label, class_='attachment', 
     737                                 href=raw_href + params, 
     738                                 title=get_resource_name(self.env, attachment)) 
     739                href = get_resource_url(self.env, attachment, formatter.href) 
     740                title = get_resource_name(self.env, attachment) 
     741                img = tag.img(src=formatter.href.chrome('common/download.png'), 
     742                              alt=_("Original format")) 
     743                return tag(tag.a(label, class_='attachment', title=title, 
     744                                 href=href + params), 
     745                           tag.span(" ", 
     746                                    tag.a(img, class_='trac-rawlink', 
     747                                          href=raw_href + params, 
     748                                          title=_("Original format")), 
     749                                    class_="noprint")) 
    740750            except ResourceNotFound, e: 
    741751                pass 
    742752            # FIXME: should be either: