[Moin-devel] [Patch] Generating relative links

Carl Worth cworth at cworth.org
Tue Dec 7 17:57:00 EST 2004


On Mon, 22 Nov 2004 14:31:58 -0500, Carl Worth wrote:
> The patch is against version 1.2.4 (as found in recent
> Debian/unstable). Let me know if I should regenerate it against a newer
> version.

I was told in IRC that a patch against the 1.3 stuff would be much
better. I've now spent some time with that and attached the results.

My previous patch replaced code like

> 	"%s/%s" % (request.getScriptname(), pagename)

with

> 	"%s%s" % (request.getRelativeScriptname(), pagename)

and then made getRelativeScriptname return '' if the relative_links
configuration parameter was true.

I reworked this patch against 1.3 and tested it quite thoroughly. It
worked almost everywhere, except for hierarchical pages where it breaks
completely, (as should be obvious).

The current patch is a step toward fixing that, but it will still need
some further work from someone who knows moin internals better than I
do.

It now has the literal '/' back into the format strings, and no
getRelativeScriptname returns '.' rather than ''.

So there are at least two things that need to be fixed:

1) The addition of "./" at the beginning of the script name seems to
   confuse moin. This will be quite apparent to anyone who applies the
   patch and tries it out. I imagine it should be a very simple matter
   to strip off this prefix early in the processing.

2) Hierarchical pages still aren't working with relative links, but the
   fix should now be very simple. It should simply be a matter of making
   getRelativeScriptname return something like ("../" * depth) for any
   hierarchical pages.

If someone wants to pick p the patch from here I would be glad to test
it. I probably won't do any more work on it myself since I'm still
dealing with a 1.2 installation and I've found an alternate solution to
the problem I was trying to solve.

I still think it would be good in the long run to switch to using
relative links. (And if it works well it might make more sense to not
make it conditional).

-Carl

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/moin-devel/attachments/20041207/664b7ef4/attachment.html>


More information about the Moin-devel mailing list