Add discussionpage configuration setting
authorJoey Hess <joey@gnu.kitenet.net>
Fri, 14 Aug 2009 01:41:33 +0000 (21:41 -0400)
committerJoey Hess <joey@gnu.kitenet.net>
Fri, 14 Aug 2009 01:41:33 +0000 (21:41 -0400)
By adding this setting, we get both more configurability, and a minor
optimisation too, since gettext does not need to be called continually
to get the Discussion value.

IkiWiki.pm
IkiWiki/Plugin/brokenlinks.pm
IkiWiki/Plugin/editpage.pm
IkiWiki/Plugin/inline.pm
IkiWiki/Plugin/opendiscussion.pm
IkiWiki/Plugin/orphans.pm
IkiWiki/Render.pm
debian/changelog

index a11b330f2126a038f69678512e1a1ba2f2c238fb..b47da966ed548f03a1ca2c03031fcd8cc084be15 100644 (file)
@@ -220,6 +220,13 @@ sub getsetup () {
                safe => 1,
                rebuild => 1,
        },
+       discussionpage => {
+               type => "string",
+               default => gettext("Discussion"),
+               description => "name of Discussion pages",
+               safe => 1,
+               rebuild => 1,
+       },
        sslcookie => {
                type => "boolean",
                default => 0,
index f8d44892b79f6e0f30612e08d949b2ebf69a35d2..5ad4c917c76b6d57782c998b4895c608ca70abaa 100644 (file)
@@ -28,14 +28,13 @@ sub preprocess (@) {
        add_depends($params{page}, $params{pages});
        
        my %broken;
-       my $discussion=gettext("Discussion");
        foreach my $page (pagespec_match_list([keys %links],
                        $params{pages}, location => $params{page})) {
                my %seen;
                foreach my $link (@{$links{$page}}) {
                        next if $seen{$link};
                        $seen{$link}=1;
-                       next if $link =~ /.*\/\Q$discussion\E/i && $config{discussion};
+                       next if $link =~ /.*\/\Q$config{discussionpage}\E/i && $config{discussion};
                        my $bestlink=bestlink($page, $link);
                        next if length $bestlink;
                        push @{$broken{$link}}, $page;
index 467cd9ed5bf54827da0f75d03304918ba8947a71..fca970c60be3a13199298ddf736c70d14dd2528d 100644 (file)
@@ -229,8 +229,9 @@ sub cgi_editpage ($$) {
                                my $dir=$from."/";
                                $dir=~s![^/]+/+$!!;
                                
-                               if ((defined $form->field('subpage') && length $form->field('subpage')) ||
-                                   $page eq lc(gettext('Discussion'))) {
+                               if ((defined $form->field('subpage') &&
+                                    length $form->field('subpage')) ||
+                                   $page eq lc($config{discussionpage})) {
                                        $best_loc="$from/$page";
                                }
                                else {
index 2fbb45e02674929adfb8443df588afec2ee6116f..704fa711d543947f6bddb2a9f6538bb2798c70b6 100644 (file)
@@ -348,9 +348,6 @@ sub preprocess_inline (@) {
                }
                my $template=HTML::Template->new(@params) unless $raw;
        
-               my $discussionlink=lc(gettext("Discussion"))
-                       if $config{discussion};
-
                foreach my $page (@list) {
                        my $file = $pagesources{$page};
                        my $type = pagetype($file);
@@ -374,14 +371,14 @@ sub preprocess_inline (@) {
                                        my $file = $pagesources{$page};
                                        my $type = pagetype($file);
                                        if ($config{discussion}) {
-                                               if ($page !~ /.*\/\Q$discussionlink\E$/ &&
+                                               if ($page !~ /.*\/\Q$config{discussionpage}\E$/ &&
                                                    (length $config{cgiurl} ||
-                                                    exists $links{$page."/".$discussionlink})) {
+                                                    exists $links{$page."/".$config{discussionpage}})) {
                                                        $template->param(have_actions => 1);
                                                        $template->param(discussionlink =>
                                                                htmllink($page,
                                                                        $params{destpage},
-                                                                       gettext("Discussion"),
+                                                                       $config{discussionpage},
                                                                        noimageinline => 1,
                                                                        forcesubpage => 1));
                                                }
index 60b193eca04fb08702a99077aa911f66dbc33705..1bec4b013a9be6686f08a29b2c1a6658b353c635 100644 (file)
@@ -23,8 +23,7 @@ sub canedit ($$) {
        my $cgi=shift;
        my $session=shift;
 
-       my $discussion=lc(gettext("Discussion"));
-       return "" if $page=~/(\/|^)\Q$discussion\E$/;
+       return "" if $page=~/(\/|^)\Q$config{discussionpage}\E$/;
        return undef;
 }
 
index 7c938ef742da0b6793542151bcfd96465eef877b..02f5d25245f74d83c3415178bfb6f5317b2dea98 100644 (file)
@@ -34,7 +34,6 @@ sub preprocess (@) {
        }
        
        my @orphans;
-       my $discussion=lc(gettext("Discussion"));
        foreach my $page (pagespec_match_list(
                        [ grep { ! $linkedto{$_} && $_ ne 'index' }
                                keys %pagesources ],
@@ -43,7 +42,7 @@ sub preprocess (@) {
                # indirectly linked to a page via that page's backlinks.
                next if grep { 
                        length $_ &&
-                       ($_ !~ /\/\Q$discussion\E$/i || ! $config{discussion}) &&
+                       ($_ !~ /\/\Q$config{discussionpage}\E$/i || ! $config{discussion}) &&
                        bestlink($page, $_) !~ /^(\Q$page\E|)$/ 
                } @{$links{$page}};
                push @orphans, $page;
index fc8f287ced58759d1954f1ef962701bada4f36e1..d5e81f1b9bb5231c1653925072cc13ec8510d069 100644 (file)
@@ -83,11 +83,10 @@ sub genpage ($$) {
                $actions++;
        }
        if ($config{discussion}) {
-               my $discussionlink=lc(gettext("Discussion"));
-               if ($page !~ /.*\/\Q$discussionlink\E$/ &&
+               if ($page !~ /.*\/\Q$config{discussionpage}\E$/ &&
                   (length $config{cgiurl} ||
-                   exists $links{$page."/".$discussionlink})) {
-                       $template->param(discussionlink => htmllink($page, $page, gettext("Discussion"), noimageinline => 1, forcesubpage => 1));
+                   exists $links{$page."/".$config{discussionpage}})) {
+                       $template->param(discussionlink => htmllink($page, $page, $config{discussionpage}, noimageinline => 1, forcesubpage => 1));
                        $actions++;
                }
        }
@@ -153,7 +152,7 @@ sub scan ($) {
                if ($config{discussion}) {
                        # Discussion links are a special case since they're
                        # not in the text of the page, but on its template.
-                       $links{$page}=[ $page."/".lc(gettext("Discussion")) ];
+                       $links{$page}=[ $page."/".lc($config{discussionpage}) ];
                }
                else {
                        $links{$page}=[];
index ed7854e8aa26985818e50715d6a9a1d6a42ccc44..5e51499279a6799d93abca1d270310a3b105a549 100644 (file)
@@ -4,6 +4,8 @@ ikiwiki (3.141593) UNRELEASED; urgency=low
     the old version, but continue. Closes: #541205 
   * inline: Avoid use of my $_ as it fails with older perls.
     Closes: #541215
+  * Add discussionpage configuration setting.
+  * Small optimisations.
 
  -- Joey Hess <joeyh@debian.org>  Wed, 12 Aug 2009 12:25:30 -0400