]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Plugin/recentchanges.pm
escape wikilinks and preprocessor directives
[ikiwiki.git] / IkiWiki / Plugin / recentchanges.pm
index fb9841ffdfe00e7c639090713c1c5aa0f15575a3..6c9848ba356213d27b8886fa716395743654bfa0 100644 (file)
@@ -6,8 +6,6 @@ use strict;
 use IkiWiki 2.00;
 
 sub import { #{{{
-       hook(type => "checkconfig", id => "recentchanges",
-               call => \&checkconfig);
        hook(type => "needsbuild", id => "recentchanges",
                call => \&needsbuild);
        hook(type => "preprocess", id => "recentchanges",
@@ -16,15 +14,11 @@ sub import { #{{{
                call => \&htmlize);
 } #}}}
 
-sub checkconfig () { #{{{
+sub needsbuild () { #{{{
        my @changes=IkiWiki::rcs_recentchanges(100);
        updatechanges("*", "recentchanges", \@changes);
 } #}}}
 
-sub needsbuild () { #{{{
-       # TODO
-} #}}}
-
 sub preprocess (@) { #{{{
        my %params=@_;
 
@@ -68,8 +62,9 @@ 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};
+       #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});
@@ -85,13 +80,20 @@ sub store ($$) { #{{{
 
        # Fill out a template with the change info.
        my $template=template("change.tmpl", blind_cache => 1);
-       $template->param(%$change);
+       $template->param(
+               %$change,
+               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);
        });
 
-       writefile($page."._change", $config{srcdir}, $template->output);
+       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";
 } #}}}