summaryrefslogtreecommitdiffhomepage
path: root/themes
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2011-10-26 02:51:34 +0000
committerJo-Philipp Wich <jow@openwrt.org>2011-10-26 02:51:34 +0000
commit7918c835865b80c6009bbe498db3f53d3d30cf3a (patch)
tree03dd20e05e0b6eaa4f27977ce9bdf5695df9ddbf /themes
parente12b8dbc1f8d4a0d820d89ab8ade4bc6f740bb63 (diff)
themes/freifunk: port to updated dispatcher api
Diffstat (limited to 'themes')
-rw-r--r--themes/freifunk/luasrc/view/themes/freifunk/header.htm172
1 files changed, 86 insertions, 86 deletions
diff --git a/themes/freifunk/luasrc/view/themes/freifunk/header.htm b/themes/freifunk/luasrc/view/themes/freifunk/header.htm
index 023e86a1e..0580a1866 100644
--- a/themes/freifunk/luasrc/view/themes/freifunk/header.htm
+++ b/themes/freifunk/luasrc/view/themes/freifunk/header.htm
@@ -11,26 +11,34 @@ You may obtain a copy of the License at
-%>
<%
-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 hostname = luci.sys.hostname()
-
-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
+ local sys = require "luci.sys"
+ local http = require "luci.http"
+ local disp = require "luci.dispatcher"
+
+ local hostname = sys.hostname()
+ local load1, load5, load15 = sys.loadavg()
+
+ local request = disp.context.path
+ local category = request[1]
+ local cattree = category and disp.node(category)
+
+ local tree = disp.node()
+ local node = disp.context.dispatched
+
+ local categories = disp.node_childs(tree)
-require("luci.i18n").loadc("base")
-require("luci.http").prepare_content("text/html")
+ local c = tree
+ local i, r
+ -- tag all nodes leading to this page
+ 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
+
+ http.prepare_content("text/html")
-%>
<?xml version="1.0" encoding="utf-8"?>
@@ -62,7 +70,7 @@ require("luci.http").prepare_content("text/html")
</script>
<![endif]-->
</head>
-<body onload="window.setup_hover && setup_hover()">
+<body onload="if (window.setup_hover) setup_hover()">
<div id="all">
<center>
@@ -90,87 +98,79 @@ require("luci.http").prepare_content("text/html")
</div>
<div class="pathbar separator black whitetext bold">
-<%: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
- %><a href="<%=url%>"><%=pcdata(striptags(translate(c.title) or v))%></a> <% if k ~= #request then %>&#187; <% end
+<%:Path%>:
+<%
+ local c = tree
+ local url = controller
+ for i, r in ipairs(request) do
+ if c.nodes and c.nodes[r] then
+ c = c.nodes[r]
+ url = url .. "/" .. r
+%>
+ <a href="<%=url%>"><%=pcdata(striptags(translate(c.title) or v))%></a>
+ <% if k ~= #request then %> &#187; <% end %>
+<%
+ end
end
-end
%>
</div>
<div class="menubar">
<div id="mainmenu" class="mainmenu">
-<%-
-local function submenu(prefix, node)
- if not node.nodes or node.hidden then
- return false
- end
- local index = {}
- local count = 0
- 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})
- count = count + 1
+ <%-
+ local function submenu(prefix, node)
+ local childs = disp.node_childs(node)
+ if #childs > 0 then
+ %>
+ <ul>
+ <%-
+ for i, r in ipairs(childs) do
+ local nnode = node.nodes[r]
+ local href = controller .. prefix .. r ..
+ (nnode.query and http.build_querystring(nnode.query) or "")
+ %>
+ <li>
+ <span<%=ifattr(nnode._menu_selected, "class", "active")%>>
+ <a href="<%=pcdata(href)%>"><%=pcdata(striptags(translate(nnode.title)))%></a>
+ </span>
+ <%- submenu(prefix .. r .. "/", nnode) %>
+ </li>
+ <%-
+ end
+ %>
+ </ul>
+ <%-
+ end
end
- end
-
- table.sort(index, function(a, b) return a.order < b.order end)
-
- if count > 0 then
-%>
- <ul>
- <%- for j, v in pairs(index) do
- if not v.hidden and #v.name > 0 then
- 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
- %>
- <li>
- <span<% if nnode._menu_selected then %> class="active"<%end%>><a href="<%=pcdata(href)%>"><%=pcdata(striptags(translate(nnode.title)))%></a></span>
- <%- submenu(prefix .. v.name .. "/", nnode) %>
- </li>
- <%- end %>
- <%- end %>
- </ul>
-<%-
- 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)
+ childs = disp.node_childs(cattree)
- for i, k in ipairs(index) do
- node = cattree.nodes[k.name]
- if not node.hidden and 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 %>
- <div<% if node._menu_selected then %> class="preactive"<%end%>><a href="<%=pcdata(href)%>"><%=pcdata(striptags(translate(node.title)))%></a>
- <%submenu("/" .. category .. "/" .. k.name .. "/", node)%>
- </div>
-<% end
- end
-end
-%>
+ if #childs > 0 then
+ for i, r in ipairs(childs) do
+ local nnode = cattree.nodes[r]
+ local href = controller .. "/" .. category .. "/" .. r ..
+ (nnode.query and http.build_querystring(k.query) or "")
+ %>
+ <div<%=ifattr(nnode._menu_selected, "class", "preactive")%>>
+ <a href="<%=pcdata(href)%>"><%=pcdata(striptags(translate(nnode.title)))%></a>
+ <%- submenu("/" .. category .. "/" .. r .. "/", nnode) %>
+ </div>
+ <%
+ end
+ end
+ %>
</div>
+
+ <% if #categories > 1 then %>
<div class="modemenu">
- <ul><%
- for k,node in pairs(tree.nodes) do
- if node.title and not node.hidden then %>
- <li<% if request[1] == k then %> class="active"<%end%>><a href="<%=controller%>/<%=k%>"><%=pcdata(translate(node.title))%></a></li>
-<% end
- end%>
+ <ul>
+ <% for i, r in ipairs(categories) do %>
+ <li><a<%=ifattr(request[1] == r, "class", "active")%> href="<%=controller%>/<%=r%>/"><%=striptags(translate(tree.nodes[r].title))%></a></li>
+ <% end %>
</ul>
</div>
+ <% end %>
<%
if tree.nodes[category] and tree.nodes[category].ucidata then