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 = 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 = 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 = 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 ucichanges = ucichanges + #j
168 if ucichanges
> 0 then
169 write('
<a class=
"uci_change_indicator label notice" href=
"%s?redir=%s">%s: %d
</a>' %{
170 url(category, 'uci/changes'),
171 http.urlencode(http.formvalue('redir') or table.concat(disp.context.request,
"/")),
172 translate('Unsaved Changes'),
180 <html lang=
"<%=luci.i18n.context.lang%>">
182 <meta charset=
"utf-8">
183 <title><%=striptags( (boardinfo.hostname or
"?") .. ( (node and node.title) and ' - ' .. translate(node.title) or '')) %
> - LuCI
</title>
184 <meta content=
"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name=
"viewport"/>
185 <meta name=
"apple-mobile-web-app-capable" content=
"yes">
186 <meta name=
"mobile-web-app-capable" content=
"yes">
187 <meta name=
"theme-color" content=
"#09c">
188 <meta name=
"msapplication-tap-highlight" content=
"no">
189 <meta name=
"msapplication-TileColor" content=
"#09c">
190 <meta name=
"application-name" content=
"<%=striptags( (boardinfo.hostname or "?
") ) %> - LuCI">
191 <meta name=
"apple-mobile-web-app-title" content=
"<%=striptags( (boardinfo.hostname or "?
") ) %> - LuCI">
192 <link rel=
"stylesheet" href=
"<%=media%>/cascade.css">
193 <link rel=
"shortcut icon" href=
"<%=media%>/favicon.ico">
194 <% if node and node.css then %
>
195 <link rel=
"stylesheet" href=
"<%=resource%>/<%=node.css%>">
198 <style title=
"text/css"><%= css %
></style>
200 <script src=
"<%=url('admin/translations', luci.i18n.context.lang)%><%# ?v=PKG_VERSION %>"></script>
201 <script src=
"<%=resource%>/cbi.js"></script>
202 <script src=
"<%=resource%>/xhr.js"></script>
204 <body class=
"lang_<%=luci.i18n.context.lang%> <% if node then %><%= striptags( node.title ) %><% end %> <% if luci.dispatcher.context.authsession then %>logged-in<% end %>" data-page=
"<%= table.concat(disp.context.requestpath, "-
") %>">
207 <div class=
"container">
208 <span class=
"showSide"></span>
209 <a id=
"logo" href=
"<%=url("admin/status/overview
")%>"><img src=
"<%=media%>/brand.png" alt=
"OpenWrt"></a>
210 <a class=
"brand" href=
"#"><%=boardinfo.hostname or
"?"%
></a>
212 <% render_changes() %
>
213 <span id=
"xhr_poll_status" style=
"display:none" onclick=
"XHR.running() ? XHR.halt() : XHR.run()">
214 <span class=
"label success" id=
"xhr_poll_status_on"><span class=
"mobile-hide"><%:Auto Refresh%
></span> <%:on%
></span>
215 <span class=
"label" id=
"xhr_poll_status_off" style=
"display:none"><span class=
"mobile-hide"><%:Auto Refresh%
></span> <%:off%
></span>
222 <div style=
"" class=
"loading"><span><div class=
"loading-img"></div>Loading...
</span></div>
223 <div class=
"main-left">
224 <% render_topmenu() %
>
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 <p><%:There is no password set on this router. Please configure a root password to protect the web interface and enable SSH.%
></p>
234 <% if disp.lookup(
"admin/system/admin") then %
>
235 <div class=
"right"><a class=
"btn" href=
"<%=url("admin/system/admin
")%>"><%:Go to password configuration...%
></a></div>
241 <div class=
"alert-message warning">
242 <h4><%:JavaScript required!%
></h4>
243 <p><%:You must enable JavaScript in your browser or LuCI will not work properly.%
></p>
247 <% if category then render_tabmenu(category, cattree) end %
>