From a31debe8a311baf761adf90a2609cf619d335037 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Wed, 26 Oct 2011 02:51:55 +0000 Subject: [PATCH] themes/freifunk-generic: port to updated dispatcher api --- .../view/themes/freifunk-generic/header.htm | 233 +++++++++--------- 1 file changed, 112 insertions(+), 121 deletions(-) diff --git a/themes/freifunk-generic/luasrc/view/themes/freifunk-generic/header.htm b/themes/freifunk-generic/luasrc/view/themes/freifunk-generic/header.htm index 53eae119e..2c35219c6 100644 --- a/themes/freifunk-generic/luasrc/view/themes/freifunk-generic/header.htm +++ b/themes/freifunk-generic/luasrc/view/themes/freifunk-generic/header.htm @@ -1,7 +1,7 @@ <%# LuCI - Lua Configuration Interface Copyright 2008 Steven Barth -Copyright 2008 Jo-Philipp Wich +Copyright 2008-2011 Jo-Philipp Wich Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -11,54 +11,60 @@ You may obtain a copy of the License at -%> <% -require("luci.sys") -local uci = require "luci.model.uci".cursor() -local fs = require "luci.fs" - -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 ff = uci:get("freifunk", "community", "name") or "" -local co = "profile_" .. ff -local community = uci:get_first(co, "community", "name") or "Freifunk" -local hp = uci:get_first(co, "community", "homepage") or "http://www.freifunk.net" -local logo = "/luci-static/freifunk-generic/logo.jpg" -local banner = false -local show_comm = true - -local lo = fs.glob("/www/luci-static/resources/custom_logo.*") -if lo[1] then - logo = string.gsub(lo[1], "/www", "") -end - -local lon = fs.glob("/www/luci-static/resources/custom_logo_only.*") -if lon[1] then - logo = string.gsub(lon[1], "/www", "") - show_comm = false -end - -local hea = fs.glob("/www/luci-static/resources/custom_header.*") -if hea[1] then - logo = string.gsub(hea[1], "/www", "") - show_comm = false - banner = true -end - -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 + local fs = require "luci.fs" + 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) + + 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 + + local uci = require "luci.model.uci".cursor() + local ff = uci:get("freifunk", "community", "name") or "" + local co = "profile_" .. ff + local community = uci:get_first(co, "community", "name") or "Freifunk" + local hp = uci:get_first(co, "community", "homepage") or "http://www.freifunk.net" + local logo = "/luci-static/freifunk-generic/logo.jpg" + local banner = false + local show_comm = true + + local lo = fs.glob("/www/luci-static/resources/custom_logo.*") + if lo[1] then + logo = string.gsub(lo[1], "/www", "") end -end -require("luci.i18n").loadc("default") -require("luci.http").prepare_content("application/xhtml+xml") + local lon = fs.glob("/www/luci-static/resources/custom_logo_only.*") + if lon[1] then + logo = string.gsub(lon[1], "/www", "") + show_comm = false + end + local hea = fs.glob("/www/luci-static/resources/custom_header.*") + if hea[1] then + logo = string.gsub(hea[1], "/www", "") + show_comm = false + banner = true + end -%> @@ -69,7 +75,7 @@ require("luci.http").prepare_content("application/xhtml+xml") - + <% if node and node.css then %> <% end -%> @@ -118,87 +124,72 @@ require("luci.http").prepare_content("application/xhtml+xml") <%=luci.version.distversion%>
<%:Load%>: <%="%.2f" % load1%> <%="%.2f" % load5%> <%="%.2f" % load15%>
<%:Hostname%>: <%=hostname%>
- + <%end%> -