urlto(): if $from is undef, return a local path, not an absolute URL
authorSimon McVittie <smcv@debian.org>
Mon, 22 Nov 2010 23:33:13 +0000 (23:33 +0000)
committerSimon McVittie <smcv@debian.org>
Mon, 22 Nov 2010 23:47:05 +0000 (23:47 +0000)
IkiWiki.pm
doc/plugins/write.mdwn

index a4afef8e0381f337d9cf8c26fe961210a2f5aaf0..ee0b1f1ea6f3ee4665857a317eb5e68e8acd61fe 100644 (file)
@@ -1148,6 +1148,12 @@ sub urlto ($$;$) {
                return $config{url}.beautify_urlpath("/".$to);
        }
 
                return $config{url}.beautify_urlpath("/".$to);
        }
 
+       if (! defined $from) {
+               my $u = $local_url;
+               $u =~ s{/$}{};
+               return $u.beautify_urlpath("/".$to);
+       }
+
        my $link = abs2rel($to, dirname(htmlpage($from)));
 
        return beautify_urlpath($link);
        my $link = abs2rel($to, dirname(htmlpage($from)));
 
        return beautify_urlpath($link);
index 6b751f0cd639bf042c7fba2c4813cc918f914e31..33db3e707d8ad816bcc80a807ec8c8098fe72ec7 100644 (file)
@@ -988,6 +988,10 @@ Construct a relative url to the first parameter from the page named by the
 second. The first parameter can be either a page name, or some other
 destination file, as registered by `will_render`.
 
 second. The first parameter can be either a page name, or some other
 destination file, as registered by `will_render`.
 
+If the second parameter is `undef`, the URL will be valid from any page on the
+wiki, or from the CGI; if possible it'll be a path starting with `/`, but an
+absolute URL will be used if the wiki and the CGI are on different servers.
+
 If the third parameter is passed and is true, an absolute url will be
 constructed instead of the default relative url.
 
 If the third parameter is passed and is true, an absolute url will be
 constructed instead of the default relative url.