Hunt the bug => workaround. Please review.
[ikiwiki] / doc / bugs / po:_plugin_should_not_override_the_title_on_the_homepage.mdwn
1 The po plugin systematically overrides the title of the homepage with the wikiname. This prevents explicitly changing it with a meta directive. It should rather check whether it was overridden before setting it back.
2
3 Here is a simple patch for that:
4
5     diff --git a/Plugin/po.pm b/Plugin/po.pm
6     index 6395ebd..a048c6a 100644
7     --- a/Plugin/po.pm
8     +++ b/Plugin/po.pm
9     @@ -333,7 +333,7 @@ sub pagetemplate (@) {
10                 && $masterpage eq "index") {
11                     $template->param('parentlinks' => []);
12             }
13     -       if (ishomepage($page) && $template->query(name => "title")) {
14     +       if (ishomepage($page) && $template->query(name => "title") && !$template->query(name => "title_overridden")) {
15                     $template->param(title => $config{wikiname});
16             }
17      }
18
19 Thanks.
20
21 > I fixed this patch a bit and applied it to my po branch, thanks
22 > (commit 406485917).
23 >
24 > But... a bug (probably in HTML::Template) prevents this
25 > theoretically correct solution to actually work.
26 > Setting a parameter that does not appear in the template, such as
27 > `title_overridden`, is not working on my install: the value does not
28 > seem to be stored anywhere, and when accessing it later using
29 > `$template->param('title_overridden')` it is always undef.
30 > Adding `<TMPL_IF TMPL_VAR TITLE_OVERRIDDEN></TMPL_IF>` in
31 > `page.tmpl` is a working, but ugly workaround.
32 >
33 > I am nevertheless in favour of merging the fix into ikiwiki.
34 > We'll then need to find how to find the remaining (smaller) bug so
35 > that this code can actually work.
36 >
37 > I'd like others to test my po branch and see if they can reproduce
38 > the bug I am talking of.
39 >
40 > --[[intrigeri]]
41
42 >> Commit 406485917 looks fine to me, FWIW --[[smcv]]
43
44 >>> I tracked the HTML::Template bug (or missing documentation?) a bit
45 >>> more. This lead to commit b2a2246ba in my po branch, that enables
46 >>> HTML::Template's parent_global_vars option which makes
47 >>> title_overridden work.
48 >>>
49 >>> OTOH I feel this workaround is a bit ugly as this option is not
50 >>> documented. IMHO being forced to use it reveals a bug in
51 >>> HTML::Template. I reported this:
52 >>> https://rt.cpan.org/Public/Bug/Display.html?id=64158.
53 >>>
54 >>> But still, I think we need to apply the workaround as
55 >>> HTML::Template's author has not updated any dist on CPAN for more
56 >>> than one year. --[[intrigeri]]