* Optimized dispatching model
This commit is contained in:
parent
3f09d369d6
commit
b1e131a3db
9 changed files with 32 additions and 28 deletions
|
@ -1,7 +1,7 @@
|
||||||
module("luci.controller.luci_ffwizard_leipzig.wizard", package.seeall)
|
module("luci.controller.luci_ffwizard_leipzig.wizard", package.seeall)
|
||||||
|
|
||||||
function index()
|
function index()
|
||||||
entry({"admin", "index", "wizard"}, action_wizard, "Freifunkassistent", 20)
|
entry({"admin", "index", "wizard"}, call("action_wizard"), "Freifunkassistent", 20)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,9 +5,9 @@ function index()
|
||||||
page.target = cbi("splash/splash")
|
page.target = cbi("splash/splash")
|
||||||
page.title = "Client-Splash"
|
page.title = "Client-Splash"
|
||||||
|
|
||||||
node("splash", "splash", "activate").target = action_activate
|
node("splash", "splash", "activate").target = call("action_activate")
|
||||||
node("splash", "splash", "allowed").target = action_allowed
|
node("splash", "splash", "allowed").target = call("action_allowed")
|
||||||
node("splash", "splash", "unknown").target = action_unknown
|
node("splash", "splash", "unknown").target = call("action_unknown")
|
||||||
node("splash", "splash", "splash").target = template("splash_splash/splash")
|
node("splash", "splash", "splash").target = template("splash_splash/splash")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -137,7 +137,11 @@ function dispatch()
|
||||||
|
|
||||||
if c and type(c.target) == "function" then
|
if c and type(c.target) == "function" then
|
||||||
dispatched = c
|
dispatched = c
|
||||||
|
stat, mod = pcall(require, c.module)
|
||||||
|
if stat then
|
||||||
|
luci.util.updfenv(c.target, mod)
|
||||||
|
end
|
||||||
|
|
||||||
stat, err = pcall(c.target)
|
stat, err = pcall(c.target)
|
||||||
if not stat then
|
if not stat then
|
||||||
error500(err)
|
error500(err)
|
||||||
|
@ -222,12 +226,7 @@ function createtree()
|
||||||
|
|
||||||
for k, v in pairs(index) do
|
for k, v in pairs(index) do
|
||||||
luci.util.updfenv(v, _M)
|
luci.util.updfenv(v, _M)
|
||||||
|
luci.util.extfenv(v, "_NAME", k)
|
||||||
local stat, mod = pcall(require, k)
|
|
||||||
if stat then
|
|
||||||
luci.util.updfenv(v, mod)
|
|
||||||
end
|
|
||||||
|
|
||||||
pcall(v)
|
pcall(v)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -242,6 +241,7 @@ function entry(path, target, title, order, add)
|
||||||
c.target = target
|
c.target = target
|
||||||
c.title = title
|
c.title = title
|
||||||
c.order = order
|
c.order = order
|
||||||
|
c.module = getfenv(2)._NAME
|
||||||
|
|
||||||
for k,v in pairs(add) do
|
for k,v in pairs(add) do
|
||||||
c[k] = v
|
c[k] = v
|
||||||
|
@ -260,7 +260,7 @@ function node(...)
|
||||||
|
|
||||||
for k,v in ipairs(arg) do
|
for k,v in ipairs(arg) do
|
||||||
if not c.nodes[v] then
|
if not c.nodes[v] then
|
||||||
c.nodes[v] = {nodes={}}
|
c.nodes[v] = {nodes={}, module=getfenv(2)._NAME}
|
||||||
end
|
end
|
||||||
|
|
||||||
c = c.nodes[v]
|
c = c.nodes[v]
|
||||||
|
@ -278,6 +278,10 @@ function alias(...)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function call(name)
|
||||||
|
return function() getfenv()[name]() end
|
||||||
|
end
|
||||||
|
|
||||||
function template(name)
|
function template(name)
|
||||||
require("luci.template")
|
require("luci.template")
|
||||||
return function() luci.template.render(name) end
|
return function() luci.template.render(name) end
|
||||||
|
|
|
@ -2,7 +2,7 @@ module("luci.controller.admin.status", package.seeall)
|
||||||
|
|
||||||
function index()
|
function index()
|
||||||
entry({"admin", "status"}, template("admin_status/index"), "Status", 20)
|
entry({"admin", "status"}, template("admin_status/index"), "Status", 20)
|
||||||
entry({"admin", "status", "syslog"}, action_syslog, "Systemprotokoll")
|
entry({"admin", "status", "syslog"}, call("action_syslog"), "Systemprotokoll")
|
||||||
end
|
end
|
||||||
|
|
||||||
function action_syslog()
|
function action_syslog()
|
||||||
|
|
|
@ -14,21 +14,21 @@ function index()
|
||||||
page.order = 30
|
page.order = 30
|
||||||
|
|
||||||
local page = node("admin", "system", "packages")
|
local page = node("admin", "system", "packages")
|
||||||
page.target = action_packages
|
page.target = call("action_packages")
|
||||||
page.title = "Paketverwaltung"
|
page.title = "Paketverwaltung"
|
||||||
page.order = 10
|
page.order = 10
|
||||||
|
|
||||||
local page = node("admin", "system", "packages", "ipkg")
|
local page = node("admin", "system", "packages", "ipkg")
|
||||||
page.target = action_ipkg
|
page.target = call("action_ipkg")
|
||||||
page.title = "IPKG-Konfiguration"
|
page.title = "IPKG-Konfiguration"
|
||||||
|
|
||||||
local page = node("admin", "system", "passwd")
|
local page = node("admin", "system", "passwd")
|
||||||
page.target = action_passwd
|
page.target = call("action_passwd")
|
||||||
page.title = "Passwort ändern"
|
page.title = "Passwort ändern"
|
||||||
page.order = 20
|
page.order = 20
|
||||||
|
|
||||||
local page = node("admin", "system", "sshkeys")
|
local page = node("admin", "system", "sshkeys")
|
||||||
page.target = action_sshkeys
|
page.target = call("action_sshkeys")
|
||||||
page.title = "SSH-Schlüssel"
|
page.title = "SSH-Schlüssel"
|
||||||
page.order = 30
|
page.order = 30
|
||||||
|
|
||||||
|
@ -43,12 +43,12 @@ function index()
|
||||||
page.order = 50
|
page.order = 50
|
||||||
|
|
||||||
local page = node("admin", "system", "upgrade")
|
local page = node("admin", "system", "upgrade")
|
||||||
page.target = action_upgrade
|
page.target = call("action_upgrade")
|
||||||
page.title = "Firmwareupgrade"
|
page.title = "Firmwareupgrade"
|
||||||
page.order = 60
|
page.order = 60
|
||||||
|
|
||||||
local page = node("admin", "system", "reboot")
|
local page = node("admin", "system", "reboot")
|
||||||
page.target = action_reboot
|
page.target = call("action_reboot")
|
||||||
page.title = "Neu starten"
|
page.title = "Neu starten"
|
||||||
page.order = 70
|
page.order = 70
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,8 +4,8 @@ require("luci.sys")
|
||||||
|
|
||||||
function index()
|
function index()
|
||||||
node("admin", "uci", "changes").target = template("admin_uci/changes")
|
node("admin", "uci", "changes").target = template("admin_uci/changes")
|
||||||
node("admin", "uci", "revert").target = action_revert
|
node("admin", "uci", "revert").target = call("action_revert")
|
||||||
node("admin", "uci", "apply").target = action_apply
|
node("admin", "uci", "apply").target = call("action_apply")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- This function has a higher priority than the admin_uci/apply template
|
-- This function has a higher priority than the admin_uci/apply template
|
||||||
|
|
|
@ -22,7 +22,7 @@ function index()
|
||||||
|
|
||||||
|
|
||||||
local page = node("freifunk", "status")
|
local page = node("freifunk", "status")
|
||||||
page.target = action_status
|
page.target = call("action_status")
|
||||||
page.title = "Status"
|
page.title = "Status"
|
||||||
page.order = 20
|
page.order = 20
|
||||||
page.setuser = false
|
page.setuser = false
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
module("luci.controller.freifunk.luciinfo", package.seeall)
|
module("luci.controller.freifunk.luciinfo", package.seeall)
|
||||||
|
|
||||||
function index()
|
function index()
|
||||||
node("freifunk", "luciinfo").target = action_index
|
node("freifunk", "luciinfo").target = call("action_index")
|
||||||
end
|
end
|
||||||
|
|
||||||
function action_index()
|
function action_index()
|
||||||
|
|
|
@ -3,27 +3,27 @@ require("luci.sys")
|
||||||
|
|
||||||
function index()
|
function index()
|
||||||
local page = node("freifunk", "olsr")
|
local page = node("freifunk", "olsr")
|
||||||
page.target = action_index
|
page.target = call("action_index")
|
||||||
page.title = "OLSR"
|
page.title = "OLSR"
|
||||||
page.order = 30
|
page.order = 30
|
||||||
|
|
||||||
local page = node("freifunk", "olsr", "routes")
|
local page = node("freifunk", "olsr", "routes")
|
||||||
page.target = action_routes
|
page.target = call("action_routes")
|
||||||
page.title = "Routen"
|
page.title = "Routen"
|
||||||
page.order = 10
|
page.order = 10
|
||||||
|
|
||||||
local page = node("freifunk", "olsr", "topology")
|
local page = node("freifunk", "olsr", "topology")
|
||||||
page.target = action_topology
|
page.target = call("action_topology")
|
||||||
page.title = "Topologie"
|
page.title = "Topologie"
|
||||||
page.order = 20
|
page.order = 20
|
||||||
|
|
||||||
local page = node("freifunk", "olsr", "hna")
|
local page = node("freifunk", "olsr", "hna")
|
||||||
page.target = action_hna
|
page.target = call("action_hna")
|
||||||
page.title = "HNA"
|
page.title = "HNA"
|
||||||
page.order = 30
|
page.order = 30
|
||||||
|
|
||||||
local page = node("freifunk", "olsr", "mid")
|
local page = node("freifunk", "olsr", "mid")
|
||||||
page.target = action_mid
|
page.target = call("action_mid")
|
||||||
page.title = "MID"
|
page.title = "MID"
|
||||||
page.order = 50
|
page.order = 50
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue