X-Git-Url: https://git.archive.openwrt.org/?p=project%2Fluci.git;a=blobdiff_plain;f=libs%2Fweb%2Fluasrc%2Fdispatcher.lua;h=28c460858d65be9d54a90f084bf53bac75656b99;hp=d10b5c0b5f37eadca317ef447f43eeb353a88a33;hb=39578a6b72782d8d39b0450346bf0fa1bbb909a1;hpb=25754119d45d3cf8695ae0ee8c8332d69f9985c3 diff --git a/libs/web/luasrc/dispatcher.lua b/libs/web/luasrc/dispatcher.lua index d10b5c0b5..28c460858 100644 --- a/libs/web/luasrc/dispatcher.lua +++ b/libs/web/luasrc/dispatcher.lua @@ -457,16 +457,16 @@ function createindex_plain(path, suffixes) index = {} for i,c in ipairs(controllers) do - local module = "luci.controller." .. c:sub(#path+1, #c):gsub("/", ".") + local modname = "luci.controller." .. c:sub(#path+1, #c):gsub("/", ".") for _, suffix in ipairs(suffixes) do - module = module:gsub(suffix.."$", "") + modname = modname:gsub(suffix.."$", "") end - local mod = require(module) + local mod = require(modname) local idx = mod.index if type(idx) == "function" then - index[module] = idx + index[modname] = idx end end @@ -718,21 +718,52 @@ local function _cbi(self, ...) end end - local redirect - local pageaction = true http.header("X-CBI-State", state or 0) + if not config.noheader then tpl.render("cbi/header", {state = state}) end + + local redirect + local messages + local applymap = false + local pageaction = true + local parsechain = { } + for i, res in ipairs(maps) do - res:render() - if res.pageaction == false then - pageaction = false + if res.apply_needed and res.parsechain then + local c + for _, c in ipairs(res.parsechain) do + parsechain[#parsechain+1] = c + end + applymap = true end + if res.redirect then redirect = redirect or res.redirect end + + if res.pageaction == false then + pageaction = false + end + + if res.message then + messages = messages or { } + messages[#messages+1] = res.message + end + end + + for i, res in ipairs(maps) do + res:render({ + firstmap = (i == 1), + applymap = applymap, + redirect = redirect, + messages = messages, + pageaction = pageaction, + parsechain = parsechain + }) end + if not config.nofooter then tpl.render("cbi/footer", { flow = config,