%
require("luci.sys")
local load1, load5, load15 = luci.sys.loadavg()
local request = require("luci.dispatcher").context.path
local category = request[1]
local tree = luci.dispatcher.node()
local cattree = category and luci.dispatcher.node(category)
local node = luci.dispatcher.context.dispatched
local c = tree
for i,r in ipairs(request) do
if c.nodes and c.nodes[r] then
c = c.nodes[r]
c._menu_selected = true
end
end
require("luci.i18n").loadc("default")
require("luci.http").prepare_content("text/html")
%>
<%:path%>: <%
local c = tree
local url = controller
for k,v in pairs(request) do
if c.nodes and c.nodes[v] then
c = c.nodes[v]
url = url .. "/" .. v
%>
<%=c.title or v%> <% if k ~= #request then %>» <% end
end
end
%>
<%
local function submenu(prefix, node)
if not node._menu_selected or not node.nodes then
return false
end
local index = {}
for k, n in pairs(node.nodes) do
if n.title and n.target then
table.insert(index, {name=k, order=n.order or 100})
end
end
table.sort(index, function(a, b) return a.order < b.order end)
%>
<% for j, v in pairs(index) do
local nnode = node.nodes[v.name]
local href = controller .. prefix .. v.name
href = (nnode.query) and href .. luci.http.build_querystring(nnode.query) or href
%>
-
class="active"<%end%>><%=nnode.title%>
<% submenu(prefix .. v.name .. "/", nnode) %>
<% end %>
<%
end
if cattree and cattree.nodes then
local index = {}
for k, node in pairs(cattree.nodes) do
table.insert(index, {name=k, order=node.order or 100})
end
table.sort(index, function(a, b) return a.order < b.order end)
for i, k in ipairs(index) do
node = cattree.nodes[k.name]
if node.title and node.target then
local href = controller.."/"..category.."/"..k.name
href = (k.query) and href .. luci.http.build_querystring(k.query) or href %>
class="preactive"<%end%>>
<%=node.title%>
<%submenu("/" .. category .. "/" .. k.name .. "/", node)%>
<% end
end
end
%>