]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Plugin/recentchanges.pm
move recentchanges link enabling into a pagetemplate hook
[ikiwiki.git] / IkiWiki / Plugin / recentchanges.pm
index f5982604bd7c091a8604700663062b36b3d5973c..8ceb2dfbf9da8036ed08bc56efafda4c284199ae 100644 (file)
@@ -9,6 +9,7 @@ sub import { #{{{
        hook(type => "checkconfig", id => "recentchanges", call => \&checkconfig);
        hook(type => "refresh", id => "recentchanges", call => \&refresh);
        hook(type => "htmlize", id => "_change", call => \&htmlize);
+       hook(type => "pagetemplate", id => "recentchanges", call => \&pagetemplate);
 } #}}}
 
 sub checkconfig () { #{{{
@@ -32,6 +33,18 @@ sub refresh ($) { #{{{
        }
 } #}}}
 
+# Enable the recentchanges link on wiki pages.
+sub pagetemplate (@) { #{{{
+       my %params=@_;
+       my $template=$params{template};
+       my $page=$params{page};
+       if ($config{rcs} && $page ne $config{recentchangespage} &&
+           $template->query(name => "recentchangesurl")) {
+               $template->param(recentchangesurl => urlto($config{recentchangespage}, $page));
+               $template->param(have_actions => 1);
+       }
+} #}}}
+
 # Pages with extension _change have plain html markup, pass through.
 sub htmlize (@) { #{{{
        my %params=@_;
@@ -60,12 +73,15 @@ sub store ($$$) { #{{{
                        else {
                                $_->{link} = IkiWiki::pagetitle($_->{page});
                        }
+                       $_->{baseurl}="$config{url}/" if length $config{url};
+
                        $_;
                } @{$change->{pages}}
        ];
        push @{$change->{pages}}, { link => '...' } if $is_excess;
 
        # See if the committer is an openid.
+       $change->{author}=$change->{user};
        my $oiduser=IkiWiki::openiduser($change->{user});
        if (defined $oiduser) {
                $change->{authorurl}=$change->{user};
@@ -93,7 +109,6 @@ sub store ($$$) { #{{{
                commitdate => displaytime($change->{when}, "%X %x"),
                wikiname => $config{wikiname},
        );
-       $template->param(baseurl => "$config{url}/") if length $config{url};
        IkiWiki::run_hooks(pagetemplate => sub {
                shift->(page => $page, destpage => $page, template => $template);
        });