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),
160 <html lang="<%=luci.i18n.context.lang%>">
162 <meta charset="utf-8">
163 <title><%=striptags( (boardinfo.hostname or "?") .. ( (node and node.title) and ' - ' .. translate(node.title) or '')) %> - LuCI</title>
164 <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport"/>
165 <meta name="apple-mobile-web-app-capable" content="yes">
166 <meta name="mobile-web-app-capable" content="yes">
167 <meta name="theme-color" content="#09c">
168 <meta name="msapplication-tap-highlight" content="no">
169 <meta name="msapplication-TileColor" content="#09c">
170 <meta name="application-name" content="<%=striptags( (boardinfo.hostname or "?") ) %> - LuCI">
171 <meta name="apple-mobile-web-app-title" content="<%=striptags( (boardinfo.hostname or "?") ) %> - LuCI">
172 <link rel="stylesheet" href="<%=media%>/cascade.css">
173 <link rel="shortcut icon" href="<%=media%>/favicon.ico">
174 <% if node and node.css then %>
175 <link rel="stylesheet" href="<%=resource%>/<%=node.css%>">
178 <style title="text/css"><%= css %></style>
180 <script src="<%=url('admin/translations', luci.i18n.context.lang)%><%# ?v=PKG_VERSION %>"></script>
181 <script src="<%=resource%>/cbi.js"></script>
182 <script src="<%=resource%>/xhr.js"></script>
184 <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, "-") %>">
187 <div class="container">
188 <span class="showSide"></span>
189 <a id="logo" href="<% if luci.dispatcher.context.authsession then %><%=url('admin/status/overview')%><% else %>#<% end %>"><img src="<%=media%>/brand.png" alt="OpenWrt"></a>
190 <a class="brand" href="#"><%=boardinfo.hostname or "?"%></a>
192 <span id="xhr_poll_status" style="display:none" onclick="XHR.running() ? XHR.halt() : XHR.run()">
193 <span class="label success" id="xhr_poll_status_on"><span class="mobile-hide"><%:Auto Refresh%></span> <%:on%></span>
194 <span class="label" id="xhr_poll_status_off" style="display:none"><span class="mobile-hide"><%:Auto Refresh%></span> <%:off%></span>
201 <div style="" class="loading"><span><div class="loading-img"></div><%:Collecting data...%></span></div>
202 <div class="main-left">
203 <% render_topmenu() %>
205 <div class="main-right">
206 <div class="darkMask"></div>
207 <div id="maincontent">
208 <div class="container">
209 <%- if luci.sys.process.info("uid") == 0 and luci.sys.user.getuser("root") and not luci.sys.user.getpasswd("root") then -%>
210 <div class="alert-message warning">
211 <h4><%:No password set!%></h4>
212 <p><%:There is no password set on this router. Please configure a root password to protect the web interface and enable SSH.%></p>
213 <% if disp.lookup("admin/system/admin") then %>
214 <div class="right"><a class="btn" href="<%=url("admin/system/admin")%>"><%:Go to password configuration...%></a></div>
220 <div class="alert-message warning">
221 <h4><%:JavaScript required!%></h4>
222 <p><%:You must enable JavaScript in your browser or LuCI will not work properly.%></p>
226 <% if category then render_tabmenu(category, cattree) end %>