aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki
diff options
context:
space:
mode:
authorJoey Hess <joey@kodama.kitenet.net>2008-01-29 15:51:32 -0500
committerJoey Hess <joey@kodama.kitenet.net>2008-01-29 15:51:32 -0500
commit8b31c53366bbee51b36501443eafd0f712ee6a4c (patch)
tree5c3f3645b4e3d7439f57fc954d6af6ca8bfd3497 /IkiWiki
parentcabd5140c4d6255afdcb527e7f6d7e7815e4aa43 (diff)
downloadikiwiki-8b31c53366bbee51b36501443eafd0f712ee6a4c.tar
ikiwiki-8b31c53366bbee51b36501443eafd0f712ee6a4c.tar.gz
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')
-rw-r--r--IkiWiki/Plugin/recentchanges.pm54
-rw-r--r--IkiWiki/Render.pm4
2 files changed, 24 insertions, 34 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
diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm
index b5b461499..ed359bdd7 100644
--- a/IkiWiki/Render.pm
+++ b/IkiWiki/Render.pm
@@ -85,8 +85,8 @@ sub genpage ($$) { #{{{
$actions++;
}
- if ($config{rcs}) {
- $template->param(recentchangesurl => urlto("recentchanges", $page));
+ if ($config{rcs} && exists $config{recentchangespage}) {
+ $template->param(recentchangesurl => urlto($config{recentchangespage}, $page));
$actions++;
}