diff options
author | Steven Barth <steven@midlink.org> | 2008-06-05 19:16:38 +0000 |
---|---|---|
committer | Steven Barth <steven@midlink.org> | 2008-06-05 19:16:38 +0000 |
commit | dd9606825da5d73883b8313f5af905ea1b2a4d7d (patch) | |
tree | 1f853ae56dd8e3051698ac6d0a38d61bf6d6997f /modules | |
parent | 75f3dbaa6136a1288fbe92d80fc127f5228f5d64 (diff) |
* Merged Luci to use native UCI-library
Diffstat (limited to 'modules')
11 files changed, 53 insertions, 64 deletions
diff --git a/modules/admin-core/luasrc/controller/admin/system.lua b/modules/admin-core/luasrc/controller/admin/system.lua index d449f48017..81034fddfa 100644 --- a/modules/admin-core/luasrc/controller/admin/system.lua +++ b/modules/admin-core/luasrc/controller/admin/system.lua @@ -1,12 +1,5 @@ module("luci.controller.admin.system", package.seeall) -require("luci.sys") -require("luci.http") -require("luci.util") -require("luci.fs") -require("luci.model.ipkg") -require("luci.model.uci") - function index() luci.i18n.loadc("admin-core") local i18n = luci.i18n.translate @@ -65,7 +58,7 @@ function action_ipkg() end function action_packages() - local ipkg = luci.model.ipkg + local ipkg = require("luci.model.ipkg") local void = nil local submit = luci.http.formvalue("submit") @@ -190,6 +183,7 @@ function action_sshkeys() end function action_upgrade() + require("luci.model.uci") local ret = nil local plat = luci.fs.mtime("/lib/upgrade/platform.sh") @@ -199,7 +193,7 @@ function action_upgrade() if plat and image then local kpattern = nil if keepcfg then - local files = luci.model.uci.sections("luci").flash_keep + local files = luci.model.uci.get_all("luci", "flash_keep") if files.luci and files.luci.flash_keep then kpattern = "" for k,v in pairs(files.luci.flash_keep) do diff --git a/modules/admin-core/luasrc/controller/admin/uci.lua b/modules/admin-core/luasrc/controller/admin/uci.lua index e9209da6ed..bb8a39185c 100644 --- a/modules/admin-core/luasrc/controller/admin/uci.lua +++ b/modules/admin-core/luasrc/controller/admin/uci.lua @@ -3,7 +3,7 @@ require("luci.util") require("luci.sys") function index() - node("admin", "uci", "changes").target = template("admin_uci/changes") + node("admin", "uci", "changes").target = call("action_changes") node("admin", "uci", "revert").target = call("action_revert") node("admin", "uci", "apply").target = call("action_apply") end @@ -21,7 +21,7 @@ function convert_changes(changes) str = "" val = "="..v end - str = str.."."..r + str = r.."."..s if o ~= ".type" then str = str.."."..o end @@ -29,9 +29,14 @@ function convert_changes(changes) end end end + return table.concat(ret, "\n") +end + +function action_changes() + local changes = convert_changes(luci.model.uci.changes()) + luci.template.render("admin_uci/changes", {changes=changes}) end --- This function has a higher priority than the admin_uci/apply template function action_apply() local changes = luci.model.uci.changes() local output = "" @@ -43,19 +48,15 @@ function action_apply() -- Collect files to be applied and commit changes for r, tbl in pairs(changes) do if r then - com[r] = true - + luci.model.uci.load(r) + luci.model.uci.commit(r) + luci.model.uci.unload(r) if luci.config.uci_oncommit and luci.config.uci_oncommit[r] then run[luci.config.uci_oncommit[r]] = true end end end - -- Apply - for config, i in pairs(com) do - luci.model.uci.commit(config) - end - -- Search for post-commit commands for cmd, i in pairs(run) do output = output .. cmd .. ":" .. luci.sys.exec(cmd) .. "\n" @@ -73,15 +74,10 @@ function action_revert() local revert = {} -- Collect files to be reverted - for r, tbl in ipairs(changes) do - if r then - revert[r] = true - end - end - - -- Revert them - for k, v in pairs(revert) do - luci.model.uci.revert(k) + for r, tbl in pairs(changes) do + luci.model.uci.load(r) + luci.model.uci.revert(r) + luci.model.uci.unload(r) end end diff --git a/modules/admin-core/luasrc/model/cbi/admin_network/dhcp.lua b/modules/admin-core/luasrc/model/cbi/admin_network/dhcp.lua index 63ef0aa3d7..88a8ea5975 100644 --- a/modules/admin-core/luasrc/model/cbi/admin_network/dhcp.lua +++ b/modules/admin-core/luasrc/model/cbi/admin_network/dhcp.lua @@ -10,12 +10,13 @@ s.addremove = true s.anonymous = true iface = s:option(ListValue, "interface", "Schnittstelle") -for k, v in pairs(luci.model.uci.sections("network")) do - if v[".type"] == "interface" and k ~= "loopback" then - iface:value(k) - s:depends("interface", k) -- Only change sections with existing interfaces - end -end +luci.model.uci.foreach("network", "interface", + function (section) + if section[".name"] ~= "loopback" then + iface:value(section[".name"]) + s:depends("interface", section[".name"]) + end + end) s:option(Value, "start", "Start", "Erste vergebene Adresse (letztes Oktett)").rmempty = true diff --git a/modules/admin-core/luasrc/model/cbi/admin_network/routes.lua b/modules/admin-core/luasrc/model/cbi/admin_network/routes.lua index a2a27eb265..a7af2915de 100644 --- a/modules/admin-core/luasrc/model/cbi/admin_network/routes.lua +++ b/modules/admin-core/luasrc/model/cbi/admin_network/routes.lua @@ -9,11 +9,12 @@ s.anonymous = true s.template = "cbi/tblsection" iface = s:option(ListValue, "interface", "Schnittstelle") -for k, v in pairs(luci.model.uci.sections("network")) do - if v[".type"] == "interface" and k ~= "loopback" then - iface:value(k) - end -end +luci.model.uci.foreach("network", "interface", + function (section) + if section[".name"] ~= "loopback" then + iface:value(section[".name"]) + end + end) s:option(Value, "target", "Ziel", "Host-IP oder Netzwerk") diff --git a/modules/admin-core/luasrc/model/cbi/admin_services/olsrd.lua b/modules/admin-core/luasrc/model/cbi/admin_services/olsrd.lua index a1a1978086..3e3c68dff5 100644 --- a/modules/admin-core/luasrc/model/cbi/admin_services/olsrd.lua +++ b/modules/admin-core/luasrc/model/cbi/admin_services/olsrd.lua @@ -51,11 +51,12 @@ i.dynamic = true network = i:option(ListValue, "Interface", "Netzwerkschnittstellen") network:value("") -for k, v in pairs(luci.model.uci.sections("network")) do - if v[".type"] == "interface" and k ~= "loopback" then - network:value(k) - end -end +luci.model.uci.foreach("network", "interface", + function (section) + if section[".name"] ~= "loopback" then + network:value(section[".name"]) + end + end) i:option(Value, "HelloInterval", "Hello-Intervall") diff --git a/modules/admin-core/luasrc/model/cbi/admin_wifi/networks.lua b/modules/admin-core/luasrc/model/cbi/admin_wifi/networks.lua index afcca4c16b..542e72a53f 100644 --- a/modules/admin-core/luasrc/model/cbi/admin_wifi/networks.lua +++ b/modules/admin-core/luasrc/model/cbi/admin_wifi/networks.lua @@ -11,22 +11,19 @@ s.anonymous = true s:option(Value, "ssid", translate("a_w_netid", "Netzkennung (ESSID)")).maxlength = 32 device = s:option(ListValue, "device", translate("device", "Gerät")) -local d = luci.model.uci.sections("wireless") -if d then - for k, v in pairs(d) do - if v[".type"] == "wifi-device" then - device:value(k) - end - end -end +luci.model.uci.foreach("wireless", "wifi-device", + function (section) + device:value(section[".name"]) + end) network = s:option(ListValue, "network", translate("network", "Netzwerk"), translate("a_w_network1", "WLAN-Netz zu Netzwerk hinzufügen")) network:value("") -for k, v in pairs(luci.model.uci.sections("network")) do - if v[".type"] == "interface" and k ~= "loopback" then - network:value(k) - end -end +luci.model.uci.foreach("network", "interface", + function (section) + if section[".name"] ~= "loopback" then + network:value(section[".name"]) + end + end) mode = s:option(ListValue, "mode", translate("mode", "Modus")) mode:value("ap", "Access Point") diff --git a/modules/admin-core/luasrc/view/about.htm b/modules/admin-core/luasrc/view/about.htm index c6dd1a1015..1046d8023b 100644 --- a/modules/admin-core/luasrc/view/about.htm +++ b/modules/admin-core/luasrc/view/about.htm @@ -10,12 +10,12 @@ speziell Netzwerkrouter unter OpenWRT. Luci steht unter der Apache-Lizenz.%></p> <ul style="font-weight: bold"> <li><a href="mailto:steven-at-midlink-dot-org">Steven "Cyrus" Barth</a> (OpenWRT, Freifunk Halle)</li> <li><a href="mailto:xm-at-leipzig.freifunk-dot-net">Jo-Philipp "Jow" Wich</a> (Freifunk Leipzig)</li> + <li><a href="mailto:nbd-at-openwrt-dot-org">Felix "nbd" Fietkau</a> (OpenWRT)</li> </ul> <br /> <h2><%:c_contributors Mitwirkende Entwickler%></h2> <ul style="font-weight: bold"> - <li><a href="mailto:nbd-at-openwrt-dot-org">Felix "nbd" Fietkau</a> (OpenWRT)</li> </ul> <br /> diff --git a/modules/admin-core/luasrc/view/admin_uci/changes.htm b/modules/admin-core/luasrc/view/admin_uci/changes.htm index 43a48e3fcb..002c0236df 100644 --- a/modules/admin-core/luasrc/view/admin_uci/changes.htm +++ b/modules/admin-core/luasrc/view/admin_uci/changes.htm @@ -1,7 +1,7 @@ <%+header%> <h1><%:config Konfiguration%></h1> <h2><%:changes Änderungen%></h2> -<code><%=luci.model.uci.changes()%></code> +<code><%=changes%></code> <form class="inline" method="get" action="<%=controller%>/admin/uci/apply"> <input type="submit" value="<%:apply Anwenden%>" /> </form> diff --git a/modules/freifunk/luasrc/controller/freifunk/luciinfo.lua b/modules/freifunk/luasrc/controller/freifunk/luciinfo.lua index c4c6276018..f7cbbf0639 100644 --- a/modules/freifunk/luasrc/controller/freifunk/luciinfo.lua +++ b/modules/freifunk/luasrc/controller/freifunk/luciinfo.lua @@ -5,8 +5,7 @@ function index() end function action_index() - local uci = luci.model.uci.StateSession() - + local uci = luci.model.uci luci.http.prepare_content("text/plain") -- General @@ -30,7 +29,7 @@ function action_index() -- Freifunk - local ff = uci:sections("freifunk") or {} + local ff = uci.get_all("freifunk") or {} for k, v in pairs(ff) do for i, j in pairs(v) do if i:sub(1, 1) ~= "." then diff --git a/modules/freifunk/luasrc/view/freifunk/contact.htm b/modules/freifunk/luasrc/view/freifunk/contact.htm index c240916db8..7e6a39d22e 100644 --- a/modules/freifunk/luasrc/view/freifunk/contact.htm +++ b/modules/freifunk/luasrc/view/freifunk/contact.htm @@ -1,5 +1,5 @@ <%+header%> -<% local contact = luci.model.uci.sections("freifunk").contact %> +<% local contact = luci.model.uci.get_all("freifunk", "contact") %> <h1><%:contact Kontakt%></h1> <table cellspacing="0" cellpadding="6"> <tr><th><%:nickname Pseudonym%>:</th><td><%=contact.nickname%></td></tr> diff --git a/modules/freifunk/luasrc/view/freifunk/index.htm b/modules/freifunk/luasrc/view/freifunk/index.htm index c5ee17b106..6a1d805f27 100644 --- a/modules/freifunk/luasrc/view/freifunk/index.htm +++ b/modules/freifunk/luasrc/view/freifunk/index.htm @@ -1,5 +1,5 @@ <%+header%> -<% local ff = luci.model.uci.sections("freifunk") %> +<% local ff = luci.model.uci.get_all("freifunk") %> <h1><%:hellonet Hallo und willkommen im Netz von%> <%=ff.community.name%>!</h1> <p><%:public1 Wir sind eine Initiative zur Schaffung eines freien, offenen und unabhängigen Funknetzwerks auf WLAN-Basis.%><br /> <%:public2 Dies ist der Zugangspunkt %><%=luci.sys.hostname()%>. <%:public3 Er wird betrieben von %> |