]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Plugin/tag.pm
fixes
[ikiwiki.git] / IkiWiki / Plugin / tag.pm
index 56bf17e2c1042ae367c1cd9afa63012ff33723ab..3de09a7672641ec471eb147038fd6a9672a3e0e3 100644 (file)
@@ -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,12 +45,9 @@ sub preprocess (@) { #{{{
 
        $tags{$page} = [];
        foreach my $tag (keys %params) {
-               if (exists $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 "";
@@ -52,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