]> sipb.mit.edu Git - ikiwiki.git/commitdiff
po plugin: slave pages link to the master's discussion page
authorintrigeri <intrigeri@boum.org>
Sun, 2 Nov 2008 23:52:27 +0000 (00:52 +0100)
committerintrigeri <intrigeri@boum.org>
Sun, 2 Nov 2008 23:52:27 +0000 (00:52 +0100)
Signed-off-by: intrigeri <intrigeri@boum.org>
IkiWiki/Plugin/po.pm
doc/plugins/po.mdwn

index 155af706f78eba5e076689d0e4fa32d5b0171f37..9dda8c0db29d8116acb7e4417276865bbe462897 100644 (file)
@@ -391,6 +391,7 @@ sub otherlanguages ($) { #{{{
 sub pagetemplate (@) { #{{{
        my %params=@_;
         my $page=$params{page};
 sub pagetemplate (@) { #{{{
        my %params=@_;
         my $page=$params{page};
+        my $destpage=$params{destpage};
         my $template=$params{template};
 
        if (istranslation($page) && $template->query(name => "percenttranslated")) {
         my $template=$params{template};
 
        if (istranslation($page) && $template->query(name => "percenttranslated")) {
@@ -417,6 +418,24 @@ sub pagetemplate (@) { #{{{
                        }
                }
        }
                        }
                }
        }
+       # Rely on IkiWiki::Render's genpage() to decide wether
+       # a discussion link should appear on $page; this is not
+       # totally accurate, though: some broken links may be generated
+       # when cgiurl is disabled.
+       # This compromise avoids some code duplication, and will probably
+       # prevent future breakage when ikiwiki internals change.
+       # Known limitations are preferred to future random bugs.
+       if ($template->param('discussionlink') && istranslation($page)) {
+               my ($masterpage, $lang) = ($page =~ /(.*)[.]([a-z]{2})$/);
+               $template->param('discussionlink' => htmllink(
+                                                       $page,
+                                                       $destpage,
+                                                       $masterpage . '/' . gettext("Discussion"),
+                                                       noimageinline => 1,
+                                                       forcesubpage => 0,
+                                                       linktext => gettext("Discussion"),
+                                                       ));
+       }
 } # }}}
 
 sub istranslatable ($) { #{{{
 } # }}}
 
 sub istranslatable ($) { #{{{
index 1a9144aee2ed4124a1353976c8e988b4718918a7..1b240de1ab84407a9746d04936890fef9c00b5c1 100644 (file)
@@ -196,6 +196,13 @@ Also, when the plugin has just been enabled, or when a page has just
 been declared as being translatable, the needed POT and PO files are
 created, and the PO files are checked into version control.
 
 been declared as being translatable, the needed POT and PO files are
 created, and the PO files are checked into version control.
 
+Discussion pages
+----------------
+
+Discussion should happen in the language in which the pages are written for
+real, *i.e.* the "master" one. If discussion pages are enabled, "slave" pages
+therefore link to the "master" page's discussion page.
+
 TODO
 ====
 
 TODO
 ====
 
@@ -248,12 +255,6 @@ Use nice page titles from meta plugin in links, as inline already does.
 
 Which configuration settings are safe enough for websetup?
 
 
 Which configuration settings are safe enough for websetup?
 
-### Discussion pages
-
-Decide something, probably that "slave" pages, being only translations, don't
-deserve a discussion page: the discussion should happen in the language in which
-the pages are written for real, which is the "master" one.
-
 ### parentlinks
 
 When the wiki home page is translatable, the parentlinks plugin sets
 ### parentlinks
 
 When the wiki home page is translatable, the parentlinks plugin sets