2 LuCI - Lua Configuration Interface
3 Copyright
2008 Steven Barth
<steven@midlink.org
>
4 Copyright
2008 Jo-Philipp Wich
<xm@leipzig.freifunk.net
>
5 Copyright
2012 David Menting
<david@nut-bolt.nl
>
7 Licensed under the Apache License, Version
2.0 (the
"License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
11 http://www.apache.org/licenses/LICENSE-
2.0
15 local sys = require
"luci.sys"
16 local http = require
"luci.http"
17 local disp = require
"luci.dispatcher"
19 local hostname = sys.hostname()
21 local request = disp.context.path
22 local request2 = disp.context.request
24 local category = request[
1]
25 local cattree = category and disp.node(category)
27 local leaf = request2[#request2]
29 local tree = disp.node()
30 local node = disp.context.dispatched
32 local categories = disp.node_childs(tree)
37 -- tag all nodes leading to this page
38 for i, r in ipairs(request) do
39 if c.nodes and c.nodes[r] then
41 c._menu_selected = true
46 http.prepare_content(
"text/html")
48 local function nodeurl(prefix, name, query)
49 local url = controller .. prefix .. name ..
"/"
51 url = url .. http.build_querystring(query)
56 local function subtree(prefix, node, level)
61 local childs = disp.node_childs(node)
74 for i, v in ipairs(childs) do
75 local nnode = node.nodes[v]
76 if nnode._menu_selected then
82 <li class=
"tabmenu-item-<%=v%><%- if nnode._menu_selected or (node.leaf and v == leaf) then -%> active<% end %>">
83 <a href=
"<%=nodeurl(prefix, v, nnode.query)%>"><%=striptags(translate(nnode.title))%
></a>
94 subtree(prefix .. selected_name ..
"/", selected_node, level +
1)
100 <html lang=
"<%=luci.i18n.context.lang%>">
102 <meta charset=
"utf-8">
103 <title><%=striptags( hostname .. ( (node and node.title) and ' - ' .. translate(node.title) or '')) %
> - LuCI
</title>
104 <!--[if lt IE 9]><script src="<%=media%>/html5.js"></script><![endif]-->
105 <link rel=
"stylesheet" href=
"<%=media%>/cascade.css">
106 <link rel=
"shortcut icon" href=
"<%=media%>/favicon.ico">
107 <% if node and node.css then %
><link rel=
"stylesheet" href=
"<%=resource%>/<%=node.css%>">
109 <script src=
"<%=resource%>/xhr.js"></script>
112 <body class=
"lang_<%=luci.i18n.context.lang%> <%- if node then %><%= striptags( node.title ) %><%- end %>">
115 <div class=
"container">
116 <a class=
"brand" href=
"#"><%=hostname%
></a>
119 local function submenu(prefix, node)
120 local childs = disp.node_childs(node)
123 <ul class=
"dropdown-menu">
125 for i, r in ipairs(childs) do
126 local nnode = node.nodes[r]
127 local href = controller .. prefix .. r ..
128 (nnode.query and http.build_querystring(nnode.query) or
"")
130 <li><a href=
"<%=pcdata(href)%>"><%=pcdata(striptags(translate(nnode.title)))%
></a></li>
139 childs = disp.node_childs(cattree)
142 for i, r in ipairs(childs) do
143 local nnode = cattree.nodes[r]
144 local href = controller ..
"/" .. category ..
"/" .. r ..
145 (nnode.query and http.build_querystring(k.query) or
"")
146 local grandchildren = disp.node_childs(nnode)
148 if #grandchildren
> 0 then
150 <li class=
"dropdown">
151 <a class=
"menu" href=
"<%=pcdata(href)%>"><%=pcdata(striptags(translate(nnode.title)))%
></a>
152 <%- submenu(
"/" .. category ..
"/" .. r ..
"/", nnode) %
>
156 <a href=
"<%=pcdata(href)%>"><%=pcdata(striptags(translate(nnode.title)))%
></a>
166 -- calculate the number of unsaved changes
167 if tree.nodes[category] and tree.nodes[category].ucidata then
170 for i, j in pairs(require(
"luci.model.uci").cursor():changes()) do
171 for k, l in pairs(j) do
172 for m, n in pairs(l) do
173 ucichanges = ucichanges +
1;
178 <div class=
"pull-right">
179 <% if ucichanges
> 0 then %
>
180 <a class=
"label notice" href=
"<%=controller%>/<%=category%>/uci/changes"><%:Unsaved Changes%
>: <%=ucichanges%
></a>
182 <span id=
"xhr_poll_status" style=
"display:none" onclick=
"XHR.running() ? XHR.halt() : XHR.run()">
183 <span class=
"label success" id=
"xhr_poll_status_on"><%:Auto Refresh%
> <%:on%
></span>
184 <span class=
"label" id=
"xhr_poll_status_off" style=
"display:none"><%:Auto Refresh%
> <%:off%
></span>
193 <%- if luci.sys.process.info(
"uid") ==
0 and luci.sys.user.getuser(
"root") and not luci.sys.user.getpasswd(
"root") then -%
>
194 <div class=
"container">
195 <div class=
"alert-message warning">
196 <h4><%:No password set!%
></h4>
197 <%:There is no password set on this router. Please configure a root password to protect the web interface and enable SSH.%
><br>
198 <a href=
"<%=pcdata(luci.dispatcher.build_url("admin/system/admin
"))%>"><%:Go to password configuration...%
></a>
203 <div id=
"maincontent" class=
"container">
204 <% if category then subtree(
"/" .. category ..
"/", cattree) end %
>