po plugin: remove broken parentlinks for home page's translations
authorintrigeri <intrigeri@boum.org>
Tue, 4 Nov 2008 19:05:21 +0000 (20:05 +0100)
committerintrigeri <intrigeri@boum.org>
Tue, 4 Nov 2008 19:05:21 +0000 (20:05 +0100)
Signed-off-by: intrigeri <intrigeri@boum.org>
IkiWiki/Plugin/po.pm
doc/plugins/po.mdwn

index cc8e9b2edd73d0a2ce4f57594d9909ccd1892cac..a5bf4fb5497d13a5121e5efd8fa1678349150dba 100644 (file)
@@ -38,7 +38,7 @@ sub import {
        hook(type => "needsbuild", id => "po", call => \&needsbuild);
        hook(type => "filter", id => "po", call => \&filter);
        hook(type => "htmlize", id => "po", call => \&htmlize);
        hook(type => "needsbuild", id => "po", call => \&needsbuild);
        hook(type => "filter", id => "po", call => \&filter);
        hook(type => "htmlize", id => "po", call => \&htmlize);
-       hook(type => "pagetemplate", id => "po", call => \&pagetemplate);
+       hook(type => "pagetemplate", id => "po", call => \&pagetemplate, last => 1);
        hook(type => "editcontent", id => "po", call => \&editcontent);
        inject(name => "IkiWiki::bestlink", call => \&mybestlink);
        inject(name => "IkiWiki::beautify_urlpath", call => \&mybeautify_urlpath);
        hook(type => "editcontent", id => "po", call => \&editcontent);
        inject(name => "IkiWiki::bestlink", call => \&mybestlink);
        inject(name => "IkiWiki::beautify_urlpath", call => \&mybeautify_urlpath);
@@ -398,9 +398,10 @@ sub otherlanguages ($) { #{{{
 
 sub pagetemplate (@) { #{{{
        my %params=@_;
 
 sub pagetemplate (@) { #{{{
        my %params=@_;
-        my $page=$params{page};
-        my $destpage=$params{destpage};
-        my $template=$params{template};
+       my $page=$params{page};
+       my $destpage=$params{destpage};
+       my $template=$params{template};
+       my ($masterpage, $lang) = ($page =~ /(.*)[.]([a-z]{2})$/) if istranslation($page);
 
        if (istranslation($page) && $template->query(name => "percenttranslated")) {
                $template->param(percenttranslated => percenttranslated($page));
 
        if (istranslation($page) && $template->query(name => "percenttranslated")) {
                $template->param(percenttranslated => percenttranslated($page));
@@ -419,7 +420,6 @@ sub pagetemplate (@) { #{{{
                        }
                }
                elsif (istranslation($page)) {
                        }
                }
                elsif (istranslation($page)) {
-                       my ($masterpage, $curlang) = ($page =~ /(.*)[.]([a-z]{2})$/);
                        add_depends($page, $masterpage);
                        foreach my $translation (values %{$translations{$masterpage}}) {
                                add_depends($page, $translation);
                        add_depends($page, $masterpage);
                        foreach my $translation (values %{$translations{$masterpage}}) {
                                add_depends($page, $translation);
@@ -434,7 +434,6 @@ sub pagetemplate (@) { #{{{
        # prevent future breakage when ikiwiki internals change.
        # Known limitations are preferred to future random bugs.
        if ($template->param('discussionlink') && istranslation($page)) {
        # 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,
                $template->param('discussionlink' => htmllink(
                                                        $page,
                                                        $destpage,
@@ -444,6 +443,12 @@ sub pagetemplate (@) { #{{{
                                                        linktext => gettext("Discussion"),
                                                        ));
        }
                                                        linktext => gettext("Discussion"),
                                                        ));
        }
+       # remove broken parentlink to ./index.html on home page's translations
+       if ($template->param('parentlinks')
+           && istranslation($page)
+           && $masterpage eq "index") {
+               $template->param('parentlinks' => []);
+       }
 } # }}}
 
 sub editcontent () { #{{{
 } # }}}
 
 sub editcontent () { #{{{
index 6aa63b429b1af2d8975424e3d10559e53a210fc1..61ed9e107378abc479852644aa114580d3855bbf 100644 (file)
@@ -259,13 +259,6 @@ be fixed by something like [[todo/using_meta_titles_for_parentlinks]].
 
 Which configuration settings are safe enough for websetup?
 
 
 Which configuration settings are safe enough for websetup?
 
-### parentlinks
-
-When the wiki home page is translatable, the parentlinks plugin sets
-`./index.html` as its translations' single parent link. Ideally, the
-home page's translations should get no parent link at all, just like
-the version written in the master language.
-
 ### backlinks
 
 If a given translatable `sourcepage.mdwn` links to \[[destpage]],
 ### backlinks
 
 If a given translatable `sourcepage.mdwn` links to \[[destpage]],