[Trac-tickets] [The Trac Project] #1009: Should be a way to differentiate external links from links to the project server

The Trac Project noreply at edgewall.com
Wed Dec 1 10:33:54 EST 2004


#1009: Should be a way to differentiate external links from links to the project
server
-------------------------+--------------------------------------------------
       Id:  1009         |      Status:  new                     
Component:  wiki         |    Modified:  Wed Dec  1 10:33:54 2004
 Severity:  enhancement  |   Milestone:                          
 Priority:  normal       |     Version:  devel                   
    Owner:  jonas        |    Reporter:  Juanma Barranquero      
-------------------------+--------------------------------------------------
 Currently, there's no way to tell apart links which are really external,
 i.e., {{{http://www.microsoft.com}}}, from the ones not in Trac, but still
 in the local server, like {{{http://myproject/mypath}}}. That's weird,
 because links I would consider "local" are decorated with the external
 icon.

 I've already patched my Trac installation to differentiate them, but I'm
 not entirely sure that relying on the {{{project.url}}} setting from
 TracIni is the right thing to do.

 {{{
 #!text/x-diff
 Index: trac/WikiFormatter.py
 ===================================================================
 --- trac/WikiFormatter.py       (revision 1107)
 +++ trac/WikiFormatter.py       (working copy)
 @@ -60,2 +60,9 @@
          self._href = absurls and env.abs_href or env.href
 +        self._local = hdf.getValue('project.url', '')
 +
 +    def link_type(self, link):
 +        if self._local and link.find(self._local) == 0:
 +            return 'loc-link'
 +        else:
 +            return 'ext-link'

 @@ -213,3 +220,3 @@
      def _url_formatter(self, match, fullmatch):
 -        return '<a class="ext-link" title="%s" href="%s">%s</a>' %
 (match, match, match)
 +        return '<a class="%s" title="%s" href="%s">%s</a>' %
 (self.link_type(match), match, match, match)

 @@ -225,3 +232,3 @@
          else:
 -            return '<a class="ext-link" title="%s" href="%s">%s</a>' %
 (link, link, name)
 +            return '<a class="%s" title="%s" href="%s">%s</a>' %
 (self.link_type(link), link, link, name)

 }}}

-- 
Ticket URL: <http://projects.edgewall.com/trac/ticket/1009>
The Trac Project <>


More information about the Trac-Tickets mailing list