main.ssp 6.51 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#import(nl.lumc.sasc.biopet.utils.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] %>
<%@ var rootPath: String %>
#{
    def createMenu(page: ReportPage, path: List[String] = Nil, first: Boolean = true): String = {
        val buffer: StringBuffer = new StringBuffer()

        if (page.subPages.nonEmpty){
15
            buffer.append("<ul class=\"dropdown-menu list-group\">")
16
17
        }

18
        for (subPage <- page.subPages.sortBy(_._1)) {
19

20
21
22
23
24
            val href: String = {
                if (path.isEmpty) rootPath + subPage._1 + "/index.html"
                else rootPath + path.mkString("","/","/") + subPage._1 + "/index.html"
            }

25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//            buffer.append("<li")
//            if(subPage._2.subPages.nonEmpty) buffer.append(" class=\"dropdown-submenu list-group-item\"")
//            buffer.append("><span class=\"badge\">%d</span><a href=\"%s\"".format(subPage._2.subPages.size, href))
//            if (first) buffer.append(" tabindex=\"-1\"")
//            buffer.append(">%s</a>".format(subPage._1))
//            buffer.append(createMenu(subPage._2, path ::: subPage._1 :: Nil, first = false))
//            buffer.append("</li>")

            val listSubmenu = if(subPage._2.subPages.nonEmpty) "dropdown-submenu" else ""
//            val subMenuBadgeCount = if(subPage._2.subPages.nonEmpty && first) "<span class='badge'>%d</span>".format(subPage._2.subPages.size) else ""
            val tabIndex = if (first) " tabindex='-1'" else ""
//            val listGroupA = if(subPage._2.subPages.nonEmpty) "list-group-item" else ""

            var menuItem: String = "<li class='%s'>".format(listSubmenu) +
            "<a href='%s' class='%s'%s>".format(href, "", tabIndex) +
            "%s".format(subPage._1) +
            "</a>" +
            createMenu(subPage._2, path ::: subPage._1 :: Nil, first = false) +
            "</li>"
            buffer.append(menuItem)

46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
        }
        if(page.subPages.nonEmpty) {
            buffer.append("</ul>\n")
        }
        buffer.toString
    }

    def getSubPage(path:List[String]): ReportPage = {
        path.foldLeft(indexPage)((c, p) => {
            val foundPages = c.subPages.filter(_._1 == p)
            require(foundPages.size == 1, "Name of page not found or duplicate is found, page:: " + p + " in path: " + path)
            foundPages.head._2
        })
    }
}#
<!DOCTYPE html>
<html>
    <head>
        <title>${reportName}</title>

        <!-- Bootstrap core JavaScript
        ================================================== -->
        <!-- Placed at the end of the document so the pages load faster -->
        <script src="${rootPath}ext/js/jquery.min.js"></script>

        <!-- Latest compiled and minified CSS -->
        <link rel="stylesheet" href="${rootPath}ext/css/bootstrap.min.css">

        <!-- Optional theme -->
        <link rel="stylesheet" href="${rootPath}ext/css/bootstrap-theme.min.css">

        <!-- Latest compiled and minified JavaScript -->
        <script src="${rootPath}ext/js/bootstrap.min.js"></script>

        <link rel="stylesheet" type="text/css" href="${rootPath}ext/css/bootstrap_dashboard.css">
        <link rel="stylesheet" type="text/css" href="${rootPath}ext/css/sortable-theme-bootstrap.css">

        <!-- sortable tables //-->
        <script src="${rootPath}ext/js/sortable.min.js"></script>
Peter van 't Hof's avatar
Peter van 't Hof committed
85
        <script src="${rootPath}ext/js/d3.v3.5.5.min.js"></script>
86
87
88
89
90
91
        <script language="JavaScript">
            <!--
            $(document).ready(function() {
                Sortable.init()

                $('body').scrollspy({
92
                    target: '.bs-sidebar'
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
                });
            });

            //-->
        </script>
    </head>
<body>

<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
    <div class="navbar-header">
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
        </button>

        <ul class="nav navbar-nav">
            <li class="root #if (path.isEmpty) active #end">
                <a class="navbar-brand" href="${rootPath}index.html">${reportName}
                    #if (indexPage.subPages.nonEmpty) <b class="caret"></b> #end
                </a>
                ${unescape(createMenu(indexPage))}
            </li>
        </ul>
    </div>

    <div class="collapse navbar-collapse navbar-ex1-collapse">
        <ul class="nav navbar-nav">
            <!-- ${path.size} //-->
            <!-- ${path} //-->
            #for (t <- 1 to path.size)
                #if(t == 0)
                    <li class="root">
                        <a href="${rootPath}index.html">Home
                            #if (indexPage.subPages.nonEmpty) <b class="caret"></b> #end
                        </a>
131
                        ${unescape(createMenu(indexPage, Nil, false))}
132
133
134
135
136
137
                    </li>
                #else
                    <li class="root #if (t == path.size) active #end">
                        <a href="${rootPath}${path.slice(0,t).mkString("", "/", "/")}index.html">${path( t - 1 )}
                            #if (getSubPage(path.slice(0, t)).subPages.nonEmpty) <b class="caret"></b> #end
                        </a>
138
                        ${unescape(createMenu(getSubPage(path.slice(0, t)), path.slice(0, t), false))}
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
                    </li>
                #end
            #end

        </ul>
    </div>
    <!--/.nav-collapse -->
</div>
</nav>

<div class="container-fluid">
<div class="row">
    <div id="side-nav" class="col-sm-3 col-md-2 sidebar">
        <ul class="nav nav-sidebar nav-list bs-sidebar">
            #for ((name, url) <- page.sections)
                <li><a href="#${name}">${name}</a></li>
            #end
        </ul>
    </div>
    <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main content">
        #for ((name, section) <- page.sections)
            <div id="${name}" class="panel panel-primary">
                <div class="panel-heading">
                    <h3 class="panel-title" id="panel-title">
                        ${name}
                    </h3>
                </div>
Peter van 't Hof's avatar
Peter van 't Hof committed
166
            ${unescape(section.render(args ++ Map("args" -> args)))}
167
168
169
170
171
172
173
174
            </div>
        #end
    </div>
</div>
</div>

</body>
</html>