Allow autoindex files to be written into the transient underlay
authorSimon McVittie <smcv@debian.org>
Sat, 25 Dec 2010 23:02:47 +0000 (23:02 +0000)
committerSimon McVittie <smcv@debian.org>
Sat, 22 Jan 2011 22:36:41 +0000 (22:36 +0000)
As with the tag plugin, for the moment keep the old behaviour in the test.

IkiWiki/Plugin/autoindex.pm
t/autoindex.t

index 5a58c820aaefa1244fd2b08947f82968ce945c37..d0261858104cdc2783709c7fafda468b94b975b4 100644 (file)
@@ -9,6 +9,7 @@ use Encode;
 sub import {
        hook(type => "getsetup", id => "autoindex", call => \&getsetup);
        hook(type => "refresh", id => "autoindex", call => \&refresh);
+       IkiWiki::loadplugin("transient");
 }
 
 sub getsetup () {
@@ -17,6 +18,14 @@ sub getsetup () {
                        safe => 1,
                        rebuild => 0,
                },
+               autoindex_commit => {
+                       type => "boolean",
+                       example => 1,
+                       default => 1,
+                       description => "commit autocreated index pages",
+                       safe => 1,
+                       rebuild => 0,
+               },
 }
 
 sub genindex ($) {
@@ -28,11 +37,16 @@ sub genindex ($) {
                                $page);
                        debug($message);
 
+                       my $dir = $config{srcdir};
+                       if (! $config{autoindex_commit}) {
+                               $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);
index 665f0dc1cdf20991f1398b2fc37b1e7eb2de951b..1e40b4c53136273089e03070d742afd56431f4fd 100755 (executable)
@@ -26,6 +26,7 @@ $config{userdir} = "users";
 $config{tagbase} = "tags";
 $config{default_pageext} = "mdwn";
 $config{wiki_file_prune_regexps} = [qr/^\./];
+$config{autoindex_commit} = 1;
 
 is(checkconfig(), 1);