Modify

Opened 15 years ago

Last modified 15 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)

freemind_url.patch (3.7 KB) - added by Martin Scharrer 15 years ago.
Patch to use enhanced TracLinks resolve code

Download all attachments as: .zip

Change History (5)

Changed 15 years ago by Martin Scharrer

Attachment: freemind_url.patch added

Patch to use enhanced TracLinks resolve code

comment:1 Changed 15 years ago by Martin Scharrer

I just integrated my href resolve example code to the FreemindMacro. See the attached attachment:freemind_url.patch .

comment:2 Changed 15 years ago by Louis Cordier

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 Changed 15 years ago by Louis Cordier

Resolution: fixed
Status: newclosed

Incorporated the patch into get_absolute_url. This however make get_absolute_url require a formatter instance when passed TracLinks as urls. This also requires serious testing.

See [4544] for details.

comment:4 in reply to:  3 Changed 15 years ago by Martin Scharrer

Resolution: fixed
Status: closedreopened

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.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as reopened The owner will remain Louis Cordier.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.