Edgewall Software
Modify

Opened 16 years ago

Last modified 3 years ago

#7728 new enhancement

Realm URL resolve function needed Trac Plugins

Reported by: martin@… Owned by:
Priority: normal Milestone: topic-wikiengine
Component: general Version:
Severity: minor Keywords: traclinks
Cc: martin@… Branch:
Release Notes:
API Changes:
Internal Changes:

Description

In the current Trac code there seems to be no separate function/method to resolve a given TracLink to an full valid URL which can be used in XHTML code returned by macros.

I'm talking about macro similar to the Image macro which takes a trac realm like 'source:' or 'attachment:'. The Image macro has this resolving hardcoded while this should be an own method provided to all macros.

At the moment several macros on TracHacks (FlashViewPlugin, FreemindMacro, …) implement there own (sometimes incomplete and buggy) implementation of this.

An easy solution would be just to take the relevant code out of the Image macro and put it in an separate method. This must be already implemented somewhere else too because the same conversation is done by 'wiki_to_html' etc.

If there is already such an method I couldn't find it. I searched the trac source code, check several macro and the Nabble trac forum.

Attachments (1)

hrefexample.py (1.3 KB ) - added by martin@… 16 years ago.
Example macro with clean href extraction code

Download all attachments as: .zip

Change History (10)

comment:1 by martin@…, 16 years ago

After going through a lot of trac and plugin code I found the (relative new?) method 'extract_link' which does half of the needed work. Because an 'Element' object is returned the href can be extracted without using an regular expression.

Because I couldn't find an example or documentation for this I coded a simple example so future macro developer have something to start with. Please find it attached. Please be aware that I'm a Perl programmer which is relative new to Python.

IMHO a method with code like this should be put in WikiMacroBase because many macro programmers need this.

by martin@…, 16 years ago

Attachment: hrefexample.py added

Example macro with clean href extraction code

comment:2 by Remy Blank, 16 years ago

Milestone: 0.12
Owner: set to Remy Blank

I'll look into this.

comment:3 by Remy Blank, 15 years ago

Milestone: 0.120.12.1

Not essential for 0.12.

comment:4 by Christian Boos, 15 years ago

Keywords: traclinks added
Milestone: next-minor-0.12.x0.13
Owner: changed from Remy Blank to Christian Boos
Severity: normalminor

This will be possible with the WikiDom API.

comment:5 by Martin Scharrer <martin@…>, 14 years ago

In the meantime I implemented the th:ExtractUrlPlugin to provide a way get the href of any TracLink. While this is good for me, I still think such a function should still be provided by Trac itself.

comment:6 by Christian Boos, 14 years ago

Milestone: 0.130.14-wikiengine

comment:7 by Ryan J Ollos, 11 years ago

Keywords: traclink added; traclinks removed

comment:8 by Ryan J Ollos, 11 years ago

Keywords: traclinks added; traclink removed

comment:9 by Ryan J Ollos, 10 years ago

Owner: Christian Boos removed

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The ticket will remain with no owner.
The ticket will be disowned.
as The resolution will be set. Next status will be 'closed'.
The owner will be changed from (none) to anonymous. Next status will be 'assigned'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.