[WM] Tidying up relative links on round substitution

Duncan Cameron dcameron.bcs.org.uk
Wed Feb 13 01:49:02 GMT 2002


What I meant to write was ...

I found that using references to images, etc., creates a relative link like
 ../site/images/logo.gif, whereas I really want the unnecessary up/down to be removed
as it will stop the site working once I move it (I publish the contents of the 'site'
directory, not the directory itself).


Regards,
Duncan Cameron

-----  Original message  -----
From: Duncan Cameron (dcameron.bcs.org.uk)
To: webmake (webmake-talk.lists.sourceforge.net)
Subject: [WM] Tidying up relative links on round substitution
Sent: 2002-02-12, 13:29:00

I've just started using Webmake and found that relative links weren't being created
as I'd like.  My directory structure is

work
...raw
...site
.......images
.......styles

My .wmk file and template.htm are in the work directory. html gets generated into the
site directory.
I found that using references to images, etc., creates a relative link like
site/images/logo.gif, whereas I really want it one level further down.

What I'd like to happen is that when a round substitution is resolved, any matching
leading directories of the substituted value and the current output file are 
removed.
Looking at the code in main.pm for _round_subst() and canon_path(),I saw that this is
nearly being done already.

We need to pass the current output file's path to canon_path() as the relative dir.
Then canon_path() already tries to solve this problem but falls foul of mixing
forward and backward slashes as directory separators. A small fix to convert all to
'/' solves that.

Attached is a diff file for version 2.3.
I'm using Windows98, so, as a lot of the tests fail anyway, I can't verify whether
this change has any adverse effects, but "it works for me".

Thanks

Duncan Cameron






More information about the Webmake-talk mailing list