2 Rosy is a theme for LuCI. It is based on luci-theme-bootstrap
4 Copyright
2018 Rosy Song
<rosysong@rosinson.com
>
5 Copyright
2018 Yan Lan Shen
<yanlan.shen@rosinson.com
>
7 Have a bug? Please create an issue here on GitHub!
8 https://github.com/rosywrt/luci-theme-rosy/issues
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
>
15 Licensed to the public under the Apache License
2.0
20 local sys = require
"luci.sys"
21 local util = require
"luci.util"
22 local http = require
"luci.http"
23 local disp = require
"luci.dispatcher"
25 local boardinfo = util.ubus(
"system",
"board")
27 local request = disp.context.path
28 local request2 = disp.context.request
30 local category = request[
1]
31 local cattree = category and disp.node(category)
33 local leaf = request2[#request2]
35 local tree = disp.node()
36 local node = disp.context.dispatched
38 local categories = disp.node_childs(tree)
43 -- tag all nodes leading to this page
44 for i, r in ipairs(request) do
45 if c.nodes and c.nodes[r] then
47 c._menu_selected = true
52 http.prepare_content(
"text/html")
54 local function nodeurl(prefix, name, query)
55 local u = url(prefix, name)
57 u = u .. http.build_querystring(query)
62 local function render_tabmenu(prefix, node, level)
67 local childs = disp.node_childs(node)
70 write('
<ul class=
"tabs">')
77 for i, v in ipairs(childs) do
78 local nnode = node.nodes[v]
79 if nnode._menu_selected then
85 write('
<li class=
"tabmenu-item-%s %s"><a href=
"%s">%s
</a></li>' %{
86 v, (nnode._menu_selected or (node.leaf and v == leaf)) and 'active' or '',
87 nodeurl(prefix, v, nnode.query),
88 striptags(translate(nnode.title))
98 render_tabmenu(prefix ..
"/" .. selected_name, selected_node, level +
1)
103 local function render_submenu(prefix, node)
104 local childs = disp.node_childs(node)
106 write('
<ul class=
"slide-menu">')
108 for i, r in ipairs(childs) do
109 local nnode = node.nodes[r]
110 local title = pcdata(striptags(translate(nnode.title)))
112 write('
<li><a data-title=
"%s" href=
"%s">%s
</a></li>' %{
114 nodeurl(prefix, r, nnode.query),
123 local function render_topmenu()
124 local childs = disp.node_childs(cattree)
126 write('
<ul class=
"nav">')
128 for i, r in ipairs(childs) do
129 local nnode = cattree.nodes[r]
130 local grandchildren = disp.node_childs(nnode)
132 if #grandchildren
> 0 then
133 local title = pcdata(striptags(translate(nnode.title)))
135 write('
<li class=
"slide"><a class=
"menu" data-title=
"%s" href=
"#">%s
</a>' %{
140 render_submenu(category ..
"/" .. r, nnode)
149 local function render_logout()
150 local childs = disp.node_childs(cattree)
153 for i, r in ipairs(childs) do
154 local nnode = cattree.nodes[r]
155 local grandchildren = disp.node_childs(nnode)
157 if #grandchildren <=
0 then
158 local title = pcdata(striptags(translate(nnode.title)))
160 write('
<span class=
"label logout"><a data-title=
"%s" href=
"%s">%s
</a></span>' %{
162 nodeurl(category, r, nnode.query),
172 local function render_changes()
173 -- calculate the number of unsaved changes
174 if tree.nodes[category] and tree.nodes[category].ucidata then
177 for i, j in pairs(require(
"luci.model.uci").cursor():changes()) do
178 for k, l in pairs(j) do
179 for m, n in pairs(l) do
180 ucichanges = ucichanges +
1;
185 if ucichanges
> 0 then
186 write('
<a class=
"uci_change_indicator label notice" href=
"%s?redir=%s"><span class=
"mobile-hide">%s:
</span> %d
</a>' %{
187 url(category, 'uci/changes'),
188 http.urlencode(http.formvalue('redir') or table.concat(disp.context.request,
"/")),
189 translate('Unsaved Changes'),
197 <html lang=
"<%=luci.i18n.context.lang%>">
200 <meta charset=
"utf-8">
202 <%=striptags( (boardinfo.hostname or
"?") .. ( (node and node.title) and ' - ' .. translate(node.title) or '')) %
> -
204 <meta content=
"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name=
"viewport" />
205 <meta name=
"format-detection" content=
"telephone=no, email=no" />
206 <meta name=
"apple-mobile-web-app-capable" content=
"yes">
207 <meta name=
"mobile-web-app-capable" content=
"yes">
208 <meta name=
"x5-fullscreen" content=
"true">
209 <meta name=
"full-screen" content=
"yes">
210 <meta name=
"x5-page-mode" content=
"app">
211 <meta name=
"browsermode" content=
"application">
212 <meta name=
"theme-color" content=
"#0099CC">
213 <meta name=
"msapplication-tap-highlight" content=
"no">
214 <meta name=
"msapplication-TileColor" content=
"#0099CC">
216 <meta name=
"application-name" content=
"<%=striptags( (boardinfo.hostname or " ?
") ) %> - LuCI">
217 <meta name=
"apple-mobile-web-app-title" content=
"<%=striptags( (boardinfo.hostname or " ?
") ) %> - LuCI">
218 <meta name=
"msapplication-TileImage" content=
"<%=media%>/logo.png" />
219 <link rel=
"icon" href=
"<%=media%>/logo.png" sizes=
"144x144">
220 <link rel=
"apple-touch-icon-precomposed" href=
"<%=media%>/logo.png" sizes=
"144x144">
222 <link rel=
"stylesheet" href=
"<%=media%>/cascade.css">
223 <link rel=
"shortcut icon" href=
"<%=media%>/favicon.ico">
224 <% if node and node.css then %
>
225 <link rel=
"stylesheet" href=
"<%=resource%>/<%=node.css%>">
228 <style title=
"text/css">
232 <script src=
"<%=resource%>/cbi.js"></script>
233 <script src=
"<%=resource%>/xhr.js"></script>
236 <body class=
"lang_<%=luci.i18n.context.lang%> <%- if node then %><%= striptags( node.title ) %><%- end %> <% if luci.dispatcher.context.authsession then %>logged-in<% end %>">
239 <div class=
"container">
240 <span class=
"showSide"></span>
241 <a class=
"brand" href=
"#"><%=boardinfo.hostname or
"?"%
></a>
242 <div class=
"btn-con pull-right">
243 <% render_changes() %
>
244 <span id=
"xhr_poll_status" style=
"display:none" onclick=
"XHR.running() ? XHR.halt() : XHR.run()">
245 <span class=
"label success" id=
"xhr_poll_status_on"><span class=
"mobile-hide">
246 <%:Auto Refresh%
></span>
248 <span class=
"label" id=
"xhr_poll_status_off" style=
"display:none"><span class=
"mobile-hide">
249 <%:Auto Refresh%
></span>
252 <% render_logout() %
>
258 <div style=
"" class=
"loading"><span>
259 <div class=
"loading-img">
260 <img src=
"<%=media%>/loading.svg">
263 <div class=
"main-left">
264 <div class=
"nav-container">
265 <a class=
"brand" href=
"#">
266 <%=boardinfo.hostname or
"?"%
></a>
267 <div class=
"navbar-container">
268 <% render_topmenu() %
>
272 <div class=
"main-right">
273 <div id=
"maincontent">
274 <div class=
"logoImg">
275 <img class=
"mobile-hide" src=
"<%=media%>/logo.png" alt=
"Rosy">
276 <img src=
"<%=media%>/mobile-loginBG.png" class=
"PC-hide">
277 <a class=
"brand" href=
"#"><%=boardinfo.hostname or
"?"%
></a>
279 <div class=
"container">
280 <%- if luci.sys.process.info(
"uid") ==
0 and luci.sys.user.getuser(
"root") and not luci.sys.user.getpasswd(
"root") then -%
>
281 <div class=
"alert-message warning">
283 <%:No password set!%
>
286 <%:There is no password set on this router. Please configure a root password to protect the web interface and enable SSH.%
>
288 <div><a class=
"btn" href=
"<%=url("admin/system/admin
")%>"> <%:Go to password configuration...%
></a></div>
293 <div class=
"alert-message warning">
295 <%:JavaScript required!%
>
298 <%:You must enable JavaScript in your browser or LuCI will not work properly.%
>
303 <% if category then render_tabmenu(category, cattree) end %
>