2 LuCI - Lua Configuration Interface
4 Copyright 2008 Steven Barth <steven@midlink.org>
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
10 http://www.apache.org/licenses/LICENSE-2.0
12 $Id: freifunk.lua 3291 2008-09-14 21:59:14Z Cyrus $
15 local fs = require "luci.fs"
16 local util = require "luci.util"
17 local uci = require "luci.model.uci".cursor()
18 local profiles = "/etc/config/profile_"
20 m = Map("freifunk", "Freifunk")
21 c = m:section(NamedSection, "community", "public", "Gemeinschaft", [[Dies sind die Grundeinstellungen
22 für die lokale Freifunkgemeinschaft. Diese Werte wirken sich NICHT auf die Konfiguration
23 des Routers aus, sondern definieren nur die Vorgaben für den Freifunkassistenten.]])
25 community = c:option(ListValue, "name", "Gemeinschaft")
26 community.rmempty = false
29 local list = fs.glob(profiles .. "*")
31 for k,v in ipairs(list) do
32 local name = uci:get_first(v, "community", "name") or "?"
33 local n = string.gsub(v, profiles, "")
34 community:value(n, name)
37 n = Map("system", translate("Basic system settings"))
38 b = n:section(TypedSection, "system", "Basic system settings")
41 hn = b:option(Value, "hostname", "hostname")
43 function hn.validate(self, value)
46 elseif (#value > 24) or string.match(value, "[^%w%.%-]") or string.match(value, "^[%-%.]") or string.match(value, "[%-%.]$") then
47 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.")
53 loc = b:option(Value, "location", "Location")
56 lat = b:option(Value, "latitude", "latitude")
59 lon = b:option(Value, "longitude", "longitude")
63 Opens an OpenStreetMap iframe or popup
64 Makes use of resources/OSMLatLon.htm and htdocs/resources/osm.js
65 (is that the right place for files like these?)
68 local class = util.class
69 local co = "profile_augsburg"
70 local syslat = uci:get_first(co, "community", "latitude")
71 local syslon = uci:get_first(co, "community", "longitude")
73 OpenStreetMapLonLat = class(AbstractValue)
75 function OpenStreetMapLonLat.__init__(self, ...)
76 AbstractValue.__init__(self, ...)
77 self.template = "cbi/osmll_value"
83 self.width = "100%" --popups will ignore the %-symbol, "100%" is interpreted as "100"
86 self.displaytext="OpenStreetMap" --text on button, that loads and displays the OSMap
87 self.hidetext="X" -- text on button, that hides OSMap
91 f = SimpleForm("ffwizward", "OpenStreetMap", "Hier kann man die Geokoordinaten des Knotens herausfinden.")
93 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.")
96 osm.centerlat = syslat
97 osm.centerlon = syslon
102 syslatlengh = string.len(syslat)
103 if syslatlengh > 7 then
105 elseif syslatlengh > 5 then
111 osm.displaytext="OpenStreetMap anzeigen"
112 osm.hidetext="OpenStreetMap verbergen"