From 6604399aa8f35d33c53a5e5a1fea765f401aef5e Mon Sep 17 00:00:00 2001 From: Steven Barth Date: Thu, 22 May 2008 14:04:03 +0000 Subject: Merge branch 'menu' --- core/src/view/footer.htm | 2 +- core/src/view/header.htm | 101 ++++++++++++++++++++++++++++++++++++----------- 2 files changed, 80 insertions(+), 23 deletions(-) (limited to 'core/src/view') diff --git a/core/src/view/footer.htm b/core/src/view/footer.htm index 67856771b..f324408a1 100644 --- a/core/src/view/footer.htm +++ b/core/src/view/footer.htm @@ -2,6 +2,6 @@
-
FFLuCI 0.3 - Freifunk Lua Configuration Interface
+
<%=require("ffluci").__appname__ .. " " .. ffluci.__version__%> - Freifunk Lua Configuration Interface
\ No newline at end of file diff --git a/core/src/view/header.htm b/core/src/view/header.htm index 9bb8b8be9..99b43805d 100644 --- a/core/src/view/header.htm +++ b/core/src/view/header.htm @@ -1,21 +1,33 @@ <% require("ffluci.sys") local load1, load5, load15 = ffluci.sys.loadavg() -local req = require("ffluci.dispatcher").request -local menu = require("ffluci.menu").get()[req.category] -menu = menu or {} + +local request = require("ffluci.dispatcher").request +local category = request[1] +local tree = ffluci.dispatcher.node() +local cattree = category and ffluci.dispatcher.node(category) +local node = ffluci.dispatcher.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("ffluci.i18n").loadc("default") + require("ffluci.http").prepare_content("text/html") %> - - + <% if node and node.css then %><% end %> - FFLuCI + FFLuCI - Freifunk Lua Configuration Interface
- Freifunk Kamikaze
- <%:batmanedition Fledermausedition%> + <%~luci.main.title%>
+ <%~luci.main.subtitle%>
-<%:path Pfad%>: "><%=translate(req.category, req.category)%>"><%=translate(req.module, req.module)%>"><%=translate(req.action, req.action)%> +<%:path Pfad%>: <% +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 + table.insert(index, {name=k, order=n.order or 100}) + 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]%> +
  • + class="yellowtext"<%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 then %> + class="yellowtext"<%end%>><%=node.title%> + <%submenu("/" .. category .. "/" .. k.name .. "/", node)%> +
+<% end + end +end +%>