]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki.pm
Fix permalinks to recentchanges items and comments, broken by last release.
[ikiwiki.git] / IkiWiki.pm
index 41e9e3f82d3cc89f44b953c8b3a47def74758fb4..3a4cfd5e730cd7fc04a14a94d8a3fbd71f053fc5 100644 (file)
@@ -544,7 +544,7 @@ sub checkconfig () {
                error(gettext("Must specify url to wiki with --url when using --cgi"));
        }
 
-       if (length $config{url}) {
+       if (defined $config{url} && length $config{url}) {
                eval q{use URI};
                my $baseurl = URI->new($config{url});
 
@@ -566,6 +566,9 @@ sub checkconfig () {
 
                $local_url =~ s{//$}{/};
        }
+       else {
+               $local_cgiurl = $config{cgiurl};
+       }
 
        $config{wikistatedir}="$config{srcdir}/.ikiwiki"
                unless exists $config{wikistatedir} && defined $config{wikistatedir};
@@ -1057,7 +1060,7 @@ sub cgiurl (@) {
 sub baseurl (;$) {
        my $page=shift;
 
-       return "$config{url}/" if ! defined $page;
+       return $local_url if ! defined $page;
        
        $page=htmlpage($page);
        $page=~s/[^\/]+$//;
@@ -1131,13 +1134,13 @@ sub beautify_urlpath ($) {
        return $url;
 }
 
-sub urlto ($$;$) {
+sub urlto ($;$$) {
        my $to=shift;
        my $from=shift;
        my $absolute=shift;
        
        if (! length $to) {
-               return beautify_urlpath(baseurl($from)."index.$config{htmlext}");
+               $to = 'index';
        }
 
        if (! $destsources{$to}) {
@@ -1148,6 +1151,12 @@ sub urlto ($$;$) {
                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);
@@ -1236,7 +1245,7 @@ sub userpage ($) {
 sub openiduser ($) {
        my $user=shift;
 
-       if ($user =~ m!^https?://! &&
+       if (defined $user && $user =~ m!^https?://! &&
            eval q{use Net::OpenID::VerifiedIdentity; 1} && !$@) {
                my $display;
 
@@ -1882,6 +1891,7 @@ sub template_depends ($$;@) {
                },
                loop_context_vars => 1,
                die_on_bad_params => 0,
+               parent_global_vars => 1,
                filename => $filename,
                @_,
                ($untrusted ? (no_includes => 1) : ()),
@@ -1921,7 +1931,7 @@ sub misctemplate ($$;@) {
                title => $title,
                wikiname => $config{wikiname},
                content => $content,
-               baseurl => baseurl(),
+               baseurl => $config{url},
                html5 => $config{html5},
                %params,
        );
@@ -2023,7 +2033,7 @@ sub rcs_recentchanges ($) {
        $hooks{rcs}{rcs_recentchanges}{call}->(@_);
 }
 
-sub rcs_diff ($) {
+sub rcs_diff ($;$) {
        $hooks{rcs}{rcs_diff}{call}->(@_);
 }