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};
38 foreach my $dir ($config{srcdir}, @{$config{underlaydirs}}, $config{underlaydir}) {
43 if (IkiWiki::file_pruned($_, $dir)) {
47 my ($f)=/$config{wiki_file_regexp}/; # untaint
48 return unless defined $f;
50 return unless length $f;
51 return if $f =~ /\._([^.]+)$/; # skip internal page
53 $pages{pagename($f)}=1;
55 elsif ($dir eq $config{srcdir}) {
64 foreach my $dir (keys %dirs) {
65 if (! exists $pages{$dir} && grep /^$dir\/.*/, keys %pages) {
72 IkiWiki::disable_commit_hook();
74 genindex($_) foreach @needed;
76 IkiWiki::rcs_commit_staged(
77 gettext("automatic index generation"),
79 IkiWiki::enable_commit_hook();