X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/a0653933d324f30838fe04d5f9aaab8b130014b2..e16746a52f40f478af1b634c532d90c25cc0ec76:/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