X-Git-Url: https://sipb.mit.edu/gitweb.cgi/ikiwiki.git/blobdiff_plain/d9d910f6765de6ba07508ab56a5a0f93edb4c8ad..8496dd9fb405eda149995615ead0a94a83298b91:/IkiWiki.pm diff --git a/IkiWiki.pm b/IkiWiki.pm index 11cfcdfd2..e2a3d216f 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -12,9 +12,9 @@ use open qw{:utf8 :std}; use vars qw{%config %links %oldlinks %pagemtime %pagectime %pagecase %pagestate %wikistate %renderedfiles %oldrenderedfiles - %pagesources %destsources %depends %depends_simple @mass_depends - %hooks %forcerebuild %loaded_plugins %typedlinks %oldtypedlinks - %autofiles}; + %pagesources %delpagesources %destsources %depends %depends_simple + @mass_depends %hooks %forcerebuild %loaded_plugins %typedlinks + %oldtypedlinks %autofiles}; use Exporter q{import}; our @EXPORT = qw(hook debug error htmlpage template template_depends @@ -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 { @@ -2440,7 +2463,7 @@ sub match_created_after ($$;@) { } sub match_creation_day ($$;@) { - if ((gmtime($IkiWiki::pagectime{shift()}))[3] == shift) { + if ((localtime($IkiWiki::pagectime{shift()}))[3] == shift) { return IkiWiki::SuccessReason->new('creation_day matched'); } else { @@ -2449,7 +2472,7 @@ sub match_creation_day ($$;@) { } sub match_creation_month ($$;@) { - if ((gmtime($IkiWiki::pagectime{shift()}))[4] + 1 == shift) { + if ((localtime($IkiWiki::pagectime{shift()}))[4] + 1 == shift) { return IkiWiki::SuccessReason->new('creation_month matched'); } else { @@ -2458,7 +2481,7 @@ sub match_creation_month ($$;@) { } sub match_creation_year ($$;@) { - if ((gmtime($IkiWiki::pagectime{shift()}))[5] + 1900 == shift) { + if ((localtime($IkiWiki::pagectime{shift()}))[5] + 1900 == shift) { return IkiWiki::SuccessReason->new('creation_year matched'); } else {