1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 # Introduces templates that compose the documentation HTML rendering.
20 # Renders the page as HTML.
25 var html_url
: String is writable, noinit
27 # Directory where css, js and other assets can be found.
28 var shareurl
: String is writable, noinit
30 # Attributes of the body tag element.
31 var body_attrs
= new Array[TagAttribute]
33 # Top menu template if any.
34 var topmenu
: TplTopMenu is writable, noinit
36 # Sidebar template if any.
37 var sidebar
: nullable TplSidebar = null is writable
39 # Content of the page in form a TplSection.
40 # TODO remove when other templates are migrated.
41 var sections
= new Array[TplSection]
43 # Footer content if any.
44 var footer
: nullable Writable = null is writable
46 # JS scripts to append at the end of the body
47 var scripts
= new Array[TplScript]
49 # Adds a section to this page.
50 # TODO remove when other templates are migrated.
51 fun add_section
(section
: TplSection) do
55 # Renders the html `<head>`.
56 private fun render_head
do
57 var css
= (self.shareurl
/ "css").html_escape
58 var vendors
= (self.shareurl
/ "vendors").html_escape
60 addn
"<!DOCTYPE html>"
62 addn
" <meta charset='utf-8'/>"
63 addn
" <!--link rel='stylesheet' href='{css}/Nitdoc.UI.css' type='text/css'/-->"
64 addn
" <link rel='stylesheet' href='{vendors}/bootstrap/css/bootstrap.min.css'/>"
65 addn
" <link rel='stylesheet' href='{css}/nitdoc.bootstrap.css'/>"
66 addn
" <link rel='stylesheet' href='{css}/nitdoc.css'/>"
67 addn
" <link rel='stylesheet' href='{css}/Nitdoc.QuickSearch.css'/>"
68 addn
" <link rel='stylesheet' href='{css}/Nitdoc.ModalBox.css'/>"
69 addn
" <link rel='stylesheet' href='{css}/Nitdoc.GitHub.css'/>"
70 addn
" <title>{title.html_escape}</title>"
73 for attr
in body_attrs
do add attr
77 # Renders the topmenu template.
78 private fun render_topmenu
do
79 addn
" <div class='row'>"
84 # Renders the sidebar template.
86 # Sidebar is automatically populated with a summary of all sections
87 # TODO remove summary generation when other templates are migrated.
88 private fun render_sidebar
do
89 if sidebar
== null then return
90 var summary
= new TplSummary.with_order
(0)
91 for section
in sections
do
92 section
.render_summary summary
94 sidebar
.boxes
.add summary
95 add sidebar
.as(not null)
98 # Renders the footer and content.
99 private fun render_content
do
100 for section
in sections
do add section
101 if footer
!= null then
102 addn
"<div class='well footer'>"
103 add footer
.as(not null)
109 private fun render_footer
do
110 var vendors
= (self.shareurl
/ "vendors").html_escape
111 var js
= (self.shareurl
/ "js").html_escape
113 addn
"<script src='{vendors}/jquery/jquery-1.11.1.min.js'></script>"
114 addn
"<script src='{vendors}/jquery/jquery-ui-1.10.4.custom.min.js'></script>"
115 addn
"<script src='{vendors}/bootstrap/js/bootstrap.min.js'></script>"
116 addn
"<script data-main='{js}/nitdoc' src='{js}/lib/require.js'></script>"
117 for script
in scripts
do add script
120 $("[data-toggle='tooltip']").tooltip();
121 $("[data-toggle='popover']").popover();
128 # Render the whole page
129 redef fun rendering
do
131 addn
"<div class='container-fluid'>"
133 addn
" <div class='row' id='content'>"
134 if sidebar
!= null then
135 addn
"<div class='col col-xs-3 col-lg-2'>"
138 addn
"<div class='col col-xs-9 col-lg-10' data-spy='scroll' data-target='.summary'>"
142 addn
"<div class='col col-xs-12'>"