Opened 16 years ago
Last modified 16 years ago
#3938 reopened enhancement
Enhance code to resolve TracLinks
Reported by: | Martin Scharrer | Owned by: | Louis Cordier |
---|---|---|---|
Priority: | normal | Component: | FreemindMacro |
Severity: | normal | Keywords: | links resolution |
Cc: | Trac Release: | 0.11 |
Description
The code to resolve the TracLinks to full HTML href's ('attachment:file' to '/attachment/wiki/foobar/file') needed by the flash plugin is at the moment self written. Every TracHacks macro seem to re-write its own implementation, while this is actual a basic functionality which should be provided by the Trac API itself.
I opened a Trac ticket to request this, ticket:7728, and also found an appropriate solution which uses the Trac wiki engine to resolve the TracLinks. Please have a look on the ticket attachment. The code could be easily taken over to the FreemindMacro and would !add complete, fully working support of all current and future TracLinks.
Attachments (1)
Change History (5)
Changed 16 years ago by
Attachment: | freemind_url.patch added |
---|
comment:1 Changed 16 years ago by
I just integrated my href resolve example code to the FreemindMacro. See the attached attachment:freemind_url.patch .
comment:2 Changed 16 years ago by
I deliberately didn't use TracLinks because I feel references to resources, SHOULD look like URLs. All references SHOULD follow a standard form, and it's Python philosophy that:
There should be one-- and preferably only one --obvious way to do it.
Then I cannot see from TracLinks how you would reference resources either in the site or a plugin's htdocs.
However, I will add your functionality so that both ways would work.
PS. I was also going to create a Trac ticket for this, I just wanted to finish a few macros first. ;)
comment:3 follow-up: 4 Changed 16 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:4 Changed 16 years ago by
Resolution: | fixed |
---|---|
Status: | closed → reopened |
I found out that my code only works with single project trac installations, e.g. starting the tracd
with the -s
option. With multiple projects there is still the project name in the url so that href.startswith('/browser/')
etc. doesn't work.
To fix this some code like this is needed (pseudo code given):
project_name = get_project_prefix_somehow(something) if not project_name: project_name = "" else: project_name.make_sure_that_it_starts_with_an_slash() if href.startswith(project_name + '/browser/'):
so we get either '/browser/
' or '/project_name/browser/
' etc.
Patch to use enhanced TracLinks resolve code