tag: Make edit link for new tags ensure that the tags are created inside tagbase...
authorJoey Hess <joey@kodama.kitenet.net>
Fri, 26 Sep 2008 00:25:07 +0000 (20:25 -0400)
committerJoey Hess <joey@kodama.kitenet.net>
Fri, 26 Sep 2008 00:25:07 +0000 (20:25 -0400)
IkiWiki/Plugin/tag.pm
debian/changelog

index 74d187cd2d8e132756e9c2f4666b73a0b519510d..bf53209fc18342df934fed8a3b1dd2c9eaf4ae10 100644 (file)
@@ -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");
 
index db80dcf837ca3087ba26f38e2e46aac626be6965..20aef4037c71c67bf618d0785209f7ac14cd378c 100644 (file)
@@ -6,6 +6,8 @@ ikiwiki (2.66) UNRELEASED; urgency=low
   * attachment: Add admin() pagespec to test if the uploading user is a wiki
     admin.
   * git: Fix handling of utf-8 filenames in recentchanges.
+  * tag: Make edit link for new tags ensure that the tags are created
+    inside tagbase, when it's set.
 
  -- Joey Hess <joeyh@debian.org>  Thu, 25 Sep 2008 13:45:55 -0400