X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/8ee9eabb1c5314f51641aaec4cb45d5c2d0fa7b8..766311f45b4351488d7dad519a6471094a58da16:/IkiWiki/Plugin/autoindex.pm diff --git a/IkiWiki/Plugin/autoindex.pm b/IkiWiki/Plugin/autoindex.pm index 5a58c820a..c443f01d2 100644 --- a/IkiWiki/Plugin/autoindex.pm +++ b/IkiWiki/Plugin/autoindex.pm @@ -7,8 +7,10 @@ use IkiWiki 3.00; use Encode; sub import { + hook(type => "checkconfig", id => "autoindex", call => \&checkconfig); hook(type => "getsetup", id => "autoindex", call => \&getsetup); hook(type => "refresh", id => "autoindex", call => \&refresh); + IkiWiki::loadplugin("transient"); } sub getsetup () { @@ -17,6 +19,20 @@ sub getsetup () { safe => 1, rebuild => 0, }, + autoindex_commit => { + type => "boolean", + example => 1, + default => 1, + description => "commit autocreated index pages", + safe => 1, + rebuild => 0, + }, +} + +sub checkconfig () { + if (! defined $config{autoindex_commit}) { + $config{autoindex_commit} = 1; + } } sub genindex ($) { @@ -28,11 +44,17 @@ sub genindex ($) { $page); debug($message); + my $dir = $config{srcdir}; + if (! $config{autoindex_commit}) { + no warnings 'once'; + $dir = $IkiWiki::Plugin::transient::transientdir; + } + my $template = template("autoindex.tmpl"); $template->param(page => $page); - writefile($file, $config{srcdir}, $template->output); + writefile($file, $dir, $template->output); - if ($config{rcs}) { + if ($config{rcs} && $config{autoindex_commit}) { IkiWiki::disable_commit_hook(); IkiWiki::rcs_add($file); IkiWiki::rcs_commit_staged(message => $message); @@ -59,6 +81,7 @@ sub refresh () { $file=~s/^\.\/?//; return unless length $file; if (IkiWiki::file_pruned($file)) { + no warnings 'once'; $File::Find::prune=1; } elsif (! -l $_) { @@ -68,7 +91,7 @@ sub refresh () { if (! -d _) { $pages{pagename($f)}=1; } - elsif ($dir eq $config{srcdir}) { + elsif ($dir eq $config{srcdir} || ! $config{autoindex_commit}) { $dirs{$f}=1; } }