3 package IkiWiki::Plugin::tag;
12 hook(type => "getopt", id => "tag", call => \&getopt);
13 hook(type => "preprocess", id => "tag", call => \&preprocess);
14 hook(type => "pagetemplate", id => "tag", call => \&pagetemplate);
18 eval q{use Getopt::Long};
19 Getopt::Long::Configure('pass_through');
20 GetOptions("tagbase=s" => \$config{tagbase});
23 sub tagpage ($) { #{{{
26 if (exists $config{tagbase} &&
27 defined $config{tagbase}) {
28 $tag=$config{tagbase}."/".$tag;
34 sub preprocess (@) { #{{{
39 my $page = $params{page};
41 delete $params{destpage};
44 foreach my $tag (keys %params) {
45 push @{$tags{$page}}, $tag;
47 push @{$links{$page}}, tagpage($tag);
53 sub pagetemplate (@) { #{{{
55 my $page=$params{page};
56 my $destpage=$params{destpage};
57 my $template=$params{template};
59 $template->param(tags => [
61 link => htmllink($page, $destpage, tagpage($_))
63 ]) if exists $tags{$page} && @{$tags{$page}} && $template->query(name => "tags");
65 if ($template->query(name => "pubdate")) {
66 # It's an rss template. Add any categories.
67 if (exists $tags{$page} && @{$tags{$page}}) {
68 $template->param(categories => [map { category => $_ }, @{$tags{$page}}]);