luci-mod-freifunk: fix lookup of community-name
[project/luci.git] / modules / luci-mod-freifunk / luasrc / model / cbi / freifunk / basics.lua
index 28f86b6..b08366d 100644 (file)
@@ -1,20 +1,11 @@
---[[
-LuCI - Lua Configuration Interface
-
-Copyright 2008 Steven Barth <steven@midlink.org>
-Copyright 2011 Manuel Munz <freifunk at somakoma 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
-
-       http://www.apache.org/licenses/LICENSE-2.0
-]]
+-- Copyright 2008 Steven Barth <steven@midlink.org>
+-- Copyright 2011 Manuel Munz <freifunk at somakoma de>
+-- Licensed to the public under the Apache License 2.0.
 
 local fs = require "nixio.fs"
 local util = require "luci.util"
 local uci = require "luci.model.uci".cursor()
 
 local fs = require "nixio.fs"
 local util = require "luci.util"
 local uci = require "luci.model.uci".cursor()
-local profiles = "/etc/config/profile_"
+local profiles = "/etc/config/profile_*"
 
 m = Map("freifunk", translate ("Community"))
 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."))
 
 m = Map("freifunk", translate ("Community"))
 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."))
@@ -23,9 +14,9 @@ community = c:option(ListValue, "name", translate ("Community"))
 community.rmempty = false
 
 local profile
 community.rmempty = false
 
 local profile
-for profile in fs.dir(profiles) do
+for profile in fs.glob(profiles) do
        local name = uci:get_first(profile, "community", "name") or "?"
        local name = uci:get_first(profile, "community", "name") or "?"
-       community:value(profile, name)
+       community:value(string.gsub(profile, "/etc/config/profile_", ""), name)
 end
 
 
 end