Edgewall Software
Modify

Opened 20 years ago

Closed 20 years ago

#1009 closed enhancement (fixed)

Should be a way to differentiate external links from links to the project server

Reported by: Juanma Barranquero Owned by: Jonas Borgström
Priority: normal Milestone: 0.9
Component: wiki system Version: 0.8
Severity: normal Keywords:
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

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.

  • trac/WikiFormatter.py

     
    6060        self._href = absurls and env.abs_href or env.href
     61        self._local = hdf.getValue('project.url', '')
     62
     63    def link_type(self, link):
     64        if self._local and link.find(self._local) == 0:
     65            return 'loc-link'
     66        else:
     67            return 'ext-link'
    6168
     
    213220    def _url_formatter(self, match, fullmatch):
    214         return '<a class="ext-link" title="%s" href="%s">%s</a>' % (match, match, match)
     221        return '<a class="%s" title="%s" href="%s">%s</a>' % (self.link_type(match), match, match, match)
    215222
     
    225232        else:
    226             return '<a class="ext-link" title="%s" href="%s">%s</a>' % (link, link, name)
     233            return '<a class="%s" title="%s" href="%s">%s</a>' % (self.link_type(link), link, link, name)
    227234

Attachments (0)

Change History (4)

comment:1 by arack99@…, 20 years ago

I agree. I have multiple trac's setup to manager multiple projects. I have one trac that is just for common wiki stuff that gets linked to from the others. I would like those URLS to be considered local to make it feels as if its a single system.

comment:2 by Juanma Barranquero, 20 years ago

BTW, a change a few weeks ago broke the patch, so the first few lines should instead be:

         self._href = absurls and env.abs_href or env.href
+        self._local = env.get_config('project', 'url')

comment:3 by Juanma Barranquero, 20 years ago

Broken again. There goes the full patch:

  • trac/WikiFormatter.py

     
    5858        self._href = absurls and env.abs_href or env.href
     59        self._local = env.get_config('project', 'url')
     60
     61    def link_type(self, link):
     62        if self._local and link.find(self._local) == 0:
     63            return 'loc-link'
     64        else:
     65            return 'ext-link'
    5966
     
    151158    def _make_ext_link(self, url, text):
    152         return '<a class="ext-link" href="%s">%s</a>' % (url, text)
     159        return '<a class="%s" href="%s">%s</a>' % (self.link_type(url), url, text)
    153160

FWIW, I still think something like that should be done in Trac, not as an external patch…

comment:4 by Christopher Lenz, 20 years ago

Milestone: 0.9
Resolution: fixed
Status: newclosed
Version: devel0.8

Slightly modified patch applied in [1232].

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Jonas Borgström.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Jonas Borgström to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.