]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki.pm
point to rebased patches containling only raw-inline code.
[ikiwiki.git] / IkiWiki.pm
index a4afef8e0381f337d9cf8c26fe961210a2f5aaf0..799236f35fc2e26cbbfa8a84abb711b53bffc809 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};
@@ -1065,6 +1068,16 @@ sub baseurl (;$) {
        return $page;
 }
 
+sub urlabs ($$) {
+       my $url=shift;
+       my $urlbase=shift;
+
+       return $url unless defined $urlbase && length $urlbase;
+
+       eval q{use URI};
+       URI->new_abs($url, $urlbase)->as_string;
+}
+
 sub abs2rel ($$) {
        # Work around very innefficient behavior in File::Spec if abs2rel
        # is passed two relative paths. It's much faster if paths are
@@ -1131,13 +1144,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 +1161,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 +1255,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 +1901,7 @@ sub template_depends ($$;@) {
                },
                loop_context_vars => 1,
                die_on_bad_params => 0,
+               parent_global_vars => 1,
                filename => $filename,
                @_,
                ($untrusted ? (no_includes => 1) : ()),
@@ -1896,39 +1916,6 @@ sub template ($;@) {
        template_depends(shift, undef, @_);
 }
 
-sub misctemplate ($$;@) {
-       my $title=shift;
-       my $content=shift;
-       my %params=@_;
-       
-       my $template=template("page.tmpl");
-
-       my $page="";
-       if (exists $params{page}) {
-               $page=delete $params{page};
-       }
-       run_hooks(pagetemplate => sub {
-               shift->(
-                       page => $page,
-                       destpage => $page,
-                       template => $template,
-               );
-       });
-       templateactions($template, "");
-
-       $template->param(
-               dynamic => 1,
-               title => $title,
-               wikiname => $config{wikiname},
-               content => $content,
-               baseurl => baseurl(),
-               html5 => $config{html5},
-               %params,
-       );
-       
-       return $template->output;
-}
-
 sub templateactions ($$) {
        my $template=shift;
        my $page=shift;
@@ -2023,7 +2010,7 @@ sub rcs_recentchanges ($) {
        $hooks{rcs}{rcs_recentchanges}{call}->(@_);
 }
 
-sub rcs_diff ($) {
+sub rcs_diff ($;$) {
        $hooks{rcs}{rcs_diff}{call}->(@_);
 }