luci-theme-material: remove the double slash (//) from menu url
[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
125     <meta name="application-name" content="<%=striptags( (boardinfo.hostname or "?") ) %> - LuCI">
126     <meta name="apple-mobile-web-app-title" content="<%=striptags( (boardinfo.hostname or "?") ) %> - LuCI">
127     <meta name="msapplication-TileImage" content="<%=media%>/logo.png"/>
128     <link rel="icon" href="<%=media%>/logo.png" sizes="144x144">
129     <link rel="apple-touch-icon-precomposed" href="<%=media%>/logo.png" sizes="144x144">
130
131     <link rel="stylesheet" href="<%=media%>/css/style.css">
132     <link rel="shortcut icon" href="<%=media%>/favicon.ico">
133     <% if node and node.css then %>
134         <link rel="stylesheet" href="<%=resource%>/<%=node.css%>">
135     <% end -%>
136     <% if css then %>
137         <style title="text/css">
138             <%-= css %>
139         </style>
140     <% end -%>
141     <script src="<%=resource%>/xhr.js"></script>
142 </head>
143
144 <body class="lang_<%=luci.i18n.context.lang%> <%- if node then %><%= striptags( node.title ) %><%- end %> <% if luci.dispatcher.context.authsession then %>logged-in<% end %>">
145
146 <header>
147         <div class="container">
148                 <span class="showSide"></span>
149                 <a class="brand" href="#"><%=boardinfo.hostname or "?"%></a>
150                 <div class="pull-right">
151                 <%
152                 -- calculate the number of unsaved changes
153                 if tree.nodes[category] and tree.nodes[category].ucidata then
154                         local ucichanges = 0
155                         for i, j in pairs(require("luci.model.uci").cursor():changes()) do
156                                 for k, l in pairs(j) do
157                                         for m, n in pairs(l) do
158                                                 ucichanges = ucichanges + 1;
159                                         end
160                                 end
161                         end
162                         %>
163                         <% if ucichanges > 0 then %>
164                         <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>
165                         <% end %>
166                         <span id="xhr_poll_status" style="display:none" onclick="XHR.running() ? XHR.halt() : XHR.run()">
167                                 <span class="label success" id="xhr_poll_status_on"><span class="mobile-hide"><%:Auto Refresh%> </span><%:on%></span>
168                                 <span class="label" id="xhr_poll_status_off" style="display:none"><span class="mobile-hide"><%:Auto Refresh%> </span><%:off%></span>
169                         </span>
170                 <% end %>
171                 </div>
172         </div>
173 </header>
174
175  <div class="main">
176          <div style="" class="loading"><span><div class="loading-img"></div>Loading...</span></div>
177          <div class="main-left">
178                  <ul class="nav">
179                          <%-
180                          local function submenu(prefix, node)
181                          local childs = disp.node_childs(node)
182                          if #childs > 0 then
183                          %>
184                          <ul class="slide-menu">
185                                  <%-
186                                  for i, r in ipairs(childs) do
187                                  local nnode = node.nodes[r]
188                                  local href  = controller .. prefix .. r ..
189                                  (nnode.query and http.build_querystring(nnode.query) or "")
190                                  %>
191                                  <li><a data-title="<%=pcdata(striptags(nnode.title))%>" href="<%=pcdata(href)%>"><%=pcdata(striptags(translate(nnode.title)))%></a></li>
192                                  <%-
193                                  end
194                                  %>
195                          </ul>
196                          <%-
197                          end
198                          end
199
200                          childs = disp.node_childs(cattree)
201
202                          if #childs > 0 then
203                          for i, r in ipairs(childs) do
204                          local nnode = cattree.nodes[r]
205                          local href  = controller .. "/" .. category .. "/" .. r ..
206                          (nnode.query and http.build_querystring(k.query) or "")
207                          local grandchildren = disp.node_childs(nnode)
208
209                          if #grandchildren > 0 then
210                          %>
211                          <li class="slide">
212                                  <a class="menu" data-title="<%=pcdata(striptags(nnode.title))%>" href="#"><%=pcdata(striptags(translate(nnode.title)))%></a>
213                                  <%- submenu(category .. "/" .. r .. "/", nnode) %>
214                          </li>
215                          <%          else %>
216                          <li>
217                                  <a data-title="<%=pcdata(striptags(nnode.title))%>" href="<%=pcdata(href)%>"><%=pcdata(striptags(translate(nnode.title)))%></a>
218                          </li>
219                          <%
220                          end
221                          end
222                          end
223                          %>
224                  </ul>
225          </div>
226          <div class="main-right">
227                  <div class="darkMask"></div>
228                  <div id="maincontent">
229                          <div class="container">
230                                  <%- if luci.sys.process.info("uid") == 0 and luci.sys.user.getuser("root") and not luci.sys.user.getpasswd("root") then -%>
231                                          <div class="alert-message warning">
232                                                  <h4><%:No password set!%></h4>
233                                                  <%:There is no password set on this router. Please configure a root password to protect the web interface and enable SSH.%><br>
234                                                  <a href="<%=pcdata(luci.dispatcher.build_url("admin/system/admin"))%>"><%:Go to password configuration...%></a>
235                                          </div>
236                                  <%- end -%>
237                                  <% if category then subtree("/" .. category .. "/", cattree) end %>
238