]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Plugin/recentchanges.pm
use new refresh hook
[ikiwiki.git] / IkiWiki / Plugin / recentchanges.pm
index 6c9848ba356213d27b8886fa716395743654bfa0..2525785e7dea0d1d219c29ede9ed99f2550012b1 100644 (file)
@@ -6,15 +6,15 @@ use strict;
 use IkiWiki 2.00;
 
 sub import { #{{{
-       hook(type => "needsbuild", id => "recentchanges",
-               call => \&needsbuild);
+       hook(type => "refresh", id => "recentchanges",
+               call => \&refresh);
        hook(type => "preprocess", id => "recentchanges",
                call => \&preprocess);
        hook(type => "htmlize", id => "_change",
                call => \&htmlize);
 } #}}}
 
-sub needsbuild () { #{{{
+sub refresh ($) { #{{{
        my @changes=IkiWiki::rcs_recentchanges(100);
        updatechanges("*", "recentchanges", \@changes);
 } #}}}
@@ -61,11 +61,6 @@ sub store ($$) { #{{{
        ];
        push @{$change->{pages}}, { link => '...' } if $is_excess;
 
-       # Take the first line of the commit message as a summary.
-       #my $m=shift @{$change->{message}};
-       #$change->{summary}=$m->{line};
-       #delete $change->{message} unless @{$change->{message}};
-
        # See if the committer is an openid.
        my $oiduser=IkiWiki::openiduser($change->{user});
        if (defined $oiduser) {
@@ -78,6 +73,15 @@ sub store ($$) { #{{{
                        $change->{user};
        }
 
+       # escape  wikilinks and preprocessor stuff in commit messages
+       if (ref $change->{message}) {
+               foreach my $field (@{$change->{message}}) {
+                       if (exists $field->{line}) {
+                               $field->{line} =~ s/(?<!\\)\[\[/\\\[\[/g;
+                       }
+               }
+       }
+
        # Fill out a template with the change info.
        my $template=template("change.tmpl", blind_cache => 1);
        $template->param(
@@ -90,20 +94,20 @@ sub store ($$) { #{{{
                shift->(page => $page, destpage => $page, template => $template);
        });
 
-       my $html=$template->output;
-       # escape  wikilinks and preprocessor stuff
-       $html=~s/(?<!\\)\[\[/\\\[\[/g;
-       writefile($page."._change", $config{srcdir}, $html);
-       utime $change->{when}, $change->{when}, "$config{srcdir}/$page._change";
+       my $file=$page."._change";
+       writefile($file, $config{srcdir}, $template->output);
+       utime $change->{when}, $change->{when}, "$config{srcdir}/$file";
 } #}}}
 
 sub updatechanges ($$) { #{{{
        my $pagespec=shift;
        my $subdir=shift;
        my @changes=@{shift()};
+
        foreach my $change (@changes) {
                store($change, $subdir);
        }
+       
        # TODO: delete old
 } #}}}