Edgewall Software
Modify

Opened 18 years ago

Closed 18 years ago

Last modified 18 years ago

#4411 closed defect (fixed)

absurls in wiki_to_html doesn't seem to take care of relative links

Reported by: ittayd@… Owned by: Christian Boos
Priority: high Milestone: 0.11
Component: wiki system Version: 0.10.3
Severity: normal Keywords:
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

i have a page with 'Page' link. using wiki_to_html(text, self.env, req, absurls=True) still leaves the href as '<a href="./SomeOtherPage">'

Attachments (0)

Change History (7)

comment:1 by Christian Boos, 18 years ago

Component: generalwiki
Milestone: 0.11
Owner: changed from Jonas Borgström to Christian Boos
Priority: normalhigh

Well, this should have worked in trunk, since the introduction of WikiContext and the related refactoring of relative links (r4442).

… but apparently it's broken for some reason, I'll check.

comment:2 by Christian Boos, 18 years ago

Resolution: fixed
Status: newclosed

… and the reason was precisely that r4442 was not merged, damn ;) Corrected in r4461.

comment:3 by ittayd@…, 18 years ago

my case was that i was trying to use wiki_to_html from one page in another. this means my 'req' contains the wrong href. is this solved with contexts?

comment:4 by ittayd@…, 18 years ago

and why not use urlparse?

in reply to:  3 comment:5 by Christian Boos, 18 years ago

Replying to ittayd@qlusters.com:

my case was that i was trying to use wiki_to_html from one page in another. this means my 'req' contains the wrong href. is this solved with contexts?

Yes, that's the purpose of the Wiki contexts.

and why not use urlparse?

… and why use it? Sorry, but maybe you should be more explicit here.

The [./SomeOtherPage Page] link now work as advertised in trunk, AFAICT: it will produce a link to a sub-page of the current page. For a sibling page, you'd have to use [../SomeSiblingPage Next Page].

In addition, if the rendering context specifies abs_urls=True, then the generating links will be absolute ones.

comment:6 by ittayd@…, 18 years ago

to elaborate:

  • say i'm in page foo/bar/zoo, and i call wiki_to_html on A/B/C, then if it contains D, the url will be http:/.../wiki/A/B/D.
  • urljoin provides the functionality of joining a base and relative url.

in reply to:  6 comment:7 by Christian Boos, 18 years ago

What you described was the 0.10 behavior, which tried to make the behavior of relative TracLinks similar to those of relative URLs. I changed this semantic for 0.11 (as documented in r4442), because there was no way to take the current page into account, which is required for being able to create relative links to sub-pages. With URLs, you obviously don't have this issue, as anything which is not prefixed will be relative to the current page. Conversely, in the Wiki, non-prefixed links are still "absolute" ones, e.g. linking to TracBrowser from anywhere in the Wiki, however deep, still links to .../wiki/TracBrowser.

So, for relative TracLinks written in some content attached to page A/B/C, we have the following semantics:

TracLinks 0.10 0.11
. A/B parent A/B/C self
.. A/B/D grand-parent A/B parent
./D A/B/D sibling A/B/C/D sub-page
../D A/D uncle… A/B/D sibling

Not to mention that without WikiContext (so in 0.10), you have no ways to specify links relative to page A/B/C when calling wiki_to_html in page foo/bar/zoo.

With 0.11, if ctx is set to be the context for wiki:foo/bar/zoo, then rendering A/B/C content with correct relative links is a matter of calling:

ctx('wiki', 'A/B/C').wiki_to_html(abc_content)

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Christian Boos.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Christian Boos to the specified user.

Add Comment


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