diff options
author | Joey Hess <joey@kodama.kitenet.net> | 2008-01-29 15:51:32 -0500 |
---|---|---|
committer | Joey Hess <joey@kodama.kitenet.net> | 2008-01-29 15:51:32 -0500 |
commit | 8b31c53366bbee51b36501443eafd0f712ee6a4c (patch) | |
tree | 5c3f3645b4e3d7439f57fc954d6af6ca8bfd3497 /IkiWiki/Plugin | |
parent | cabd5140c4d6255afdcb527e7f6d7e7815e4aa43 (diff) |
added configuration for recentchanges
I kept it to a simple global configuration, rather than using the
preprocessor directive for recentchanges, because that had chicken and egg
problems and seemed overcomplicated. This should work reasonably well,
though it would be good to add some more metadata so that more customised
recentchanges pages can be made.
Diffstat (limited to 'IkiWiki/Plugin')
-rw-r--r-- | IkiWiki/Plugin/recentchanges.pm | 54 |
1 files changed, 22 insertions, 32 deletions
diff --git a/IkiWiki/Plugin/recentchanges.pm b/IkiWiki/Plugin/recentchanges.pm index 8f707afc4..f5982604b 100644 --- a/IkiWiki/Plugin/recentchanges.pm +++ b/IkiWiki/Plugin/recentchanges.pm @@ -6,25 +6,30 @@ use strict; use IkiWiki 2.00; sub import { #{{{ - hook(type => "refresh", id => "recentchanges", - call => \&refresh); - hook(type => "preprocess", id => "recentchanges", - call => \&preprocess); - hook(type => "htmlize", id => "_change", - call => \&htmlize); + hook(type => "checkconfig", id => "recentchanges", call => \&checkconfig); + hook(type => "refresh", id => "recentchanges", call => \&refresh); + hook(type => "htmlize", id => "_change", call => \&htmlize); } #}}} -sub refresh ($) { #{{{ - my @changes=IkiWiki::rcs_recentchanges(100); - updatechanges("*", "recentchanges", \@changes); +sub checkconfig () { #{{{ + $config{recentchangespage}='recentchanges' unless defined $config{recentchangespage}; + $config{recentchangesnum}=100 unless defined $config{recentchangesnum}; } #}}} -sub preprocess (@) { #{{{ - my %params=@_; - - # TODO +sub refresh ($) { #{{{ + my %seen; - return ""; + # add new changes + foreach my $change (IkiWiki::rcs_recentchanges($config{recentchangesnum})) { + $seen{store($change, $config{recentchangespage})}=1; + } + + # delete old and excess changes + foreach my $page (keys %pagesources) { + if ($page=~/^\Q$config{recentchangespage}\E\/change_/ && ! $seen{$page}) { + unlink($config{srcdir}.'/'.$pagesources{$page}); + } + } } #}}} # Pages with extension _change have plain html markup, pass through. @@ -33,11 +38,10 @@ sub htmlize (@) { #{{{ return $params{content}; } #}}} -sub store ($$) { #{{{ +sub store ($$$) { #{{{ my $change=shift; - my $subdir=shift; - - my $page="$subdir/change_".IkiWiki::titlepage($change->{rev}); + + my $page="$config{recentchangespage}/change_".IkiWiki::titlepage($change->{rev}); # Optimisation to avoid re-writing pages. Assumes commits never # change (or that any changes are not important). @@ -102,23 +106,9 @@ sub store ($$) { #{{{ } #}}} sub updatechanges ($$) { #{{{ - my $pagespec=shift; my $subdir=shift; my @changes=@{shift()}; - my %seen; - - # add new changes - foreach my $change (@changes) { - $seen{store($change, $subdir)}=1; - } - - # delete old and excess changes - foreach my $page (keys %pagesources) { - if ($page=~/^\Q$subdir\E\/change_/ && ! $seen{$page}) { - unlink($config{srcdir}.'/'.$pagesources{$page}); - } - } } #}}} 1 |