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
13 local fs = require "luci.fs"
14 local util = require "luci.util"
15 local uci = require "luci.model.uci".cursor()
16 local profiles = "/etc/config/profile_"
18 m = Map("freifunk", translate ("Community"))
19 c = m:section(NamedSection, "community", "public", nil, translate([[These are the basic
20 settings for your local wireless community. These settings define the default values for the wizard
21 and DO NOT affect the actual configuration of the router.]]))
23 community = c:option(ListValue, "name", translate ("Community"))
24 community.rmempty = false
27 local list = fs.glob(profiles .. "*")
29 for k,v in ipairs(list) do
30 local name = uci:get_first(v, "community", "name") or "?"
31 local n = string.gsub(v, profiles, "")
32 community:value(n, name)
35 n = Map("system", translate("Basic system settings"))
36 b = n:section(TypedSection, "system")
39 hn = b:option(Value, "hostname", translate("Hostname"))
41 hn.datatype = "hostname"
43 loc = b:option(Value, "location", translate("Location"))
46 lat = b:option(Value, "latitude", translate("Latitude"), translate("e.g.") .. " 48.12345")
49 lon = b:option(Value, "longitude", translate("Longitude"), translate("e.g.") .. " 10.12345")
53 Opens an OpenStreetMap iframe or popup
54 Makes use of resources/OSMLatLon.htm and htdocs/resources/osm.js
55 (is that the right place for files like these?)
58 --[[ this needs to be fixed
59 local class = util.class
60 local co = "profile_augsburg"
61 local syslat = uci:get_first(co, "community", "latitude")
62 local syslon = uci:get_first(co, "community", "longitude")
64 OpenStreetMapLonLat = class(AbstractValue)
66 function OpenStreetMapLonLat.__init__(self, ...)
67 AbstractValue.__init__(self, ...)
68 self.template = "cbi/osmll_value"
74 self.width = "100%" --popups will ignore the %-symbol, "100%" is interpreted as "100"
77 self.displaytext="OpenStreetMap" --text on button, that loads and displays the OSMap
78 self.hidetext="X" -- text on button, that hides OSMap
82 f = SimpleForm("ffwizward", "OpenStreetMap", "Hier kann man die Geokoordinaten des Knotens herausfinden.")
84 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.")
87 osm.centerlat = syslat
88 osm.centerlon = syslon
93 syslatlengh = string.len(syslat)
94 if syslatlengh > 7 then
96 elseif syslatlengh > 5 then
102 osm.displaytext="OpenStreetMap anzeigen"
103 osm.hidetext="OpenStreetMap verbergen"