Skip to content

Commit 2dd9612

Browse files
committed
Merge: nitiwiki: fix multiple trails
Fix a bug where independent trails could have been merged into a big one. Pull-Request: #1854 Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
2 parents 9519a29 + f574c45 commit 2dd9612

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
first page
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# A independant trail
2+
3+
a [[trail: first]] and a [[trail: second]] page.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
a second page

contrib/nitiwiki/src/wiki_html.nit

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -313,17 +313,21 @@ redef class WikiArticle
313313

314314
var res = new Template
315315
res.add "<ul class=\"trail\">"
316-
if pos > 0 then
317-
var target = flat[pos-1]
318-
res.add "<li>{target.a_from(self, "prev")}</li>"
319-
end
320316
var parent = wiki.trails.parent(self)
317+
# Up and prev are disabled on a root
321318
if parent != null then
319+
if pos > 0 then
320+
var target = flat[pos-1]
321+
res.add "<li>{target.a_from(self, "prev")}</li>"
322+
end
322323
res.add "<li>{parent.a_from(self, "up")}</li>"
323324
end
324325
if pos < flat.length - 1 then
325326
var target = flat[pos+1]
326-
res.add "<li>{target.a_from(self, "next")}</li>"
327+
# Only print the next if it is not a root
328+
if target.parent != null then
329+
res.add "<li>{target.a_from(self, "next")}</li>"
330+
end
327331
end
328332
res.add "</ul>"
329333

0 commit comments

Comments
 (0)