X-Git-Url: https://git.archive.openwrt.org/?p=project%2Fluci.git;a=blobdiff_plain;f=modules%2Ffreifunk%2Fluasrc%2Fview%2Ffreifunk%2Findex.htm;h=0fcec45971a1f2b6022b6d6fc21846e505adb1b1;hp=28900a7b943eb1a5c7fc166b390d071d6cf9e58e;hb=45d812dbb7b6374cd4188925661b74723cef91a7;hpb=f57f25fcb88a21bde5b899283731e924602718d5 diff --git a/modules/freifunk/luasrc/view/freifunk/index.htm b/modules/freifunk/luasrc/view/freifunk/index.htm index 28900a7b9..0fcec4597 100644 --- a/modules/freifunk/luasrc/view/freifunk/index.htm +++ b/modules/freifunk/luasrc/view/freifunk/index.htm @@ -15,19 +15,29 @@ $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") -if not ff.community.name then - ff.community.name = "" + +if not ff or not ff.community.name then + community = "Freifunk" + DefaultText = "" + nickname = "No Nickname set" +else + community = ff.community.name + DefaultText = ff.community.DefaultText + nickname = ff.contact.nickname end -local co = "profile_" .. ff.community.name -local community = uci:get_first(co, "community", "name") or "Freifunk" + +local co = "profile_" .. community +--local community = uci:get_first(co, "community", "name") or "Freifunk" 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 (ff.community.DefaultText or "") ~= "disabled" then +if DefaultText ~= "disabled" then defaulttext = '

'.. (translate("Hello and welcome in the network of")).. @@ -41,10 +51,10 @@ if (ff.community.DefaultText or "") ~= "disabled" then luci.sys.hostname().. '. '.. translate("It is operated by").. - ''.. - (ff.contact.nickname or translate("Please set your contact information")).. + (nickname or translate("Please set your contact information")).. '.

'.. translate("You can find further information about the global Freifunk initiative at").. ' Freifunk.net.
'.. @@ -60,4 +70,23 @@ 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 + table.insert(widgets, s) + end + end) + +for k, v in ipairs(widgets) do + if v['template'] and fs.access(dir .. "/" .. v['template'] .. "/main.htm") then + tpl.render("freifunk/widgets/" .. v['template'] .. "/main", { data = v }) + end +end + +%> <%+footer%>