]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki.pm
refactor template actions
[ikiwiki.git] / IkiWiki.pm
index 46c29abe38a045b813a8a32a632c3f97c729faa8..a42f56bf0c6d2320c7403af19618e3b65f5f966a 100644 (file)
@@ -1755,18 +1755,32 @@ sub misctemplate ($$;@) {
                html5 => $config{html5},
                @_,
        );
+
+       templateactions($template, "");
        
+       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 => "");
+                       grep { defined } shift->(page => $page);
        });
        $template->param(actions => \@actions);
-       if (@actions) {
-               $template->param(have_actions => 1);
+
+       if ($config{cgiurl} && exists $hooks{auth}) {
+               $template->param(prefsurl => cgiurl(do => "prefs"));
+               $have_actions=1;
        }
 
-       return $template->output;
+       if ($have_actions || @actions) {
+               $template->param(have_actions => 1);
+       }
 }
 
 sub hook (@) {