X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/2e86b8df985067e101269bb4f8a41c5237af9f91..c5495420bd78882b90869551a7f79e548eb500f0:/IkiWiki.pm diff --git a/IkiWiki.pm b/IkiWiki.pm index 11cfcdfd2..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,10 +1745,10 @@ sub misctemplate ($$;@) { run_hooks(pagetemplate => sub { shift->(page => "", destpage => "", template => $template); }); + templateactions($template, ""); $template->param( dynamic => 1, - have_actions => 0, # force off title => $title, wikiname => $config{wikiname}, content => $content, @@ -1756,10 +1756,32 @@ sub misctemplate ($$;@) { html5 => $config{html5}, @_, ); - + 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=@_; @@ -2348,7 +2370,8 @@ sub match_internal ($$;@) { sub match_page ($$;@) { my $page=shift; my $match=match_glob($page, shift, @_); - if ($match && ! defined IkiWiki::pagetype($IkiWiki::pagesources{$page})) { + if ($match && ! (exists $IkiWiki::pagesources{$page} + && defined IkiWiki::pagetype($IkiWiki::pagesources{$page}))) { return IkiWiki::FailReason->new("$page is not a page"); } else {