Modify

Opened 6 years ago

Last modified 6 years ago

#3938 reopened enhancement

Enhance code to resolve TracLinks

Reported by: martin_s Owned by: lcordier
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_s 6 years ago.
Patch to use enhanced TracLinks resolve code

Download all attachments as: .zip

Change History (5)

Changed 6 years ago by martin_s

Patch to use enhanced TracLinks resolve code

comment:1 Changed 6 years ago by martin_s

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

comment:2 Changed 6 years ago by lcordier

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: Changed 6 years ago by lcordier

  • Resolution set to fixed
  • Status changed from new to closed

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 6 years ago by martin_s

  • Resolution fixed deleted
  • Status changed from closed to 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.

Add Comment

Modify Ticket

Action
as reopened .
Author


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

 
Note: See TracTickets for help on using tickets.