summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--IkiWiki/Plugin/tag.pm27
-rwxr-xr-xt/tag.t10
2 files changed, 31 insertions, 6 deletions
diff --git a/IkiWiki/Plugin/tag.pm b/IkiWiki/Plugin/tag.pm
index fd5ce1e8a..13dabce0c 100644
--- a/IkiWiki/Plugin/tag.pm
+++ b/IkiWiki/Plugin/tag.pm
@@ -7,11 +7,14 @@ use strict;
use IkiWiki 3.00;
sub import {
+ hook(type => "checkconfig", id => "tag", call => \&checkconfig);
hook(type => "getopt", id => "tag", call => \&getopt);
hook(type => "getsetup", id => "tag", call => \&getsetup);
hook(type => "preprocess", id => "tag", call => \&preprocess_tag, scan => 1);
hook(type => "preprocess", id => "taglink", call => \&preprocess_taglink, scan => 1);
hook(type => "pagetemplate", id => "tag", call => \&pagetemplate);
+
+ IkiWiki::loadplugin("transient");
}
sub getopt () {
@@ -41,6 +44,20 @@ sub getsetup () {
safe => 1,
rebuild => undef,
},
+ tag_autocreate_commit => {
+ type => "boolean",
+ example => 1,
+ default => 1,
+ description => "commit autocreated tag pages",
+ safe => 1,
+ rebuild => 0,
+ },
+}
+
+sub checkconfig () {
+ if (! defined $config{tag_autocreate_commit}) {
+ $config{tag_autocreate_commit} = 1;
+ }
}
sub taglink ($) {
@@ -97,8 +114,14 @@ sub gentag ($) {
my $template=template("autotag.tmpl");
$template->param(tagname => tagname($tag));
$template->param(tag => $tag);
- writefile($tagfile, $config{srcdir}, $template->output);
- if ($config{rcs}) {
+
+ my $dir = $config{srcdir};
+ if (! $config{tag_autocreate_commit}) {
+ $dir = $IkiWiki::Plugin::transient::transientdir;
+ }
+
+ writefile($tagfile, $dir, $template->output);
+ if ($config{rcs} && $config{tag_autocreate_commit}) {
IkiWiki::disable_commit_hook();
IkiWiki::rcs_add($tagfile);
IkiWiki::rcs_commit_staged(message => $message);
diff --git a/t/tag.t b/t/tag.t
index 2d0a6e662..9f2a8f3ec 100755
--- a/t/tag.t
+++ b/t/tag.t
@@ -3,7 +3,7 @@ package IkiWiki;
use warnings;
use strict;
-use Test::More tests => 22;
+use Test::More tests => 23;
BEGIN { use_ok("IkiWiki"); }
BEGIN { use_ok("IkiWiki::Render"); }
@@ -22,6 +22,7 @@ $config{wiki_file_chars} = "-[:alnum:]+/.:_";
$config{userdir} = "users";
$config{tagbase} = "tags";
$config{tag_autocreate} = 1;
+$config{tag_autocreate_commit} = 0;
$config{default_pageext} = "mdwn";
$config{wiki_file_prune_regexps} = [qr/^\./];
$config{underlaydirbase} = '.';
@@ -63,9 +64,10 @@ is_deeply([sort keys %autofiles], [qw(tags/lucky.mdwn tags/numbers.mdwn tags/pri
ok(!-e "t/tmp/tags/lucky.mdwn");
my (%pages, @del);
IkiWiki::gen_autofile("tags/lucky.mdwn", \%pages, \@del);
-is_deeply(\%pages, {"t/tmp/tags/lucky" => 1});
-is_deeply(\@del, []);
-ok(-s "t/tmp/tags/lucky.mdwn");
+ok(! -s "t/tmp/tags/lucky.mdwn");
+ok(-s "t/tmp/.ikiwiki/transient/tags/lucky.mdwn");
+is_deeply(\%pages, {"t/tmp/tags/lucky" => 1}) || diag explain \%pages;
+is_deeply(\@del, []) || diag explain \@del;
# generating an autofile that already exists does nothing
%pages = @del = ();