2 package IkiWiki::Plugin::autoindex;
10 hook(type => "refresh", id => "autoindex", call => \&refresh);
13 sub genindex ($) { #{{{
15 my $file=$page.".".$config{default_pageext};
16 my $template=template("autoindex.tmpl");
17 $template->param(page => $page);
18 writefile($file, $config{srcdir}, $template->output);
20 IkiWiki::rcs_add($file);
25 eval q{use File::Find};
33 if (IkiWiki::file_pruned($_, $config{srcdir})) {
37 my ($f)=/$config{wiki_file_regexp}/; # untaint
38 return unless defined $f;
39 $f=~s/^\Q$config{srcdir}\E\/?//;
40 return unless length $f;
42 $pages{pagename($f)}=1;
52 foreach my $dir (keys %dirs) {
53 if (! exists $pages{$dir}) {
60 IkiWiki::disable_commit_hook();
62 genindex($_) foreach @needed;
64 IkiWiki::rcs_commit_staged(
65 gettext("automatic index generation"),
67 IkiWiki::enable_commit_hook();