+}
+
+sub genindex ($) {
+ my $page=shift;
+ my $file=newpagefile($page, $config{default_pageext});
+
+ add_autofile($file, "autoindex", sub {
+ my $message = sprintf(gettext("creating index page %s"),
+ $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, $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();
+ }
+ });
+}