Added support for per dispatching node theme control
[project/luci.git] / libs / web / luasrc / dispatcher.lua
index d03b2ec..a54685f 100644 (file)
@@ -163,7 +163,7 @@ function dispatch(request)
        -- Init template engine
        if (c and c.index) or not track.notemplate then
                local tpl = require("luci.template")
-               local media = luci.config.main.mediaurlbase
+               local media = track.mediaurlbase or luci.config.main.mediaurlbase
                if not pcall(tpl.Template, "themes/%s/header" % fs.basename(media)) then
                        media = nil
                        for name, theme in pairs(luci.config.themes) do
@@ -232,16 +232,20 @@ function dispatch(request)
                luci.sys.process.setuser(track.setuser)
        end
 
+       if c and (c.index or type(c.target) == "function") then
+               ctx.dispatched = c
+               ctx.requested = ctx.requested or ctx.dispatched
+       end
+
        if c and c.index then
                local tpl = require "luci.template"
-               if util.copcall(tpl.render, "indexer") then
+
+               if util.copcall(tpl.render, "indexer", {}) then
                        return true
                end
        end
 
        if c and type(c.target) == "function" then
-               context.dispatched = c
-
                util.copcall(function()
                        local oldenv = getfenv(c.target)
                        local module = require(c.module)