aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/autoindex.pm
diff options
context:
space:
mode:
authorSimon McVittie <smcv@debian.org>2011-01-06 00:15:28 +0000
committerSimon McVittie <smcv@debian.org>2011-01-22 22:25:48 +0000
commitdca6679a5442581746daf89e78ee83712a017b98 (patch)
tree5f088c4ceeb332651b4e9593ae60afaafc7c1264 /IkiWiki/Plugin/autoindex.pm
parent0118479c9a8977ff3198622829ac4a0f3ea0de76 (diff)
downloadikiwiki-dca6679a5442581746daf89e78ee83712a017b98.tar
ikiwiki-dca6679a5442581746daf89e78ee83712a017b98.tar.gz
autoindex: use add_autofile
This does cause a minor regression: index pages are now committed individually rather than being a single commit per rebuild. This also means the autoindex regression test needs to trigger the autofile generation pass.
Diffstat (limited to 'IkiWiki/Plugin/autoindex.pm')
-rw-r--r--IkiWiki/Plugin/autoindex.pm37
1 files changed, 21 insertions, 16 deletions
diff --git a/IkiWiki/Plugin/autoindex.pm b/IkiWiki/Plugin/autoindex.pm
index 11595e217..ba2dcb907 100644
--- a/IkiWiki/Plugin/autoindex.pm
+++ b/IkiWiki/Plugin/autoindex.pm
@@ -22,12 +22,23 @@ sub getsetup () {
sub genindex ($) {
my $page=shift;
my $file=newpagefile($page, $config{default_pageext});
- my $template=template("autoindex.tmpl");
- $template->param(page => $page);
- writefile($file, $config{srcdir}, $template->output);
- if ($config{rcs}) {
- IkiWiki::rcs_add($file);
- }
+
+ add_autofile($file, "autoindex", sub {
+ my $message = sprintf(gettext("creating index page %s"),
+ $page);
+ debug($message);
+
+ my $template = template("autoindex.tmpl");
+ $template->param(page => $page);
+ writefile($file, $config{srcdir}, $template->output);
+
+ if ($config{rcs}) {
+ IkiWiki::disable_commit_hook();
+ IkiWiki::rcs_add($file);
+ IkiWiki::rcs_commit_staged(message => $message);
+ IkiWiki::enable_commit_hook();
+ }
+ });
}
sub refresh () {
@@ -66,7 +77,10 @@ sub refresh () {
chdir($origdir) || die "chdir $origdir: $!";
}
-
+
+ # FIXME: some of this is probably redundant with add_autofile now, and
+ # the rest should perhaps be added to the autofile machinery
+
my %deleted;
if (ref $wikistate{autoindex}{deleted}) {
%deleted=%{$wikistate{autoindex}{deleted}};
@@ -109,18 +123,9 @@ sub refresh () {
}
if (@needed) {
- if ($config{rcs}) {
- IkiWiki::disable_commit_hook();
- }
foreach my $page (@needed) {
genindex($page);
}
- if ($config{rcs}) {
- IkiWiki::rcs_commit_staged(
- message => gettext("automatic index generation"),
- );
- IkiWiki::enable_commit_hook();
- }
}
}