From: Giuseppe Bilotta Date: Fri, 15 Feb 2013 21:43:50 +0000 (+0100) Subject: trail: no 'up' page if it's a member of the trail X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/commitdiff_plain/cca5cb0a5e3071f1ce77688d0b5b9df42135c5b2?hp=e2405005e6253e5040ffd305534f2bfc91d1e940 trail: no 'up' page if it's a member of the trail 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. --- 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 @@ | + + |