]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Plugin/tag.pm
web commit by http://natalian.org/
[ikiwiki.git] / IkiWiki / Plugin / tag.pm
index 29d1d030a2e328088feb1244d98e934b226dc227..bae8e14327d5e2761e01a8aeddd33566e0741c04 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);
        }
@@ -59,14 +60,16 @@ sub pagetemplate (@) { #{{{
 
        $template->param(tags => [
                map { 
-                       link => htmllink($page, $destpage, tagpage($_))
-               }, @{$tags{$page}}
-       ]) if exists $tags{$page} && @{$tags{$page}} && $template->query(name => "tags");
+                       link => htmllink($page, $destpage, tagpage($_),
+                                       rel => "tag")
+               }, sort keys %{$tags{$page}}
+       ]) if exists $tags{$page} && %{$tags{$page}} && $template->query(name => "tags");
 
        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 => $_ }, @{$tags{$page}}]);
+               if (exists $tags{$page} && %{$tags{$page}}) {
+                       $template->param(categories => [map { category => $_ },
+                               sort keys %{$tags{$page}}]);
                }
        }
 } # }}}