46e008dbfcef6ecaa3eb78618678b1d905b60304
[project/luci.git] / themes / luci-theme-material / luasrc / view / themes / material / header.htm
1 <%#
2 Material is a clean HTML5 theme for LuCI. It is based on luci-theme-bootstrap and MUI
3
4 luci-theme-material
5 Copyright 2015 Lutty Yang <lutty@wcan.in>
6
7 Have a bug? Please create an issue here on GitHub!
8 https://github.com/LuttyYang/luci-theme-material/issues
9
10 luci-theme-bootstrap:
11 Copyright 2008 Steven Barth <steven@midlink.org>
12 Copyright 2008 Jo-Philipp Wich <jow@openwrt.org>
13 Copyright 2012 David Menting <david@nut-bolt.nl>
14
15 MUI:
16 https://github.com/muicss/mui
17
18 Licensed to the public under the Apache License 2.0
19 -%>
20
21 <%
22 local ver = require "luci.version"
23 local sys = require "luci.sys"
24 local util = require "luci.util"
25 local http = require "luci.http"
26 local disp = require "luci.dispatcher"
27
28 local boardinfo = util.ubus("system", "board")
29
30 local request = disp.context.path
31 local request2 = disp.context.request
32
33 local category = request[1]
34 local cattree = category and disp.node(category)
35
36 local leaf = request2[#request2]
37
38 local tree = disp.node()
39 local node = disp.context.dispatched
40
41 local categories = disp.node_childs(tree)
42
43 local c = tree
44 local i, r
45
46 -- tag all nodes leading to this page
47 for i, r in ipairs(request) do
48 if c.nodes and c.nodes[r] then
49 c = c.nodes[r]
50 c._menu_selected = true
51 end
52 end
53
54 -- send as HTML5
55 http.prepare_content("text/html")
56
57 local function nodeurl(prefix, name, query)
58 local url = controller .. prefix .. name .. "/"
59 if query then
60 url = url .. http.build_querystring(query)
61 end
62 return pcdata(url)
63 end
64
65 local function subtree(prefix, node, level)
66 if not level then
67 level = 1
68 end
69
70 local childs = disp.node_childs(node)
71 if #childs > 0 then
72
73 if level > 2 then
74 %>
75 <ul class="tabs">
76 <%
77 end
78
79 local selected_node
80 local selected_name
81 local i, v
82
83 for i, v in ipairs(childs) do
84 local nnode = node.nodes[v]
85 if nnode._menu_selected then
86 selected_node = nnode
87 selected_name = v
88 end
89 if level > 2 then
90 %>
91 <li class="tabmenu-item-<%=v%><%- if nnode._menu_selected or (node.leaf and v == leaf) then %> active<% end %>">
92 <a href="<%=nodeurl(prefix, v, nnode.query)%>"><%=striptags(translate(nnode.title))%></a>
93 </li>
94 <% end
95 end
96
97 if level > 2 then
98 %>
99 </ul>
100 <% end
101
102 if selected_node then
103 subtree(prefix .. selected_name .. "/", selected_node, level + 1)
104 end
105 end
106 end
107 -%>
108 <!DOCTYPE html>
109 <html lang="<%=luci.i18n.context.lang%>">
110 <head>
111 <meta charset="utf-8">
112 <title><%=striptags( (boardinfo.hostname or "?") .. ( (node and node.title) and ' - ' .. translate(node.title) or '')) %> - LuCI</title>
113 <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
114 <meta name="format-detection" content="telephone=no, email=no"/>
115 <meta name="apple-mobile-web-app-capable" content="yes">
116 <meta name="mobile-web-app-capable" content="yes">
117 <meta name="x5-fullscreen" content="true">
118 <meta name="full-screen" content="yes">
119 <meta name="x5-page-mode" content="app">
120 <meta name="browsermode" content="application">
121 <meta name="theme-color" content="#0099CC">
122 <meta name="msapplication-tap-highlight" content="no">
123 <meta name="msapplication-TileColor" content="#0099CC">
124 <meta name="msapplication-TileImage" content="<%=media%>/logo.png"/>
125 <link rel="stylesheet" href="<%=media%>/css/style.css">
126 <link rel="shortcut icon" href="<%=media%>/favicon.ico">
127 <% if node and node.css then %>
128 <link rel="stylesheet" href="<%=resource%>/<%=node.css%>">
129 <% end -%>
130 <% if css then %>
131 <style title="text/css">
132 <%-= css %>
133 </style>
134 <% end -%>
135 <script src="<%=resource%>/xhr.js"></script>
136 </head>
137
138 <body class="lang_<%=luci.i18n.context.lang%> <%- if node then %><%= striptags( node.title ) %><%- end %> <% if luci.dispatcher.context.authsession then %>logged-in<% end %>">
139
140 <header>
141 <div class="container">
142 <span class="showSide"></span>
143 <a class="brand" href="#"><%=boardinfo.hostname or "?"%></a>
144 <div class="pull-right">
145 <%
146 -- calculate the number of unsaved changes
147 if tree.nodes[category] and tree.nodes[category].ucidata then
148 local ucichanges = 0
149 for i, j in pairs(require("luci.model.uci").cursor():changes()) do
150 for k, l in pairs(j) do
151 for m, n in pairs(l) do
152 ucichanges = ucichanges + 1;
153 end
154 end
155 end
156 %>
157 <% if ucichanges > 0 then %>
158 <a class="label notice" href="<%=controller%>/<%=category%>/uci/changes?redir=<%=http.urlencode(http.formvalue("redir") or REQUEST_URI)%>"><span class="mobile-hide"><%:Unsaved Changes%>: </span><%=ucichanges%></a>
159 <% end %>
160 <span id="xhr_poll_status" style="display:none" onclick="XHR.running() ? XHR.halt() : XHR.run()">
161 <span class="label success" id="xhr_poll_status_on"><span class="mobile-hide"><%:Auto Refresh%> </span><%:on%></span>
162 <span class="label" id="xhr_poll_status_off" style="display:none"><span class="mobile-hide"><%:Auto Refresh%> </span><%:off%></span>
163 </span>
164 <% end %>
165 </div>
166 </div>
167 </header>
168
169 <div class="main">
170 <div style="" class="loading"><span><div class="loading-img"></div>Loading...</span></div>
171 <div class="main-left">
172 <ul class="nav">
173 <%-
174 local function submenu(prefix, node)
175 local childs = disp.node_childs(node)
176 if #childs > 0 then
177 %>
178 <ul class="slide-menu">
179 <%-
180 for i, r in ipairs(childs) do
181 local nnode = node.nodes[r]
182 local href = controller .. prefix .. r ..
183 (nnode.query and http.build_querystring(nnode.query) or "")
184 %>
185 <li><a data-title="<%=pcdata(striptags(nnode.title))%>" href="<%=pcdata(href)%>"><%=pcdata(striptags(translate(nnode.title)))%></a></li>
186 <%-
187 end
188 %>
189 </ul>
190 <%-
191 end
192 end
193
194 childs = disp.node_childs(cattree)
195
196 if #childs > 0 then
197 for i, r in ipairs(childs) do
198 local nnode = cattree.nodes[r]
199 local href = controller .. "/" .. category .. "/" .. r ..
200 (nnode.query and http.build_querystring(k.query) or "")
201 local grandchildren = disp.node_childs(nnode)
202
203 if #grandchildren > 0 then
204 %>
205 <li class="slide">
206 <a class="menu" data-title="<%=pcdata(striptags(nnode.title))%>" href="#"><%=pcdata(striptags(translate(nnode.title)))%></a>
207 <%- submenu("/" .. category .. "/" .. r .. "/", nnode) %>
208 </li>
209 <% else %>
210 <li>
211 <a data-title="<%=pcdata(striptags(nnode.title))%>" href="<%=pcdata(href)%>"><%=pcdata(striptags(translate(nnode.title)))%></a>
212 </li>
213 <%
214 end
215 end
216 end
217 %>
218 </ul>
219 </div>
220 <div class="main-right">
221 <div class="darkMask"></div>
222 <div id="maincontent">
223 <div class="container">
224 <%- if luci.sys.process.info("uid") == 0 and luci.sys.user.getuser("root") and not luci.sys.user.getpasswd("root") then -%>
225 <div class="alert-message warning">
226 <h4><%:No password set!%></h4>
227 <%:There is no password set on this router. Please configure a root password to protect the web interface and enable SSH.%><br>
228 <a href="<%=pcdata(luci.dispatcher.build_url("admin/system/admin"))%>"><%:Go to password configuration...%></a>
229 </div>
230 <%- end -%>
231 <% if category then subtree("/" .. category .. "/", cattree) end %>
232