#4411 closed defect (fixed)
absurls in wiki_to_html doesn't seem to take care of relative links
Reported by: | 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 , 18 years ago
Component: | general → wiki |
---|---|
Milestone: | → 0.11 |
Owner: | changed from | to
Priority: | normal → high |
comment:2 by , 18 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
follow-up: 5 comment:3 by , 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:5 by , 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.
follow-up: 7 comment:6 by , 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.
comment:7 by , 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)
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.