2 Material is a clean HTML5 theme for LuCI. It is based on luci-theme-bootstrap and MUI
5 Copyright
2015-
2017 Lutty Yang
<lutty@wcan.in
>
7 Have a bug? Please create an issue here on GitHub!
8 https://github.com/LuttyYang/luci-theme-material/issues
11 Copyright
2008 Steven Barth
<steven@midlink.org
>
12 Copyright
2008-
2016 Jo-Philipp Wich
<jow@openwrt.org
>
13 Copyright
2012 David Menting
<david@nut-bolt.nl
>
16 https://github.com/muicss/mui
18 Licensed to the public under the Apache License
2.0
22 local sys = require
"luci.sys"
23 local util = require
"luci.util"
24 local http = require
"luci.http"
25 local disp = require
"luci.dispatcher"
27 local boardinfo = util.ubus(
"system",
"board")
29 local request = disp.context.path
30 local request2 = disp.context.request
32 local category = request[
1]
33 local cattree = category and disp.node(category)
35 local leaf = request2[#request2]
37 local tree = disp.node()
38 local node = disp.context.dispatched
40 local categories = disp.node_childs(tree)
45 -- tag all nodes leading to this page
46 for i, r in ipairs(request) do
47 if c.nodes and c.nodes[r] then
49 c._menu_selected = true
54 http.prepare_content(
"text/html")
56 local function nodeurl(prefix, name, query)
57 local u = url(prefix, name)
59 u = u .. http.build_querystring(query)
64 local function render_tabmenu(prefix, node, level)
69 local childs = disp.node_childs(node)
72 write('
<ul class=
"tabs">')
79 for i, v in ipairs(childs) do
80 local nnode = node.nodes[v]
81 if nnode._menu_selected then
87 write('
<li class=
"tabmenu-item-%s %s"><a href=
"%s">%s
</a></li>' %{
88 v, (nnode._menu_selected or (node.leaf and v == leaf)) and 'active' or '',
89 nodeurl(prefix, v, nnode.query),
90 striptags(translate(nnode.title))
100 render_tabmenu(prefix ..
"/" .. selected_name, selected_node, level +
1)
105 local function render_submenu(prefix, node)
106 local childs = disp.node_childs(node)
108 write('
<ul class=
"slide-menu">')
110 for i, r in ipairs(childs) do
111 local nnode = node.nodes[r]
112 local title = pcdata(striptags(translate(nnode.title)))
114 write('
<li><a data-title=
"%s" href=
"%s">%s
</a></li>' %{
116 nodeurl(prefix, r, nnode.query),
125 local function render_topmenu()
126 local childs = disp.node_childs(cattree)
128 write('
<ul class=
"nav">')
130 for i, r in ipairs(childs) do
131 local nnode = cattree.nodes[r]
132 local grandchildren = disp.node_childs(nnode)
134 if #grandchildren
> 0 then
135 local title = pcdata(striptags(translate(nnode.title)))
137 write('
<li class=
"slide"><a class=
"menu" data-title=
"%s" href=
"#">%s
</a>' %{
142 render_submenu(category ..
"/" .. r, nnode)
145 local title = pcdata(striptags(translate(nnode.title)))
147 write('
<li><a data-title=
"%s" href=
"%s">%s
</a></li>' %{
149 nodeurl(category, r, nnode.query),
159 local function render_changes()
160 -- calculate the number of unsaved changes
161 if tree.nodes[category] and tree.nodes[category].ucidata then
164 for i, j in pairs(require(
"luci.model.uci").cursor():changes()) do
165 for k, l in pairs(j) do
166 for m, n in pairs(l) do
167 ucichanges = ucichanges +
1;
172 if ucichanges
> 0 then
173 write('
<a class=
"uci_change_indicator label notice" href=
"%s?redir=%s">%s: %d
</a>' %{
174 url(category, 'uci/changes'),
175 http.urlencode(http.formvalue('redir') or table.concat(disp.context.request,
"/")),
176 translate('Unsaved Changes'),
184 <html lang=
"<%=luci.i18n.context.lang%>">
186 <meta charset=
"utf-8">
187 <title><%=striptags( (boardinfo.hostname or
"?") .. ( (node and node.title) and ' - ' .. translate(node.title) or '')) %
> - LuCI
</title>
188 <meta content=
"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name=
"viewport"/>
189 <meta name=
"format-detection" content=
"telephone=no, email=no"/>
190 <meta name=
"apple-mobile-web-app-capable" content=
"yes">
191 <meta name=
"mobile-web-app-capable" content=
"yes">
192 <meta name=
"x5-fullscreen" content=
"true">
193 <meta name=
"full-screen" content=
"yes">
194 <meta name=
"x5-page-mode" content=
"app">
195 <meta name=
"browsermode" content=
"application">
196 <meta name=
"theme-color" content=
"#0099CC">
197 <meta name=
"msapplication-tap-highlight" content=
"no">
198 <meta name=
"msapplication-TileColor" content=
"#0099CC">
200 <meta name=
"application-name" content=
"<%=striptags( (boardinfo.hostname or "?
") ) %> - LuCI">
201 <meta name=
"apple-mobile-web-app-title" content=
"<%=striptags( (boardinfo.hostname or "?
") ) %> - LuCI">
202 <meta name=
"msapplication-TileImage" content=
"<%=media%>/logo.png"/>
203 <link rel=
"icon" href=
"<%=media%>/logo.png" sizes=
"144x144">
204 <link rel=
"apple-touch-icon-precomposed" href=
"<%=media%>/logo.png" sizes=
"144x144">
206 <link rel=
"stylesheet" href=
"<%=media%>/css/style.css">
207 <link rel=
"shortcut icon" href=
"<%=media%>/favicon.ico">
208 <% if node and node.css then %
>
209 <link rel=
"stylesheet" href=
"<%=resource%>/<%=node.css%>">
212 <style title=
"text/css"><%= css %
></style>
214 <script src=
"<%=resource%>/cbi.js"></script>
215 <script src=
"<%=resource%>/xhr.js"></script>
217 <body class=
"lang_<%=luci.i18n.context.lang%> <%- if node then %><%= striptags( node.title ) %><%- end %> <% if luci.dispatcher.context.authsession then %>logged-in<% end %>">
219 <div class=
"container">
220 <span class=
"showSide"></span>
221 <a class=
"brand" href=
"#"><%=boardinfo.hostname or
"?"%
></a>
222 <div class=
"pull-right">
223 <% render_changes() %
>
224 <span id=
"xhr_poll_status" style=
"display:none" onclick=
"XHR.running() ? XHR.halt() : XHR.run()">
225 <span class=
"label success" id=
"xhr_poll_status_on"><span class=
"mobile-hide"><%:Auto Refresh%
></span> <%:on%
></span>
226 <span class=
"label" id=
"xhr_poll_status_off" style=
"display:none"><span class=
"mobile-hide"><%:Auto Refresh%
></span> <%:off%
></span>
232 <div style=
"" class=
"loading"><span><div class=
"loading-img"></div>Loading...
</span></div>
233 <div class=
"main-left">
234 <% render_topmenu() %
>
236 <div class=
"main-right">
237 <div class=
"darkMask"></div>
238 <div id=
"maincontent">
239 <div class=
"container">
240 <%- if luci.sys.process.info(
"uid") ==
0 and luci.sys.user.getuser(
"root") and not luci.sys.user.getpasswd(
"root") then -%
>
241 <div class=
"alert-message warning">
242 <h4><%:No password set!%
></h4>
243 <p><%:There is no password set on this router. Please configure a root password to protect the web interface and enable SSH.%
></p>
244 <div class=
"right"><a class=
"btn" href=
"<%=url("admin/system/admin
")%>"><%:Go to password configuration...%
></a></div>
249 <div class=
"alert-message warning">
250 <h4><%:JavaScript required!%
></h4>
251 <p><%:You must enable JavaScript in your browser or LuCI will not work properly.%
></p>
255 <% if category then render_tabmenu(category, cattree) end %
>