X-Git-Url: https://sipb.mit.edu/gitweb.cgi/ikiwiki.git/blobdiff_plain/11937595687df86aa93502d2e895f747a6262c4c..47bc6105326ce76327f2accb6d6ae34d2cb1429e:/IkiWiki.pm diff --git a/IkiWiki.pm b/IkiWiki.pm index 0da2c93c8..699ad13da 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -1004,7 +1004,7 @@ sub displaytime ($;$$) { my $time=formattime($_[0], $_[1]); if ($config{html5}) { return ''; } else { @@ -1745,24 +1745,43 @@ sub misctemplate ($$;@) { run_hooks(pagetemplate => sub { shift->(page => "", destpage => "", template => $template); }); + templateactions($template, ""); $template->param( + dynamic => 1, title => $title, wikiname => $config{wikiname}, content => $content, baseurl => baseurl(), html5 => $config{html5}, - have_actions => 0, # force off - parentlinks => [{ # override - url => $config{url}, - page => $config{wikiname}, - }], @_, ); - + return $template->output; } +sub templateactions ($$) { + my $template=shift; + my $page=shift; + + my $have_actions=0; + my @actions; + run_hooks(pageactions => sub { + push @actions, map { { action => $_ } } + grep { defined } shift->(page => $page); + }); + $template->param(actions => \@actions); + + if ($config{cgiurl} && exists $hooks{auth}) { + $template->param(prefsurl => cgiurl(do => "prefs")); + $have_actions=1; + } + + if ($have_actions || @actions) { + $template->param(have_actions => 1); + } +} + sub hook (@) { my %param=@_; @@ -2332,11 +2351,7 @@ sub match_glob ($$;@) { my $regexp=IkiWiki::glob2re($glob); if ($page=~/^$regexp$/i) { - if ($params{onlypage} && - ! defined IkiWiki::pagetype($IkiWiki::pagesources{$page})) { - return IkiWiki::FailReason->new("$page is not a page"); - } - elsif (! IkiWiki::isinternal($page) || $params{internal}) { + if (! IkiWiki::isinternal($page) || $params{internal}) { return IkiWiki::SuccessReason->new("$glob matches $page"); } else { @@ -2349,11 +2364,19 @@ sub match_glob ($$;@) { } sub match_internal ($$;@) { - return match_glob($_[0], $_[1], @_, internal => 1) + return match_glob(shift, shift, @_, internal => 1) } sub match_page ($$;@) { - return match_glob($_[0], $_[1], @_, onlypage => 1) + my $page=shift; + my $match=match_glob($page, shift, @_); + if ($match && ! (exists $IkiWiki::pagesources{$page} + && defined IkiWiki::pagetype($IkiWiki::pagesources{$page}))) { + return IkiWiki::FailReason->new("$page is not a page"); + } + else { + return $match; + } } sub match_link ($$;@) {