2011-01-25 21:04:57 +00:00
--[[
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
2011-01-28 23:31:10 +00:00
] ]
2011-01-25 21:04:57 +00:00
local fs = require " luci.fs "
local util = require " luci.util "
local uci = require " luci.model.uci " . cursor ( )
local profiles = " /etc/config/profile_ "
2011-01-28 23:31:10 +00:00
m = Map ( " freifunk " , translate ( " Community " ) )
2011-02-14 18:01:20 +00:00
c = m : section ( NamedSection , " community " , " public " , nil , translate ( " These are the basic settings for your local wireless community. These settings define the default values for the wizard and DO NOT affect the actual configuration of the router. " ) )
2011-01-25 21:04:57 +00:00
2011-01-28 23:31:10 +00:00
community = c : option ( ListValue , " name " , translate ( " Community " ) )
2011-01-25 21:04:57 +00:00
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 " ) )
2011-01-28 23:31:10 +00:00
b = n : section ( TypedSection , " system " )
2011-01-25 21:04:57 +00:00
b.anonymous = true
2011-02-02 10:55:38 +00:00
hn = b : option ( Value , " hostname " , translate ( " Hostname " ) )
2011-01-25 21:04:57 +00:00
hn.rmempty = false
2011-02-12 11:09:13 +00:00
hn.datatype = " hostname "
2011-01-25 21:04:57 +00:00
2011-02-02 10:55:38 +00:00
loc = b : option ( Value , " location " , translate ( " Location " ) )
2011-01-25 21:04:57 +00:00
loc.rmempty = false
2011-02-02 10:55:38 +00:00
lat = b : option ( Value , " latitude " , translate ( " Latitude " ) , translate ( " e.g. " ) .. " 48.12345 " )
2011-01-25 21:04:57 +00:00
lat.rmempty = false
2011-02-02 10:55:38 +00:00
lon = b : option ( Value , " longitude " , translate ( " Longitude " ) , translate ( " e.g. " ) .. " 10.12345 " )
2011-01-25 21:04:57 +00:00
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 ? )
] ] --
2011-02-02 10:55:38 +00:00
--[[ this needs to be fixed
2011-01-25 21:04:57 +00:00
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 "
2011-02-02 10:55:38 +00:00
] ]
2011-01-25 21:04:57 +00:00
return m , n