use new refresh hook

master
Joey Hess 2008-01-29 13:08:48 -05:00
parent e1ce482e41
commit 35bc35660c
1 changed files with 7 additions and 11 deletions

View File

@ -6,18 +6,17 @@ use strict;
use IkiWiki 2.00; use IkiWiki 2.00;
sub import { #{{{ sub import { #{{{
hook(type => "needsbuild", id => "recentchanges", hook(type => "refresh", id => "recentchanges",
call => \&needsbuild); call => \&refresh);
hook(type => "preprocess", id => "recentchanges", hook(type => "preprocess", id => "recentchanges",
call => \&preprocess); call => \&preprocess);
hook(type => "htmlize", id => "_change", hook(type => "htmlize", id => "_change",
call => \&htmlize); call => \&htmlize);
} #}}} } #}}}
sub needsbuild ($) { #{{{ sub refresh ($) { #{{{
my $needsbuild=shift;
my @changes=IkiWiki::rcs_recentchanges(100); my @changes=IkiWiki::rcs_recentchanges(100);
push @$needsbuild, updatechanges("*", "recentchanges", \@changes); updatechanges("*", "recentchanges", \@changes);
} #}}} } #}}}
sub preprocess (@) { #{{{ sub preprocess (@) { #{{{
@ -98,21 +97,18 @@ sub store ($$) { #{{{
my $file=$page."._change"; my $file=$page."._change";
writefile($file, $config{srcdir}, $template->output); writefile($file, $config{srcdir}, $template->output);
utime $change->{when}, $change->{when}, "$config{srcdir}/$file"; utime $change->{when}, $change->{when}, "$config{srcdir}/$file";
return $file;
} #}}} } #}}}
sub updatechanges ($$) { #{{{ sub updatechanges ($$) { #{{{
my $pagespec=shift; my $pagespec=shift;
my $subdir=shift; my $subdir=shift;
my @changes=@{shift()}; my @changes=@{shift()};
my @ret;
foreach my $change (@changes) { foreach my $change (@changes) {
my $file=store($change, $subdir); store($change, $subdir);
push @ret, $file if defined $file;
} }
# TODO: delete old
return @ret; # TODO: delete old
} #}}} } #}}}
1 1