diff options
author | Manuel Munz <freifunk@somakoma.de> | 2011-02-19 14:54:16 +0000 |
---|---|---|
committer | Manuel Munz <freifunk@somakoma.de> | 2011-02-19 14:54:16 +0000 |
commit | 1a87c7b347da6dfdec72df261140c5b46088fdc5 (patch) | |
tree | 5b5ec93fc0e1bedae266d4114990ace1b0b31122 /modules/freifunk/luasrc | |
parent | f9563981b85a91b8d5b338de0c7b6fc2a20da88c (diff) |
modules/freifunk: Change default netmask to 255.255.0.0, change non-working dns, show error when user tries to edit profiles but there is no profile set yet
Diffstat (limited to 'modules/freifunk/luasrc')
4 files changed, 68 insertions, 49 deletions
diff --git a/modules/freifunk/luasrc/controller/freifunk/freifunk.lua b/modules/freifunk/luasrc/controller/freifunk/freifunk.lua index f3538a1f1..e8cd19b65 100644 --- a/modules/freifunk/luasrc/controller/freifunk/freifunk.lua +++ b/modules/freifunk/luasrc/controller/freifunk/freifunk.lua @@ -98,6 +98,7 @@ function index() entry({"freifunk", "map"}, template("freifunk-map/frame"), i18n("Map"), 50) entry({"freifunk", "map", "content"}, template("freifunk-map/map"), nil, 51) + entry({"admin", "freifunk", "profile_error"}, template("freifunk/profile_error")) end local function fetch_olsrd() diff --git a/modules/freifunk/luasrc/model/cbi/freifunk/profile.lua b/modules/freifunk/luasrc/model/cbi/freifunk/profile.lua index 54e32b685..5e5cc21da 100644 --- a/modules/freifunk/luasrc/model/cbi/freifunk/profile.lua +++ b/modules/freifunk/luasrc/model/cbi/freifunk/profile.lua @@ -11,45 +11,48 @@ You may obtain a copy of the License at ]]-- local uci = require "luci.model.uci".cursor() -local community = "profile_" .. uci:get("freifunk", "community", "name") ---local community = "profile_augsburg" +local community = uci:get("freifunk", "community", "name") +if community == nil then + luci.http.redirect(luci.dispatcher.build_url("admin", "freifunk", "profile_error")) + return +else + community = "profile_" .. community + m = Map(community, translate("Community settings"), translate("These are the settings of your local community.")) + c = m:section(NamedSection, "profile", "community") -m = Map(community, translate("Community settings"), translate("These are the settings of your local community.")) + name = c:option(Value, "name", "Name") + name.rmempty = false -c = m:section(NamedSection, "profile", "community") + homepage = c:option(Value, "homepage", translate("Homepage")) -name = c:option(Value, "name", "Name") -name.rmempty = false - -homepage = c:option(Value, "homepage", translate("Homepage")) - -cc = c:option(Value, "country", translate("Country code")) -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) + cc = c:option(Value, "country", translate("Country code")) + 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 -end -ssid = c:option(Value, "ssid", translate("ESSID")) -ssid.rmempty = false + ssid = c:option(Value, "ssid", translate("ESSID")) + ssid.rmempty = false -prefix = c:option(Value, "mesh_network", translate("Mesh prefix")) -prefix.rmempty = false + prefix = c:option(Value, "mesh_network", translate("Mesh prefix")) + prefix.rmempty = false -splash_net = c:option(Value, "splash_network", translate("Network for client DHCP addresses")) -splash_net.rmempty = false + splash_net = c:option(Value, "splash_network", translate("Network for client DHCP addresses")) + splash_net.rmempty = false -splash_prefix = c:option(Value, "splash_prefix", translate("Client network size")) -splash_prefix.rmempty = false + splash_prefix = c:option(Value, "splash_prefix", translate("Client network size")) + splash_prefix.rmempty = false -lat = c:option(Value, "latitude", translate("Latitude")) -lat.rmempty = false + lat = c:option(Value, "latitude", translate("Latitude")) + lat.rmempty = false -lon = c:option(Value, "longitude", translate("Longitude")) -lon.rmempty = false -return m + lon = c:option(Value, "longitude", translate("Longitude")) + lon.rmempty = false + return m +end diff --git a/modules/freifunk/luasrc/model/cbi/freifunk/profile_expert.lua b/modules/freifunk/luasrc/model/cbi/freifunk/profile_expert.lua index d737132b0..a0b8f34bc 100644 --- a/modules/freifunk/luasrc/model/cbi/freifunk/profile_expert.lua +++ b/modules/freifunk/luasrc/model/cbi/freifunk/profile_expert.lua @@ -12,26 +12,30 @@ You may obtain a copy of the License at 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("You can manually edit the selected community profile here.")) - -t = f:field(TextValue, "cop") -t.rmempty = true -t.rows = 30 -function t.cfgvalue() - return fs.readfile(community) or "" -end +local community = uci:get("freifunk", "community", "name") + +if community == nil then + luci.http.redirect(luci.dispatcher.build_url("admin", "freifunk", "profile_error")) + return +else + community = "/etc/config/profile_" .. community + f = SimpleForm("community", translate("Community profile"), translate("You can manually edit the selected community profile here.")) + + 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")) + 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 true + return f end -return f - diff --git a/modules/freifunk/luasrc/view/freifunk/profile_error.htm b/modules/freifunk/luasrc/view/freifunk/profile_error.htm new file mode 100644 index 000000000..984fa0acf --- /dev/null +++ b/modules/freifunk/luasrc/view/freifunk/profile_error.htm @@ -0,0 +1,11 @@ +<%+header%> + +<% +local profileurl = luci.dispatcher.build_url(luci.dispatcher.context.path[1], "freifunk", "basics") +%> + +<h2><%:Error%></h2> +<%:You need to select a profile before you can edit it. To select a profile go to%> <a href='<%=profileurl%>'><%:Basic settings%></a>. +<p/> + +<%+footer%> |