- my $template=template("autoindex.tmpl");
- $template->param(page => $page);
- writefile($file, $config{srcdir}, $template->output);
- if ($config{rcs}) {
- IkiWiki::rcs_add($file);
- }
+
+ add_autofile($file, "autoindex", sub {
+ my $message = sprintf(gettext("creating index page %s"),
+ $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, $dir, $template->output);
+
+ if ($config{rcs} && $config{autoindex_commit}) {
+ IkiWiki::disable_commit_hook();
+ IkiWiki::rcs_add($file);
+ IkiWiki::rcs_commit_staged(message => $message);
+ IkiWiki::enable_commit_hook();
+ }
+ });