main.ssp 2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
#import(nl.lumc.sasc.biopet.core.summary.Summary)
#import(nl.lumc.sasc.biopet.core.report.ReportPage)
<%@ var summary: Summary %>
<%@ var indexPage: ReportPage %>
<%@ var reportName: String %>
<%@ var page: ReportPage %>
<%@ var path: List[String] %>
<%@ var args: Map[String, Any] %>
#{
    val rootPath = "./" + Array.fill(path.size)("../").mkString("")

    def createMenu(page: ReportPage, path: List[String] = Nil): String = {
        val buffer: StringBuffer = new StringBuffer()
        buffer.append("<ul>")

        for (subPage <- page.subPages) {
            val href: String = {
                if (path.isEmpty) rootPath + subPage._1 + "/index.html"
                else rootPath + path.mkString("","/","/") + subPage._1 + "/index.html"
            }

            buffer.append("<li><a href=\"" + href + "\">" + subPage._1 + "</a>")
            buffer.append(createMenu(subPage._2, path ::: subPage._1 :: Nil))
            buffer.append("</li>")
        }

        buffer.append("</ul>")
        buffer.toString
    }

    def getSubPage(path:List[String]): ReportPage = {
        path.foldLeft(indexPage)(_.subPages(_))
    }
}#
<!DOCTYPE html>
<html>
    <head>
        <link rel="stylesheet" type="text/css" href="${rootPath}css/biopet.css">
    </head>
<body>

<header><h1>${reportName}</h1></header>
Peter van 't Hof's avatar
Peter van 't Hof committed
43
<nav id="menu">
44 45 46 47 48 49 50 51 52 53 54 55 56 57
<ul>
#for (t <- 0 to path.size)
    <li>
    #if (t == 0)
        <a href="${rootPath}index.html">Home</a>
        ${unescape(createMenu(indexPage))}
    #else
        <a href="${rootPath}${path.slice(0, t).mkString("","/","/")}index.html">${path(t - 1)}</a>
        ${unescape(createMenu(getSubPage(path.slice(0, t)), path.slice(0, t)))}
    #end
    </li>
#end
</ul>
</nav>
Peter van 't Hof's avatar
Peter van 't Hof committed
58
<aside id="index">
Peter van 't Hof's avatar
Peter van 't Hof committed
59 60 61 62 63 64
<ul>
#for ((name, url) <- page.sections)
    <li><a href="#${name}">${name}</a></li>
#end
</ul>
</aside>
Peter van 't Hof's avatar
Peter van 't Hof committed
65
<aside id="main">
66
#for ((name, url) <- page.sections)
Peter van 't Hof's avatar
Peter van 't Hof committed
67 68 69 70
    <section id="${name}">
        <h3>${name}</h3>
        ${unescape(url.render(args))}
    </section>
71
#end
Peter van 't Hof's avatar
Peter van 't Hof committed
72
</aside>
73 74 75 76

<footer>Footer</footer>
</body>
</html>