diff options
Diffstat (limited to 'modules/freifunk/luasrc')
9 files changed, 302 insertions, 57 deletions
diff --git a/modules/freifunk/luasrc/controller/freifunk/freifunk.lua b/modules/freifunk/luasrc/controller/freifunk/freifunk.lua index b9f551b1e4..154a29917b 100644 --- a/modules/freifunk/luasrc/controller/freifunk/freifunk.lua +++ b/modules/freifunk/luasrc/controller/freifunk/freifunk.lua @@ -17,6 +17,7 @@ function index() local i18n = luci.i18n.translate local uci = require "luci.model.uci".cursor() + -- Frontend local page = node() page.lock = true page.target = alias("freifunk") @@ -41,6 +42,7 @@ function index() local page = node("freifunk", "index", "contact") page.target = template("freifunk/contact") page.title = "Kontakt" + page.order = 10 local page = node("freifunk", "status") page.target = template("freifunk/public_status") @@ -60,22 +62,39 @@ function index() assign({"freifunk", "graph"}, {"admin", "statistics", "graph"}, i18n("Statistics"), 40) end - assign({"mini", "freifunk"}, {"admin", "freifunk"}, "Freifunk", 15) - entry({"admin", "freifunk"}, alias("admin", "freifunk", "index"), "Freifunk", 15) - local page = node("admin", "freifunk", "index") - page.target = cbi("freifunk/freifunk") + -- backend + assign({"mini", "freifunk"}, {"admin", "freifunk"}, "Freifunk", 5) + entry({"admin", "freifunk"}, alias("admin", "freifunk", "index"), "Freifunk", 5) + + local page = node("admin", "freifunk") + page.target = template("freifunk/adminindex") page.title = "Freifunk" - page.order = 30 + page.order = 5 + + local page = node("admin", "freifunk", "basics") + page.target = cbi("freifunk/basics") + page.title = "Grundeinstellungen" + page.order = 5 + + local page = node("admin", "freifunk", "basics", "profile") + page.target = cbi("freifunk/profile") + page.title = "Profile" + page.order = 10 + + local page = node("admin", "freifunk", "basics", "profile_expert") + page.target = cbi("freifunk/profile_expert") + page.title = "Profile (Expert)" + page.order = 20 local page = node("admin", "freifunk", "Index-Page") page.target = cbi("freifunk/user_index") page.title = "Index-Page" - page.order = 35 + page.order = 50 local page = node("admin", "freifunk", "contact") page.target = cbi("freifunk/contact") page.title = "Kontakt" - page.order = 40 + page.order = 15 entry({"freifunk", "map"}, template("freifunk-map/frame"), i18n("Karte"), 50) entry({"freifunk", "map", "content"}, template("freifunk-map/map"), nil, 51) @@ -85,7 +104,6 @@ function index() has_serv = true end end) - if has_serv then entry({"freifunk", "services"}, template("freifunk-services/services"), i18n("Services"), 60) end @@ -296,4 +314,3 @@ function public_status_json() luci.http.write_json(rv) return end - diff --git a/modules/freifunk/luasrc/model/cbi/freifunk/basics.lua b/modules/freifunk/luasrc/model/cbi/freifunk/basics.lua new file mode 100644 index 0000000000..1cd5c6d9c4 --- /dev/null +++ b/modules/freifunk/luasrc/model/cbi/freifunk/basics.lua @@ -0,0 +1,115 @@ +--[[ +LuCI - Lua Configuration Interface + +Copyright 2008 Steven Barth <steven@midlink.org> + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +$Id: freifunk.lua 3291 2008-09-14 21:59:14Z Cyrus $ +]]-- + +local fs = require "luci.fs" +local util = require "luci.util" +local uci = require "luci.model.uci".cursor() +local profiles = "/etc/config/profile_" + +m = Map("freifunk", "Freifunk") +c = m:section(NamedSection, "community", "public", "Gemeinschaft", [[Dies sind die Grundeinstellungen +für die lokale Freifunkgemeinschaft. Diese Werte wirken sich NICHT auf die Konfiguration +des Routers aus, sondern definieren nur die Vorgaben für den Freifunkassistenten.]]) + +community = c:option(ListValue, "name", "Gemeinschaft") +community.rmempty = false + +local list = { } +local list = fs.glob(profiles .. "*") + +for k,v in ipairs(list) do + local name = uci:get_first(v, "community", "name") or "?" + local n = string.gsub(v, profiles, "") + community:value(n, name) +end + +n = Map("system", translate("Basic system settings")) +b = n:section(TypedSection, "system", "Basic system settings") +b.anonymous = true + +hn = b:option(Value, "hostname", "hostname") +hn.rmempty = false +function hn.validate(self, value) + if value == nil then + return + elseif (#value > 24) or string.match(value, "[^%w%.%-]") or string.match(value, "^[%-%.]") or string.match(value, "[%-%.]$") then + return nil, translate("Hostname may contain up to 24 alphanumeric characters. Minus and period are also allowed, but not in the beginning or the end of the hostname.") + else + return value + end +end + +loc = b:option(Value, "location", "Location") +loc.rmempty = false + +lat = b:option(Value, "latitude", "latitude") +lat.rmempty = false + +lon = b:option(Value, "longitude", "longitude") +lon.rmempty = false + +--[[ +Opens an OpenStreetMap iframe or popup +Makes use of resources/OSMLatLon.htm and htdocs/resources/osm.js +(is that the right place for files like these?) +]]-- + +local class = util.class +local co = "profile_augsburg" +local syslat = uci:get_first(co, "community", "latitude") +local syslon = uci:get_first(co, "community", "longitude") + +OpenStreetMapLonLat = class(AbstractValue) + +function OpenStreetMapLonLat.__init__(self, ...) + AbstractValue.__init__(self, ...) + self.template = "cbi/osmll_value" + self.latfield = nil + self.lonfield = nil + self.centerlat = "" + self.centerlon = "" + self.zoom = "0" + self.width = "100%" --popups will ignore the %-symbol, "100%" is interpreted as "100" + self.height = "600" + self.popup = false + self.displaytext="OpenStreetMap" --text on button, that loads and displays the OSMap + self.hidetext="X" -- text on button, that hides OSMap +end + + +f = SimpleForm("ffwizward", "OpenStreetMap", "Hier kann man die Geokoordinaten des Knotens herausfinden.") + +osm = f:field(OpenStreetMapLonLat, "latlon", "Geokoordinaten mit OpenStreetMap ermitteln:", "Klicken Sie auf Ihren Standort in der Karte. Diese Karte funktioniert nur, wenn das Gerät bereits eine Verbindung zum Internet hat.") +osm.latfield = "lat" +osm.lonfield = "lon" +osm.centerlat = syslat +osm.centerlon = syslon +osm.width = "100%" +osm.height = "600" +osm.popup = false + +syslatlengh = string.len(syslat) +if syslatlengh > 7 then + osm.zoom = "15" +elseif syslatlengh > 5 then + osm.zoom = "12" +else + osm.zoom = "6" +end + +osm.displaytext="OpenStreetMap anzeigen" +osm.hidetext="OpenStreetMap verbergen" + + +return m, n diff --git a/modules/freifunk/luasrc/model/cbi/freifunk/contact.lua b/modules/freifunk/luasrc/model/cbi/freifunk/contact.lua index c976409c65..178df28b85 100644 --- a/modules/freifunk/luasrc/model/cbi/freifunk/contact.lua +++ b/modules/freifunk/luasrc/model/cbi/freifunk/contact.lua @@ -18,17 +18,17 @@ m = Map("freifunk", translate("Contact"), translate("Please fill in your contact c = m:section(NamedSection, "contact", "public", "") -c:option(Value, "nickname", translate("Nickname")) -c:option(Value, "name", translate("Realname")) -c:option(Value, "mail", translate("E-Mail"), translate("You really should provide your address here!")) -c:option(Value, "phone", translate("Phone")) -c:option(Value, "location", translate("Location")) -c:option(Value, "note", translate("Notice")) +local nick = c:option(Value, "nickname", translate("Nickname")) +nick.rmempty = false + +name = c:option(Value, "name", translate("Realname")) +name.rmempty = false -m2 = Map("system", translate("Coordinates")) +mail = c:option(Value, "mail", translate("E-Mail")) +mail.rmempty = false -s = m2:section(TypedSection, "system", "") -s:option(Value, "latitude", translate("Latitude")).rmempty = true -s:option(Value, "longitude", translate("Longitude")).rmempty = true +c:option(Value, "phone", translate("Phone")) + +c:option(Value, "note", translate("Notice")) -return m, m2 +return m diff --git a/modules/freifunk/luasrc/model/cbi/freifunk/freifunk.lua b/modules/freifunk/luasrc/model/cbi/freifunk/freifunk.lua deleted file mode 100644 index 1a147460b7..0000000000 --- a/modules/freifunk/luasrc/model/cbi/freifunk/freifunk.lua +++ /dev/null @@ -1,24 +0,0 @@ ---[[ -LuCI - Lua Configuration Interface - -Copyright 2008 Steven Barth <steven@midlink.org> - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -$Id$ -]]-- -m = Map("freifunk", "Freifunk") - -c = m:section(NamedSection, "community", "public", "Gemeinschaft", [[Dies sind die Grundeinstellungen -für die lokale Freifunkgemeinschaft. Diese Werte wirken sich NICHT auf die Konfiguration -des Routers aus, sondern definieren nur die Vorgaben für den Freifunkassistenten.]]) -c:option(Value, "name", "Gemeinschaft") -c:option(Value, "homepage", "Webseite") -c:option(Value, "ssid", "ESSID") -c:option(Value, "prefix", "Netzprefix") - -return m
\ No newline at end of file diff --git a/modules/freifunk/luasrc/model/cbi/freifunk/profile.lua b/modules/freifunk/luasrc/model/cbi/freifunk/profile.lua new file mode 100644 index 0000000000..87ec03c7e7 --- /dev/null +++ b/modules/freifunk/luasrc/model/cbi/freifunk/profile.lua @@ -0,0 +1,55 @@ +--[[ +LuCI - Lua Configuration Interface + +Copyright 2011 Manuel Munz <freifunk at somakoma dot de> + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + httc://www.apache.org/licenses/LICENSE-2.0 +]]-- + +local uci = require "luci.model.uci".cursor() +local community = "profile_" .. uci:get("freifunk", "community", "name") +--local community = "profile_augsburg" + + +m = Map(community, translate("Community settings"), translate("These are the settings of your local community")) + +c = m:section(NamedSection, "profile", "community", "foobar") + +name = c:option(Value, "name", "Name") +name.rmempty = false + +homepage = c:option(Value, "homepage", "Webseite") + +cc = c:option(Value, "country", "Countrycode") +function cc.cfgvalue(self, section) + return uci:get(community, "wifi_device", "country") +end +function cc.write(self, sec, value) + if value then + uci:set(community, "wifi_device", "country", value) + uci:save(community) + end +end + +ssid = c:option(Value, "ssid", "ESSID") +ssid.rmempty = false + +prefix = c:option(Value, "mesh_network", "Netzprefix") +prefix.rmempty = false + +splash_net = c:option(Value, "splash_network", "Netzwerk für Client-DHCP-Adressen") +splash_net.rmempty = false + +splash_prefix = c:option(Value, "splash_prefix", "Netzgröße für Clientnetze") +splash_prefix.rmempty = false + +lat = c:option(Value, "latitude", "Latitude") +lat.rmempty = false + +lon = c:option(Value, "longitude", "longitude") +lon.rmempty = false +return m diff --git a/modules/freifunk/luasrc/model/cbi/freifunk/profile_expert.lua b/modules/freifunk/luasrc/model/cbi/freifunk/profile_expert.lua new file mode 100644 index 0000000000..5da7e7b121 --- /dev/null +++ b/modules/freifunk/luasrc/model/cbi/freifunk/profile_expert.lua @@ -0,0 +1,36 @@ +--[[ +LuCI - Lua Configuration Interface + +Copyright 2011 Manuel Munz <freifunk at somakoma dot de> + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + httc://www.apache.org/licenses/LICENSE-2.0 +]]-- + +local fs = require "nixio.fs" +local uci = require "luci.model.uci".cursor() +local community = "/etc/config/profile_" .. uci:get("freifunk", "community", "name") + +f = SimpleForm("community", translate("Community profile"), translate("This is the complete content of the selected community profile.")) + +t = f:field(TextValue, "cop") +t.rmempty = true +t.rows = 30 +function t.cfgvalue() + return fs.readfile(community) or "" +end + +function f.handle(self, state, data) + if state == FORM_VALID then + if data.cop then + fs.writefile(cop, data.rcs:gsub("\r\n", "\n")) + end + end + return true +end + +return f + diff --git a/modules/freifunk/luasrc/view/freifunk/adminindex.htm b/modules/freifunk/luasrc/view/freifunk/adminindex.htm new file mode 100644 index 0000000000..d2bf0b7eaa --- /dev/null +++ b/modules/freifunk/luasrc/view/freifunk/adminindex.htm @@ -0,0 +1,33 @@ +<%+header%> +<% +local uci = require "luci.model.uci".cursor() +local contact = uci:get_all("freifunk", "contact") +local contacturl = luci.dispatcher.build_url(luci.dispatcher.context.path[1], "freifunk", "contact") +local hostname = uci:get_first ("system", "system", "hostname") +local latitude = uci:get_first ("system", "system", "latitude") +local longitude = uci:get_first ("system", "system", "longitude") +local location = uci:get_first ("system", "system", "location") +local basicsurl = luci.dispatcher.build_url(luci.dispatcher.context.path[1], "freifunk", "basics") +%> + +<h2><%:Freifunk Overview%></h2> + +<%:These pages will assist you in setting up your router for Freifunk or similar wireless community networks.%> +<p /> + +<% if not (hostname and latitude and longitude and location) then%> +<div class="error"> + <%:Basic settings are missing. Please go to this page and fill all required fields: %> + <a href='<%=basicsurl%>'><%:Basic settings%></a> +</div> +<%end%> +<p /> + +<% if not (contact.nickname and contact.name and contact.mail) then%> +<div class="error"> + <%:Contact information missing. Please go to this page and fill all required fields: %> + <a href='<%=contacturl%>'><%:Contact%></a> +</div> +<%end%> + +<%+footer%> diff --git a/modules/freifunk/luasrc/view/freifunk/contact.htm b/modules/freifunk/luasrc/view/freifunk/contact.htm index 0b4a068108..0d917ad5b6 100644 --- a/modules/freifunk/luasrc/view/freifunk/contact.htm +++ b/modules/freifunk/luasrc/view/freifunk/contact.htm @@ -13,15 +13,23 @@ $Id$ -%> <%+header%> -<% local contact = luci.model.uci.cursor():get_all("freifunk", "contact") %> + +<% +local uci = require "luci.model.uci".cursor() +local contact = uci:get_all("freifunk", "contact") +local location = uci:get_first("system", "system", "location") +local lon = uci:get_first("system", "system", "longitude") +local lat = uci:get_first("system", "system", "latitude") +%> + <h2><a id="content" name="content"><%:Contact%></a></h2> <table cellspacing="0" cellpadding="6"> <tr><th><%:Nickname%>:</th><td><%=contact.nickname%></td></tr> <tr><th><%:Realname%>:</th><td><%=contact.name%></td></tr> <tr><th><%:E-Mail%>:</th><td><%=contact.mail%></td></tr> <tr><th><%:Phone%>:</th><td><%=contact.phone%></td></tr> - <tr><th><%:Location%>:</th><td><%=contact.location%></td></tr> - <tr><th><%:Coordinates%>:</th><td><%=contact.geo%></td></tr> + <tr><th><%:Location%>:</th><td><%=location%></td></tr> + <tr><th><%:Coordinates%>:</th><td><%=lat%> <%=lon%></td></tr> <tr><th><%:Notice%>:</th><td><%=contact.note%></td></tr> </table> <%+footer%> diff --git a/modules/freifunk/luasrc/view/freifunk/index.htm b/modules/freifunk/luasrc/view/freifunk/index.htm index d93dcd8f45..4a9ab2efe1 100644 --- a/modules/freifunk/luasrc/view/freifunk/index.htm +++ b/modules/freifunk/luasrc/view/freifunk/index.htm @@ -14,7 +14,16 @@ $Id$ -%> <%+header%> <% -local ff = luci.model.uci.cursor():get_all("freifunk") +local uci = require "luci.model.uci".cursor() +local ff = uci:get_all("freifunk") +if not ff.community.name then + ff.community.name = "" +end +local co = "profile_" .. ff.community.name +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") @@ -23,7 +32,7 @@ if (ff.community.DefaultText or "") ~= "disabled" then defaulttext = '<h2><a id="content" name="content">'.. (translate("Hello and welcome in the network of")).. ' '.. - (ff.community.name or "Freifunk Deutschland").. + (community or "Freifunk Deutschland").. '!</a></h2><p>'.. translate("We are an initiative to establish a free, independent and open wireless mesh network.").. '<br />'.. @@ -31,20 +40,16 @@ if (ff.community.DefaultText or "") ~= "disabled" then ' '.. luci.sys.hostname().. '. '.. - translate("It is operated by").. + translate("It is operated by ").. '<a href="'.. luci.dispatcher.build_url("freifunk", "index", "contact").. - '"> '.. - (ff.contact.nickname or "Anonymous").. + '">'.. + (ff.contact.nickname or translate("Please set your contact information")).. '</a>.</p><p>'.. translate("You can find further information about the global Freifunk initiative at").. ' <a href="http://freifunk.net">Freifunk.net</a>.<br />'.. translate("If you are interested in our project then contact the local community").. - ' <a href="'.. - (ff.community.homepage or "http//freifunk.net").. - '">'.. - (ff.community.name or "Freifunk").. - '</a>.</p><p><strong>'.. + ' <a href="'..url..'">'..community..'</a>.</p><p><strong>'.. translate("Notice").. '</strong>: '.. translate("Internet access depends on technical and organisational conditions and may or may not work for you.").. |