]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Plugin/tag.pm
* Patch from hb to fix the pagestats plugin, which was broken by a past
[ikiwiki.git] / IkiWiki / Plugin / tag.pm
index ddb67c2a8b5ad52f24c76cd1ff512c27466232e4..48ed1a8f87eb67ae74302484d49942a468a7a7f4 100644 (file)
@@ -4,7 +4,7 @@ package IkiWiki::Plugin::tag;
 
 use warnings;
 use strict;
-use IkiWiki;
+use IkiWiki 2.00;
 
 my %tags;
 
@@ -40,10 +40,11 @@ sub preprocess (@) { #{{{
        my $page = $params{page};
        delete $params{page};
        delete $params{destpage};
+       delete $params{preview};
 
-       $tags{$page} = [];
        foreach my $tag (keys %params) {
-               push @{$tags{$page}}, $tag;
+               $tag=IkiWiki::linkpage($tag);
+               $tags{$page}{$tag}=1;
                # hidden WikiLink
                push @{$links{$page}}, tagpage($tag);
        }
@@ -60,13 +61,14 @@ sub pagetemplate (@) { #{{{
        $template->param(tags => [
                map { 
                        link => htmllink($page, $destpage, tagpage($_))
-               }, @{$tags{$page}}
-       ]) if exists $tags{$page} && @{$tags{$page}} && $template->query(name => "tags");
+               }, sort keys %{$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}}]);
+       if ($template->query(name => "categories")) {
+               # It's an rss/atom template. Add any categories.
+               if (exists $tags{$page} && %{$tags{$page}}) {
+                       $template->param(categories => [map { category => $_ },
+                               sort keys %{$tags{$page}}]);
                }
        }
 } # }}}