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);
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);
eval q{use Getopt::Long};
error($@) if $@;
Getopt::Long::Configure('pass_through');
GetOptions("tagbase=s" => \$config{tagbase});
eval q{use Getopt::Long};
error($@) if $@;
Getopt::Long::Configure('pass_through');
GetOptions("tagbase=s" => \$config{tagbase});
+}
+
+sub taglink ($$$;@) {
+ my $page=shift;
+ my $destpage=shift;
+ my $tag=shift;
+ my %opts=@_;
+
+ return htmllink($page, $destpage, tagpage($tag), %opts);
+}
+
+sub gentag ($) {
+ my $tag=shift;
+ if (defined $config{tag_autocreate} && $config{tag_autocreate}) {
+ my $tagfile = newpagefile(tagpage($tag), $config{default_pageext});
+ $tagfile=~s/^\///;
+
+ return if (! add_autofile($tagfile));
-sub preprocess_tag (@) { #{{{
+ debug(sprintf(gettext("creating tag page %s"), $tag));
+
+ my $template=template("autotag.tmpl");
+ $template->param(tag => $tag);
+ writefile($tagfile, $config{srcdir}, $template->output);
+ }
+}
+
+sub preprocess_tag (@) {
- return htmllink($params{page}, $params{destpage},
- tagpage($tag),
- linktext => IkiWiki::pagetitle($1));
+ add_link($params{page}, tagpage($tag));
+ return taglink($params{page}, $params{destpage}, $tag,
+ linktext => pagetitle($1));
- return htmllink($params{page}, $params{destpage},
- tagpage($tag));
+ add_link($params{page}, tagpage($tag));
+ return taglink($params{page}, $params{destpage}, $tag);
- link => htmllink($page, $destpage, tagpage($_),
- rel => "tag")
+ link => taglink($page, $destpage, $_, rel => "tag")
}, sort keys %{$tags{$page}}
]) if exists $tags{$page} && %{$tags{$page}} && $template->query(name => "tags");
}, sort keys %{$tags{$page}}
]) if exists $tags{$page} && %{$tags{$page}} && $template->query(name => "tags");