projects
/
project
/
luci.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
7086a16
)
Implemented dispatching tree modifiers
author
Steven Barth
<steven@midlink.org>
Tue, 11 Nov 2008 18:55:07 +0000
(18:55 +0000)
committer
Steven Barth
<steven@midlink.org>
Tue, 11 Nov 2008 18:55:07 +0000
(18:55 +0000)
libs/web/luasrc/dispatcher.lua
patch
|
blob
|
history
diff --git
a/libs/web/luasrc/dispatcher.lua
b/libs/web/luasrc/dispatcher.lua
index
2323cf8
..
b48b584
100644
(file)
--- a/
libs/web/luasrc/dispatcher.lua
+++ b/
libs/web/luasrc/dispatcher.lua
@@
-354,9
+354,11
@@
function createtree()
local ctx = context
local tree = {nodes={}}
local ctx = context
local tree = {nodes={}}
+ local modi = {}
ctx.treecache = setmetatable({}, {__mode="v"})
ctx.tree = tree
ctx.treecache = setmetatable({}, {__mode="v"})
ctx.tree = tree
+ ctx.modifiers = modi
-- Load default translation
require "luci.i18n".loadc("default")
-- Load default translation
require "luci.i18n".loadc("default")
@@
-369,9
+371,30
@@
function createtree()
v()
end
v()
end
+ local function modisort(a,b)
+ return modi[a].order < modi[b].order
+ end
+
+ for _, v in util.spairs(modi, modisort) do
+ scope._NAME = v.module
+ setfenv(v.func, scope)
+ v.func()
+ end
+
return tree
end
return tree
end
+--- Register a tree modifier.
+-- @param func Modifier function
+-- @param order Modifier order value (optional)
+function modifier(func, order)
+ context.modifiers[#context.modifiers+1] = {
+ func = func,
+ order = order or 0,
+ module = getfenv(2)._NAME
+ }
+end
+
--- Clone a node of the dispatching tree to another position.
-- @param path Virtual path destination
-- @param clone Virtual path source
--- Clone a node of the dispatching tree to another position.
-- @param path Virtual path destination
-- @param clone Virtual path source