summaryrefslogtreecommitdiffhomepage
path: root/libs
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2008-06-06 15:50:21 +0000
committerSteven Barth <steven@midlink.org>2008-06-06 15:50:21 +0000
commit932280107232706c4605e475a6d969f0adf2e22d (patch)
treeffc20d5818255da0cb9a1d3b7453b747702beacb /libs
parentdd9606825da5d73883b8313f5af905ea1b2a4d7d (diff)
* Separated OLSR pages into separate application pack
* Minor bugfixes and enhancements
Diffstat (limited to 'libs')
-rw-r--r--libs/core/luasrc/util.lua2
-rw-r--r--libs/web/luasrc/dispatcher.lua28
2 files changed, 21 insertions, 9 deletions
diff --git a/libs/core/luasrc/util.lua b/libs/core/luasrc/util.lua
index 074b43519..343c62725 100644
--- a/libs/core/luasrc/util.lua
+++ b/libs/core/luasrc/util.lua
@@ -107,7 +107,7 @@ end
function dumptable(t, i)
i = i or 0
for k,v in pairs(t) do
- print(string.rep("\t", i) .. k, v)
+ print(string.rep("\t", i) .. tostring(k), tostring(v))
if type(v) == "table" then
dumptable(v, i+1)
end
diff --git a/libs/web/luasrc/dispatcher.lua b/libs/web/luasrc/dispatcher.lua
index 7ff4031a6..99ba9adca 100644
--- a/libs/web/luasrc/dispatcher.lua
+++ b/libs/web/luasrc/dispatcher.lua
@@ -99,10 +99,9 @@ end
-- Creates a request object for dispatching
function httpdispatch()
local pathinfo = luci.http.env.PATH_INFO or ""
- local c = tree
- for s in pathinfo:gmatch("([%w-]+)") do
- table.insert(request, s)
+ for node in pathinfo:gmatch("[^/]+") do
+ table.insert(request, node)
end
dispatch()
@@ -163,7 +162,7 @@ function dispatch()
tpl.viewns.media = luci.config.main.mediaurlbase
tpl.viewns.resource = luci.config.main.resourcebase
tpl.viewns.uci = require("luci.model.uci").config
- tpl.viewns.REQUEST_URI = luci.http.env.SCRIPT_NAME .. luci.http.env.PATH_INFO
+ tpl.viewns.REQUEST_URI = luci.http.env.SCRIPT_NAME .. (luci.http.env.PATH_INFO or "")
if c and type(c.target) == "function" then
@@ -304,7 +303,16 @@ function assign(path, clone, title, order)
obj.title = title
obj.order = order
- setmetatable(obj, {__index = clone})
+ local c = tree
+ for k, v in ipairs(clone) do
+ if not c.nodes[v] then
+ c.nodes[v] = {nodes={}}
+ end
+
+ c = c.nodes[v]
+ end
+
+ setmetatable(obj, {__index = c})
return obj
end
@@ -325,18 +333,22 @@ end
function node(...)
local c = tree
- if arg[1] and type(arg[1]) == "table" then
- arg = arg[1]
+ arg.n = nil
+ if arg[1] then
+ if type(arg[1]) == "table" then
+ arg = arg[1]
+ end
end
for k,v in ipairs(arg) do
if not c.nodes[v] then
- c.nodes[v] = {nodes={}, module=getfenv(2)._NAME}
+ c.nodes[v] = {nodes={}}
end
c = c.nodes[v]
end
+ c.module = getfenv(2)._NAME
c.path = arg
return c