<%#
-LuCI - Lua Configuration Interface
-Copyright 2008 Steven Barth <steven@midlink.org>
-Copyright 2008-2010 Jo-Philipp Wich <xm@subsignal.org>
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-$Id$
-
+ Copyright 2008 Steven Barth <steven@midlink.org>
+ Copyright 2008-2010 Jo-Philipp Wich <jow@openwrt.org>
+ Licensed to the public under the Apache License 2.0.
-%>
+
<%
local sys = require "luci.sys"
local util = require "luci.util"
local http = require "luci.http"
local disp = require "luci.dispatcher"
+ local ver = require "luci.version"
local sysinfo = util.ubus("system", "info") or { }
local loadinfo = sysinfo.load or { 0, 0, 0 }
http.prepare_content("application/xhtml+xml")
local function nodeurl(prefix, name, query)
- local url = controller .. prefix .. name .. "/"
+ local u = url(prefix, name)
if query then
- url = url .. http.build_querystring(query)
+ u = u .. http.build_querystring(query)
end
- return pcdata(url)
+ return pcdata(u)
end
- local function subtree(prefix, node, level)
+ local function render_menu(prefix, node, level)
if not level then
level = 1
end
local childs = disp.node_childs(node)
if #childs > 0 then
-%>
- <div class="tabmenu<%=level%>">
- <ul class="tabmenu l<%=level%>">
- <%
+ write('<div class="tabmenu%d"><ul class="tabmenu l%d">' %{
+ level, level
+ })
+
local selected_node
local selected_name
local i, v
selected_node = nnode
selected_name = v
end
- %>
- <li class="tabmenu-item-<%=v%><% if nnode._menu_selected or (node.leaf and v == leaf) then %> active<% end %>">
- <a href="<%=nodeurl(prefix, v, nnode.query)%>"><%=striptags(translate(nnode.title))%></a>
- </li>
- <%
+
+ write('<li class="tabmenu-item-%s %s"><a href="%s">%s</a></li>' %{
+ v, (nnode._menu_selected or (node.leaf and v == leaf)) and 'active' or '',
+ nodeurl(prefix, v, nnode.query),
+ striptags(translate(nnode.title))
+ })
end
- %>
- </ul>
- <br style="clear:both" />
-<%
+
+ write('</ul><br style="clear:both" />')
+
if selected_node then
- subtree(prefix .. selected_name .. "/", selected_node, level + 1)
+ render_menu(prefix .. "/" .. selected_name, selected_node, level + 1)
end
-%>
- </div>
-<%
+
+ write('</div>')
+ end
+ end
+
+ local function render_changes()
+ if tree.nodes[category] and tree.nodes[category].ucidata then
+ local ucic = 0
+ for i, j in pairs(require("luci.model.uci").cursor():changes()) do
+ for k, l in pairs(j) do
+ for m, n in pairs(l) do
+ ucic = ucic + 1;
+ end
+ end
+ end
+
+ write('<div id="savemenu">')
+
+ if ucic > 0 then
+ write('<a class="warning" href="%s?redir=%s">%s: %d</a>' %{
+ url(category, 'uci/changes'),
+ http.urlencode(http.formvalue('redir') or REQUEST_URI),
+ translate('Unsaved Changes'),
+ ucic
+ })
+ else
+ write('<a href="#">%s: 0</a>' %{
+ translate('Unsaved Changes')
+ })
+ end
+
+ write('</div>')
end
end
-%>
<h2 class="navigation"><a id="navigation" name="navigation"><%:Navigation%></a></h2>
<div class="hostinfo">
- <%=(boardinfo.hostname or "?")%> | <%=luci.version.distversion%> |
- <%:Load%>: <%="%.2f" % loadinfo[1] / 65535.0%> <%="%.2f" % loadinfo[2] / 65535.0%> <%="%.2f" % loadinfo[3] / 65535.0%>
+ <%=(boardinfo.hostname or "?")%> | <%=ver.distversion%> |
+ <%:Load%>: <%="%.2f" % (loadinfo[1] / 65535.0)%> <%="%.2f" % (loadinfo[2] / 65535.0)%> <%="%.2f" % (loadinfo[3] / 65535.0)%>
<span id="xhr_poll_status" style="display:none" onclick="XHR.running() ? XHR.halt() : XHR.run()">
| <%:Auto Refresh%>:
<span id="xhr_poll_status_on"><%:on%></span>
</ul>
<% end %>
-<%
-if tree.nodes[category] and tree.nodes[category].ucidata then
- local ucic = 0
- for i, j in pairs(require("luci.model.uci").cursor():changes()) do
- for k, l in pairs(j) do
- for m, n in pairs(l) do
- ucic = ucic + 1;
- end
- end
- end
--%>
-<div id="savemenu">
- <% if ucic > 0 then %>
- <a class="warning" href="<%=controller%>/<%=category%>/uci/changes/?redir=<%=luci.http.urlencode(luci.http.formvalue("redir") or REQUEST_URI)%>"><%:Unsaved Changes%>: <%=ucic%></a>
- <%- else -%>
- <a href="#"><%:Changes%>: 0</a>
- <% end -%>
-</div><% end %>
+<% render_changes() %>
<div class="clear"></div>
</div>
<div id="maincontainer">
<div id="tabmenu">
- <% if category then subtree("/" .. category .. "/", cattree) end %>
+ <% if category then render_menu(category, cattree) end %>
</div>
<div id="maincontent">
<noscript>
<div class="errorbox">
- <strong><%:Java Script required!%></strong><br />
- <%:You must enable Java Script in your browser or LuCI will not work properly.%>
+ <strong><%:JavaScript required!%></strong><br />
+ <%:You must enable JavaScript in your browser or LuCI will not work properly.%>
</div>
</noscript>