Ticket #3938 (reopened enhancement)

Opened 5 years ago

Last modified 5 years ago

Enhance code to resolve TracLinks

Reported by: martin_s Assigned to: 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

freemind_url.patch (3.7 kB) - added by martin_s on 10/20/08 00:57:48.
Patch to use enhanced TracLinks resolve code

Change History

10/20/08 00:57:48 changed by martin_s

  • attachment freemind_url.patch added.

Patch to use enhanced TracLinks resolve code

10/20/08 00:59:49 changed by martin_s

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

10/20/08 10:44:43 changed 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. ;)

(follow-up: ↓ 4 ) 10/20/08 17:29:41 changed by lcordier

  • status changed from new to closed.
  • resolution set to fixed.

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.

(in reply to: ↑ 3 ) 10/21/08 13:58:03 changed by martin_s

  • status changed from closed to reopened.
  • resolution deleted.

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/Change #3938 (Enhance code to resolve TracLinks)




Change Properties
Action