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
60 60 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' 61 68 … … 213 220 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) 215 222 … … 225 232 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) 227 234
Attachments (0)
Change History (4)
comment:1 by , 20 years ago
comment:2 by , 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 , 20 years ago
Broken again. There goes the full patch:
-
trac/WikiFormatter.py
58 58 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' 59 66 … … 151 158 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) 153 160
FWIW, I still think something like that should be done in Trac, not as an external patch…
comment:4 by , 20 years ago
Milestone: | → 0.9 |
---|---|
Resolution: | → fixed |
Status: | new → closed |
Version: | devel → 0.8 |
Slightly modified patch applied in [1232].
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.