Handle the nesting properly

This commit is contained in:
Las Zenow 2012-08-28 12:24:11 +02:00
parent de721f5ff3
commit 9a3e50b193
2 changed files with 11 additions and 11 deletions

View file

@ -73,7 +73,7 @@ func cleanLink(link string) string {
/* return next and prev urls from document and the list of chapters */ /* return next and prev urls from document and the list of chapters */
func chapterList(e *epub.Epub, file string, id string, base string) (string, string, []chapter) { func chapterList(e *epub.Epub, file string, id string, base string) (string, string, []chapter) {
chapters := make([]chapter, 0) var chapters []chapter
prev := "" prev := ""
next := "" next := ""
tit := e.Titerator(epub.TITERATOR_NAVMAP) tit := e.Titerator(epub.TITERATOR_NAVMAP)
@ -90,13 +90,13 @@ func chapterList(e *epub.Epub, file string, id string, base string) (string, str
activeIndx = len(chapters) activeIndx = len(chapters)
} }
c.Depth = tit.Depth() c.Depth = tit.Depth()
if c.Depth > depth { for c.Depth > depth {
c.In = true c.In = append(c.In, true)
depth = c.Depth depth++
} }
if c.Depth < depth { for c.Depth < depth {
c.Out = true c.Out = append(c.Out, true)
depth = c.Depth depth--
} }
chapters = append(chapters, c) chapters = append(chapters, c)
} }

View file

@ -19,13 +19,13 @@
<div class="row"> <div class="row">
<div class="span4"> <div class="span4">
{{range .Chapters}} {{range .Chapters}}
{{if .In}} {{range .Out}}
</ul>
{{end}}
{{range .In}}
<ul class="nav nav-list"> <ul class="nav nav-list">
{{end}} {{end}}
<li {{if .Active}}class="active"{{end}}><a href="{{.Link}}">{{.Label}}</a></li> <li {{if .Active}}class="active"{{end}}><a href="{{.Link}}">{{.Label}}</a></li>
{{if .Out}}
</ul>
{{end}}
{{end}} {{end}}
{{if .Chapters}} {{if .Chapters}}
</ul> </ul>