3 package IkiWiki::Plugin::tag;
12 IkiWiki::hook(type => "getopt", id => "tag",
14 IkiWiki::hook(type => "preprocess", id => "tag",
15 call => \&preprocess);
16 IkiWiki::hook(type => "pagetemplate", id => "tag",
17 call => \&pagetemplate);
21 eval q{use Getopt::Long};
22 Getopt::Long::Configure('pass_through');
23 GetOptions("tagbase=s" => \$IkiWiki::config{tagbase});
26 sub preprocess (@) { #{{{
31 my $page = $params{page};
33 delete $params{destpage};
36 foreach my $tag (keys %params) {
37 if (exists $IkiWiki::config{tagbase} &&
38 defined $IkiWiki::config{tagbase}) {
39 $tag=$IkiWiki::config{tagbase}."/".$tag;
41 push @{$tags{$page}}, $tag;
43 push @{$IkiWiki::links{$page}}, $tag;
49 sub pagetemplate (@) { #{{{
51 my $page=$params{page};
52 my $destpage=$params{destpage};
53 my $template=$params{template};
55 $template->param(tags => [
56 map { link => IkiWiki::htmllink($page, $destpage, $_) },
58 ]) if exists $tags{$page} && @{$tags{$page}} && $template->query(name => "tags");