2 package IkiWiki::Plugin::autoindex;
10 hook(type => "getsetup", id => "autoindex", call => \&getsetup);
11 hook(type => "refresh", id => "autoindex", call => \&refresh);
14 sub getsetup () { #{{{
22 sub genindex ($) { #{{{
24 my $file=$page.".".$config{default_pageext};
25 my $template=template("autoindex.tmpl");
26 $template->param(page => $page);
27 writefile($file, $config{srcdir}, $template->output);
29 IkiWiki::rcs_add($file);
34 eval q{use File::Find};
42 if (IkiWiki::file_pruned($_, $config{srcdir})) {
46 my ($f)=/$config{wiki_file_regexp}/; # untaint
47 return unless defined $f;
48 $f=~s/^\Q$config{srcdir}\E\/?//;
49 return unless length $f;
51 $pages{pagename($f)}=1;
61 foreach my $dir (keys %dirs) {
62 if (! exists $pages{$dir}) {
69 IkiWiki::disable_commit_hook();
71 genindex($_) foreach @needed;
73 IkiWiki::rcs_commit_staged(
74 gettext("automatic index generation"),
76 IkiWiki::enable_commit_hook();