X-Git-Url: https://sipb.mit.edu/gitweb.cgi/ikiwiki.git/blobdiff_plain/a0653933d324f30838fe04d5f9aaab8b130014b2..e4ccc4f3b09aaaa4f64bdba1d6ffff24e924fd20:/IkiWiki/Plugin/tag.pm diff --git a/IkiWiki/Plugin/tag.pm b/IkiWiki/Plugin/tag.pm index 289b48b87..3de09a767 100644 --- a/IkiWiki/Plugin/tag.pm +++ b/IkiWiki/Plugin/tag.pm @@ -23,6 +23,17 @@ sub getopt () { #{{{ GetOptions("tagbase=s" => \$IkiWiki::config{tagbase}); } #}}} +sub tagpage ($) { #{{{ + my $tag=shift; + + if (exists $IkiWiki::config{tagbase} && + defined $IkiWiki::config{tagbase}) { + $tag=$IkiWiki::config{tagbase}."/".$tag; + } + + return $tag; +} #}}} + sub preprocess (@) { #{{{ if (! @_) { return ""; @@ -34,13 +45,9 @@ sub preprocess (@) { #{{{ $tags{$page} = []; foreach my $tag (keys %params) { - if (exists $IkiWiki::config{tagbase} && - defined $IkiWiki::config{tagbase}) { - $tag=$IkiWiki::config{tagbase}."/".$tag; - } push @{$tags{$page}}, $tag; # hidden WikiLink - push @{$IkiWiki::links{$page}}, $tag; + push @{$IkiWiki::links{$page}}, tagpage($tag); } return ""; @@ -53,9 +60,17 @@ sub pagetemplate (@) { #{{{ my $template=$params{template}; $template->param(tags => [ - map { link => IkiWiki::htmllink($page, $destpage, $_) }, - @{$tags{$page}} + map { + link => IkiWiki::htmllink($page, $destpage, tagpage($_)) + }, @{$tags{$page}} ]) if exists $tags{$page} && @{$tags{$page}} && $template->query(name => "tags"); + + if ($template->query(name => "pubdate")) { + # It's an rss template. Add any categories. + if (exists $tags{$page} && @{$tags{$page}}) { + $template->param(categories => [map { category => $_ }, @{$tags{$page}}]); + } + } } # }}} 1