aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/tag.pm
diff options
context:
space:
mode:
authorJoey Hess <joey@kodama.kitenet.net>2008-09-25 20:25:07 -0400
committerJoey Hess <joey@kodama.kitenet.net>2008-09-25 20:25:07 -0400
commitbce2a34c1936f6f361a011502d08d7241cc00518 (patch)
treeac9cf00fd83fdb198a10cb672a94a75107d3ae06 /IkiWiki/Plugin/tag.pm
parent6cea3a0b0328fc13d6446c37e937691e9684802a (diff)
downloadikiwiki-bce2a34c1936f6f361a011502d08d7241cc00518.tar
ikiwiki-bce2a34c1936f6f361a011502d08d7241cc00518.tar.gz
tag: Make edit link for new tags ensure that the tags are created inside tagbase, when it's set.
Diffstat (limited to 'IkiWiki/Plugin/tag.pm')
-rw-r--r--IkiWiki/Plugin/tag.pm25
1 files changed, 18 insertions, 7 deletions
diff --git a/IkiWiki/Plugin/tag.pm b/IkiWiki/Plugin/tag.pm
index 74d187cd2..bf53209fc 100644
--- a/IkiWiki/Plugin/tag.pm
+++ b/IkiWiki/Plugin/tag.pm
@@ -42,7 +42,6 @@ sub tagpage ($) { #{{{
my $tag=shift;
if ($tag !~ m{^\.?/} &&
- exists $config{tagbase} &&
defined $config{tagbase}) {
$tag=$config{tagbase}."/".$tag;
}
@@ -50,6 +49,21 @@ sub tagpage ($) { #{{{
return $tag;
} #}}}
+sub taglink ($$$;@) { #{{{
+ my $page=shift;
+ my $destpage=shift;
+ my $tag=shift;
+ my %opts=@_;
+
+ my $link=tagpage($tag);
+
+ # Force tag creation links to create the tag under /tagbase,
+ # if there is a tagbase and this tag used it.
+ $link="/".$link if $tag ne $link;
+
+ return htmllink($page, $destpage, $link, %opts);
+} #}}}
+
sub preprocess_tag (@) { #{{{
if (! @_) {
return "";
@@ -80,16 +94,14 @@ sub preprocess_taglink (@) { #{{{
my $tag=IkiWiki::linkpage($2);
$tags{$params{page}}{$tag}=1;
push @{$links{$params{page}}}, tagpage($tag);
- return htmllink($params{page}, $params{destpage},
- tagpage($tag),
+ return taglink($params{page}, $params{destpage}, $tag,
linktext => IkiWiki::pagetitle($1));
}
else {
my $tag=IkiWiki::linkpage($_);
$tags{$params{page}}{$tag}=1;
push @{$links{$params{page}}}, tagpage($tag);
- return htmllink($params{page}, $params{destpage},
- tagpage($tag));
+ return taglink($params{page}, $params{destpage}, $tag);
}
}
grep {
@@ -105,8 +117,7 @@ sub pagetemplate (@) { #{{{
$template->param(tags => [
map {
- link => htmllink($page, $destpage, tagpage($_),
- rel => "tag")
+ link => taglink($page, $destpage, $_, rel => "tag")
}, sort keys %{$tags{$page}}
]) if exists $tags{$page} && %{$tags{$page}} && $template->query(name => "tags");