X-Git-Url: https://git.archive.openwrt.org/?p=project%2Fluci.git;a=blobdiff_plain;f=core%2Fsrc%2Fdispatcher.lua;h=a05c8805cbd79c7921186f9089d8d7a48b0c98a5;hp=84c665edab6b173f4e6589d9e5cf24dda2ad46e7;hb=b515d6f88e8cbfe1b742d0a5cc99aa2d55b6c38e;hpb=505c3208c90d649cd2397a100c93925d480cce91 diff --git a/core/src/dispatcher.lua b/core/src/dispatcher.lua index 84c665eda..a05c8805c 100644 --- a/core/src/dispatcher.lua +++ b/core/src/dispatcher.lua @@ -137,11 +137,30 @@ function createindex() end end +-- Shortcut for creating a dispatching node +function entry(path, target, title, order, add) + add = add or {} + + local c = node(path) + c.target = target + c.title = title + c.order = order + + for k,v in pairs(add) do + c[k] = v + end + + return c +end -- Fetch a dispatching node function node(...) local c = tree + if arg[1] and type(arg[1]) == "table" then + arg = arg[1] + end + for k,v in ipairs(arg) do if not c.nodes[v] then c.nodes[v] = {nodes={}}