2 Copyright
2008 Steven Barth
<steven@midlink.org
>
3 Copyright
2008-
2016 Jo-Philipp Wich
<jow@openwrt.org
>
4 Copyright
2012 David Menting
<david@nut-bolt.nl
>
5 Licensed to the public under the Apache License
2.0.
9 local sys = require
"luci.sys"
10 local util = require
"luci.util"
11 local http = require
"luci.http"
12 local disp = require
"luci.dispatcher"
14 local boardinfo = util.ubus(
"system",
"board")
16 local request = disp.context.path
17 local request2 = disp.context.request
19 local category = request[
1]
20 local cattree = category and disp.node(category)
22 local leaf = request2[#request2]
24 local tree = disp.node()
25 local node = disp.context.dispatched
27 local categories = disp.node_childs(tree)
32 -- tag all nodes leading to this page
33 for i, r in ipairs(request) do
34 if c.nodes and c.nodes[r] then
36 c._menu_selected = true
41 http.prepare_content(
"text/html")
43 local function nodeurl(prefix, name, query)
44 local u = url(prefix, name)
46 u = u .. http.build_querystring(query)
51 local function render_tabmenu(prefix, node, level)
56 local childs = disp.node_childs(node)
59 write('
<ul class=
"tabs">')
66 for i, v in ipairs(childs) do
67 local nnode = node.nodes[v]
68 if nnode._menu_selected then
74 write('
<li class=
"tabmenu-item-%s %s"><a href=
"%s">%s
</a></li>' %{
75 v, (nnode._menu_selected or (node.leaf and v == leaf)) and 'active' or '',
76 nodeurl(prefix, v, nnode.query),
77 striptags(translate(nnode.title))
87 render_tabmenu(prefix ..
"/" .. selected_name, selected_node, level +
1)
92 local function render_submenu(prefix, node)
93 local childs = disp.node_childs(node)
95 write('
<ul class=
"dropdown-menu">')
97 for i, r in ipairs(childs) do
98 local nnode = node.nodes[r]
99 write('
<li><a href=
"%s">%s
</a></li>' %{
100 nodeurl(prefix, r, nnode.query),
101 striptags(translate(nnode.title))
109 local function render_topmenu()
110 local childs = disp.node_childs(cattree)
112 write('
<ul class=
"nav">')
114 for i, r in ipairs(childs) do
115 local nnode = cattree.nodes[r]
116 local grandchildren = disp.node_childs(nnode)
118 if #grandchildren
> 0 then
119 write('
<li class=
"dropdown"><a class=
"menu" href=
"#">%s
</a>' % striptags(translate(nnode.title)))
120 render_submenu(category ..
"/" .. r, nnode)
123 write('
<li><a href=
"%s">%s
</a></li>' %{
124 nodeurl(category, r, nnode.query),
125 striptags(translate(nnode.title))
135 <html lang=
"<%=luci.i18n.context.lang%>">
137 <meta charset=
"utf-8">
138 <title><%=striptags( (boardinfo.hostname or
"?") .. ( (node and node.title) and ' - ' .. translate(node.title) or '')) %
> - LuCI
</title>
139 <meta name=
"viewport" content=
"initial-scale=1.0">
140 <link rel=
"stylesheet" href=
"<%=media%>/cascade.css">
141 <link rel=
"stylesheet" media=
"only screen and (max-device-width: 854px)" href=
"<%=media%>/mobile.css" type=
"text/css" />
142 <link rel=
"shortcut icon" href=
"<%=media%>/favicon.png">
143 <% if node and node.css then %
>
144 <link rel=
"stylesheet" href=
"<%=resource%>/<%=node.css%>">
147 <style title=
"text/css"><%= css %
></style>
149 <script src=
"<%=url('admin/translations', luci.i18n.context.lang)%><%# ?v=PKG_VERSION %>"></script>
150 <script src=
"<%=resource%>/cbi.js"></script>
151 <script src=
"<%=resource%>/xhr.js"></script>
154 <body class=
"lang_<%=luci.i18n.context.lang%> <% if node then %><%= striptags( node.title ) %><%- end %>" data-page=
"<%= table.concat(disp.context.requestpath, "-
") %>">
157 <div class=
"container">
158 <a class=
"brand" href=
"#"><%=boardinfo.hostname or
"?"%
></a>
159 <% render_topmenu() %
>
160 <div class=
"pull-right">
161 <span id=
"xhr_poll_status" style=
"display:none" onclick=
"XHR.running() ? XHR.halt() : XHR.run()">
162 <span class=
"label success" id=
"xhr_poll_status_on"><%:Auto Refresh%
> <%:on%
></span>
163 <span class=
"label" id=
"xhr_poll_status_off" style=
"display:none"><%:Auto Refresh%
> <%:off%
></span>
170 <div id=
"maincontent" class=
"container">
171 <%- if luci.sys.process.info(
"uid") ==
0 and luci.sys.user.getuser(
"root") and not luci.sys.user.getpasswd(
"root") then -%
>
172 <div class=
"alert-message warning">
173 <h4><%:No password set!%
></h4>
174 <p><%:There is no password set on this router. Please configure a root password to protect the web interface and enable SSH.%
></p>
175 <% if disp.lookup(
"admin/system/admin") then %
>
176 <div class=
"right"><a class=
"btn" href=
"<%=url("admin/system/admin
")%>"><%:Go to password configuration...%
></a></div>
182 <div class=
"alert-message warning">
183 <h4><%:JavaScript required!%
></h4>
184 <p><%:You must enable JavaScript in your browser or LuCI will not work properly.%
></p>
188 <% if category then render_tabmenu(category, cattree) end %
>