From cca5cb0a5e3071f1ce77688d0b5b9df42135c5b2 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Fri, 15 Feb 2013 22:43:50 +0100 Subject: [PATCH] trail: no 'up' page if it's a member of the trail MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit When a trail includes its index page among the members, the pages before/after it will have “double links” to the index page (both as next/prev and as 'up') and the index page will include an 'up' link to itself. Prevent this by not defining the appropriate template variables when the index page is member of the trail itself. The default page template is also adapted to skip the link at all in this case. --- IkiWiki/Plugin/trail.pm | 17 +++++++++++++---- templates/page.tmpl | 2 ++ templates/trails.tmpl | 2 ++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/IkiWiki/Plugin/trail.pm b/IkiWiki/Plugin/trail.pm index d5fb2b5d6..45b53d4b5 100644 --- a/IkiWiki/Plugin/trail.pm +++ b/IkiWiki/Plugin/trail.pm @@ -447,17 +447,26 @@ sub pagetemplate (@) { $nexttitle = title_of($next); } - push @trails, { + my %trail_info = ( prevpage => $prev, prevtitle => $prevtitle, prevurl => $prevurl, nextpage => $next, nexttitle => $nexttitle, nexturl => $nexturl, - trailpage => $trail, - trailtitle => title_of($trail), - trailurl => urlto($trail, $page), + ); + + # the trail index is added as 'up' page, but only if it's + # not a page in the trail itself. This allows the definition of + # up-less trails by using e.g. the trailitems directive in one of the + # pages of the trail + unless ($trail ~~ @$members) { + $trail_info{trailpage} = $trail; + $trail_info{trailtitle} = title_of($trail); + $trail_info{trailurl} = urlto($trail, $page); }; + + push @trails, \%trail_info; } $template->param(trailloop => \@trails); diff --git a/templates/page.tmpl b/templates/page.tmpl index 89b4f3a06..50f244003 100644 --- a/templates/page.tmpl +++ b/templates/page.tmpl @@ -31,7 +31,9 @@ + + diff --git a/templates/trails.tmpl b/templates/trails.tmpl index 54c046043..89d737e99 100644 --- a/templates/trails.tmpl +++ b/templates/trails.tmpl @@ -8,9 +8,11 @@ | + + | -- 2.39.2