summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorManuel Munz <freifunk@somakoma.de>2012-09-17 14:22:14 +0000
committerManuel Munz <freifunk@somakoma.de>2012-09-17 14:22:14 +0000
commit613de9b48f0aa8bf7fb170080d4ceb103702425d (patch)
treed56320a9bf969c0a79abf94aa6b6d22e9ff87ba6
parent745920eb08b63944ea03cb140dbe4033d7467973 (diff)
modules/freifunk: include widgets in indexpage when available
-rw-r--r--modules/freifunk/luasrc/view/freifunk/index.htm29
1 files changed, 27 insertions, 2 deletions
diff --git a/modules/freifunk/luasrc/view/freifunk/index.htm b/modules/freifunk/luasrc/view/freifunk/index.htm
index e13d7f9c2..d1862bd3a 100644
--- a/modules/freifunk/luasrc/view/freifunk/index.htm
+++ b/modules/freifunk/luasrc/view/freifunk/index.htm
@@ -15,6 +15,8 @@ $Id$
<%+header%>
<%
local uci = require "luci.model.uci".cursor()
+local tpl = require "luci.template"
+local fs = require "luci.fs"
local ff = {}
local ff = uci:get_all("freifunk")
@@ -33,8 +35,7 @@ local co = "profile_" .. community
local url = uci:get_first(co, "community", "homepage") or "http://www.freifunk.net"
-require("luci.fs")
-local usertext = luci.fs.readfile("/www/luci-static/index_user.html")
+local usertext = fs.readfile("/www/luci-static/index_user.html")
if DefaultText ~= "disabled" then
@@ -69,4 +70,28 @@ end
<%=defaulttext%>
<%=usertext%>
+<%
+-- add custom widgets from view/freifunk/widgets
+local widgets = {}
+local dir = "/usr/lib/lua/luci/view/freifunk/widgets"
+
+uci:foreach("freifunk-widgets", "widget",
+ function(s)
+ if s.enabled == "1" then
+ local name = s[".name"]
+ widgets[name] = s
+ end
+ end)
+
+local function cmp(a, b)
+ return (widgets[a].order or 100) > (widgets[b].order or 100)
+end
+
+for k, v in luci.util.spairs(widgets, function(a,b) return (tonumber(widgets[a].order) < tonumber(widgets[b].order)) end) do
+ if v['template'] and fs.access(dir .. "/" .. v['template'] .. "/main.htm") then
+ tpl.render("freifunk/widgets/" .. v['template'] .. "/main", { name = k, data = v })
+ end
+end
+
+%>
<%+footer%>