X-Git-Url: https://git.archive.openwrt.org/?p=project%2Fluci.git;a=blobdiff_plain;f=libs%2Fweb%2Fluasrc%2Fdispatcher.lua;h=565e995d191d5fdf38367db732dac746a471baa7;hp=062084f86ad2506456cd5eadbcc27c1751aea187;hb=f3deef9ec570d49795346516d34c1b42fb416fde;hpb=30b7bc7c623dbef9683b1ec1762a78bd0b6d684d diff --git a/libs/web/luasrc/dispatcher.lua b/libs/web/luasrc/dispatcher.lua index 062084f86..565e995d1 100644 --- a/libs/web/luasrc/dispatcher.lua +++ b/libs/web/luasrc/dispatcher.lua @@ -77,6 +77,8 @@ function error500(message) luci.util.perror(message) if not context.template_header_sent then luci.http.status(500, "Internal Server Error") + luci.http.prepare_content("text/plain") + luci.http.write(message) else require("luci.template") if not luci.util.copcall(luci.template.render, "error500", {message=message}) then @@ -132,6 +134,9 @@ function dispatch(request) ctx.urltoken = ctx.urltoken or {} local conf = require "luci.config" + assert(conf.main, + "/etc/config/luci seems to be corrupt, unable to find section 'main'") + local lang = conf.main.lang if lang == "auto" then local aclang = http.getenv("HTTP_ACCEPT_LANGUAGE") or "" @@ -635,9 +640,7 @@ local function _cbi(self, ...) local state = nil for i, res in ipairs(maps) do - if config.autoapply then - res.autoapply = config.autoapply - end + res.flow = config local cstate = res:parse() if cstate and (not state or cstate < state) then state = cstate @@ -667,14 +670,18 @@ local function _cbi(self, ...) local pageaction = true http.header("X-CBI-State", state or 0) - tpl.render("cbi/header", {state = state}) + if not config.noheader then + tpl.render("cbi/header", {state = state}) + end for i, res in ipairs(maps) do res:render() if res.pageaction == false then pageaction = false end end - tpl.render("cbi/footer", {pageaction=pageaction, state = state, autoapply = config.autoapply}) + if not config.nofooter then + tpl.render("cbi/footer", {flow = config, pageaction=pageaction, state = state, autoapply = config.autoapply}) + end end --- Create a CBI model dispatching target.