X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/21add7ffa87a5e622d18bdbb24c638c15bdb3800..b5e7f7a67f9893c7083afe3594c4a274c1b96062:/IkiWiki/Plugin/tag.pm diff --git a/IkiWiki/Plugin/tag.pm b/IkiWiki/Plugin/tag.pm index ecc77cbb1..7a85874f6 100644 --- a/IkiWiki/Plugin/tag.pm +++ b/IkiWiki/Plugin/tag.pm @@ -4,9 +4,7 @@ package IkiWiki::Plugin::tag; use warnings; use strict; -use IkiWiki 2.00; - -my %tags; +use IkiWiki 3.00; sub import { hook(type => "getopt", id => "tag", call => \&getopt); @@ -71,9 +69,8 @@ sub preprocess_tag (@) { foreach my $tag (keys %params) { $tag=linkpage($tag); - $tags{$page}{$tag}=1; # hidden WikiLink - push @{$links{$page}}, tagpage($tag); + add_link($page, tagpage($tag), 'tag'); } return ""; @@ -87,15 +84,13 @@ sub preprocess_taglink (@) { return join(" ", map { if (/(.*)\|(.*)/) { my $tag=linkpage($2); - $tags{$params{page}}{$tag}=1; - push @{$links{$params{page}}}, tagpage($tag); + add_link($params{page}, tagpage($tag), 'tag'); return taglink($params{page}, $params{destpage}, $tag, linktext => pagetitle($1)); } else { my $tag=linkpage($_); - $tags{$params{page}}{$tag}=1; - push @{$links{$params{page}}}, tagpage($tag); + add_link($params{page}, tagpage($tag), 'tag'); return taglink($params{page}, $params{destpage}, $tag); } } @@ -110,19 +105,27 @@ sub pagetemplate (@) { my $destpage=$params{destpage}; my $template=$params{template}; + my $tags = $typedlinks{$page}{tag}; + $template->param(tags => [ map { link => taglink($page, $destpage, $_, rel => "tag") - }, sort keys %{$tags{$page}} - ]) if exists $tags{$page} && %{$tags{$page}} && $template->query(name => "tags"); + }, sort keys %$tags + ]) if defined $tags && %$tags && $template->query(name => "tags"); if ($template->query(name => "categories")) { # It's an rss/atom template. Add any categories. - if (exists $tags{$page} && %{$tags{$page}}) { + if (defined $tags && %$tags) { $template->param(categories => [map { category => $_ }, - sort keys %{$tags{$page}}]); + sort keys %$tags]); } } } +package IkiWiki::PageSpec; + +sub match_tagged ($$;@) { + return match_link($_[0], IkiWiki::Plugin::tag::tagpage($_[1]), linktype => 'tag'); +} + 1