From 9c3db58ee44dfd411336d7d460d0f7a6a10f0ee3 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Mon, 22 Nov 2010 00:32:54 +0000 Subject: libs/web: combine apply actions of all maps on a page, prevents concurrent XHR --- libs/web/luasrc/dispatcher.lua | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) (limited to 'libs/web/luasrc/dispatcher.lua') diff --git a/libs/web/luasrc/dispatcher.lua b/libs/web/luasrc/dispatcher.lua index d10b5c0b5f..589cb731f6 100644 --- a/libs/web/luasrc/dispatcher.lua +++ b/libs/web/luasrc/dispatcher.lua @@ -718,21 +718,45 @@ 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 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 end + + for i, res in ipairs(maps) do + res:render({ + firstmap = (i == 1), + applymap = applymap, + redirect = redirect, + pageaction = pageaction, + parsechain = parsechain + }) + end + if not config.nofooter then tpl.render("cbi/footer", { flow = config, -- cgit v1.2.3