summaryrefslogtreecommitdiff
path: root/IkiWiki
diff options
context:
space:
mode:
authorJoey Hess <joey@kodama.kitenet.net>2008-01-29 15:22:23 -0500
committerJoey Hess <joey@kodama.kitenet.net>2008-01-29 15:22:23 -0500
commitcabd5140c4d6255afdcb527e7f6d7e7815e4aa43 (patch)
treea880f5fef4835bfe91807cae16f75ec944d0c4f6 /IkiWiki
parent7e52cc90b21b100571324dad3060259eba66af88 (diff)
add code to delete old change pages
Diffstat (limited to 'IkiWiki')
-rw-r--r--IkiWiki/Plugin/recentchanges.pm16
1 files changed, 13 insertions, 3 deletions
diff --git a/IkiWiki/Plugin/recentchanges.pm b/IkiWiki/Plugin/recentchanges.pm
index 2525785e7..8f707afc4 100644
--- a/IkiWiki/Plugin/recentchanges.pm
+++ b/IkiWiki/Plugin/recentchanges.pm
@@ -41,7 +41,7 @@ sub store ($$) { #{{{
# Optimisation to avoid re-writing pages. Assumes commits never
# change (or that any changes are not important).
- return if exists $pagesources{$page} && ! $config{rebuild};
+ return $page if exists $pagesources{$page} && ! $config{rebuild};
# Limit pages to first 10, and add links to the changed pages.
my $is_excess = exists $change->{pages}[10];
@@ -97,18 +97,28 @@ sub store ($$) { #{{{
my $file=$page."._change";
writefile($file, $config{srcdir}, $template->output);
utime $change->{when}, $change->{when}, "$config{srcdir}/$file";
+
+ return $page;
} #}}}
sub updatechanges ($$) { #{{{
my $pagespec=shift;
my $subdir=shift;
my @changes=@{shift()};
+
+ my %seen;
+ # add new changes
foreach my $change (@changes) {
- store($change, $subdir);
+ $seen{store($change, $subdir)}=1;
}
- # TODO: delete old
+ # delete old and excess changes
+ foreach my $page (keys %pagesources) {
+ if ($page=~/^\Q$subdir\E\/change_/ && ! $seen{$page}) {
+ unlink($config{srcdir}.'/'.$pagesources{$page});
+ }
+ }
} #}}}
1