]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/commitdiff
trail: no 'up' page if it's a member of the trail
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Fri, 15 Feb 2013 21:43:50 +0000 (22:43 +0100)
committerJoey Hess <joey@kitenet.net>
Sat, 16 Feb 2013 16:16:18 +0000 (12:16 -0400)
When a trail includes its index page among the members, the pages
before/after it will have â\80\9cdouble linksâ\80\9d 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
templates/page.tmpl
templates/trails.tmpl

index d5fb2b5d624c1b21cf0fa9163b5b223a090e917e..45b53d4b56498f345405150b0a0f3b52675b451a 100644 (file)
@@ -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);
index 89b4f3a06805e65d832a3ab279baf8e7e29675ea..50f244003548bbea08d37cba689a525f8adec3f0 100644 (file)
@@ -31,7 +31,9 @@
 <TMPL_IF PREVPAGE>
 <link rel="prev" href="<TMPL_VAR PREVURL>" title="<TMPL_VAR PREVTITLE>" />
 </TMPL_IF>
+<TMPL_IF TRAILURL>
 <link rel="up" href="<TMPL_VAR TRAILURL>" title="<TMPL_VAR TRAILTITLE>" />
+</TMPL_IF>
 <TMPL_IF NEXTPAGE>
 <link rel="next" href="<TMPL_VAR NEXTURL>" title="<TMPL_VAR NEXTTITLE>" />
 </TMPL_IF>
index 54c04604337727c0bdbbcf11b759af697a816cf7..89d737e99de6875a684d402a4706c6f5f3350697 100644 (file)
@@ -8,9 +8,11 @@
 <span class="trailsep">|</span>
 </span>
 </TMPL_IF>
+<TMPL_IF TRAILURL>
 <span class="trailup">
 <a href="<TMPL_VAR TRAILURL>"><TMPL_VAR TRAILTITLE></a>
 </span>
+</TMPL_IF>
 <TMPL_IF NEXTPAGE>
 <span class="trailnext">
 <span class="trailsep">|</span>