diff --git a/applications/luci-splash/src/view/splash/splash.htm b/applications/luci-splash/src/view/splash/splash.htm index db4bd0f780..22631e08f4 100644 --- a/applications/luci-splash/src/view/splash/splash.htm +++ b/applications/luci-splash/src/view/splash/splash.htm @@ -1,7 +1,10 @@ +<% +local c = luci.model.uci.sections("freifunk").community +
Du bist jetzt mit dem freien Funknetz
-<%~freifunk.community.name%> verbunden.
+<%=c.name%> verbunden.
Wir sind ein experimentelles Gemeinschaftsnetzwerk, aber kein Internetanbieter.
Wenn Du unsere Idee gut findest, kannst Du uns unterstützen:
-Mit einem Klick auf <%:accept Annehmen%> kannst du für <%~luci_splash.general.leasetime%> Stunden +Mit einem Klick auf <%:accept Annehmen%> kannst du für <%=c.leasetime%> Stunden über unser Netz das Internet verwenden. Dann wirst du erneut aufgefordet, diese Bedingungen zu akzeptieren.
\ No newline at end of file diff --git a/applications/sgi-webuci/root/lib/webuci/main.lua b/applications/sgi-webuci/root/lib/webuci/main.lua index 478c2a94e3..cb2730d147 100644 --- a/applications/sgi-webuci/root/lib/webuci/main.lua +++ b/applications/sgi-webuci/root/lib/webuci/main.lua @@ -1,21 +1,20 @@ module("webuci", package.seeall) function prepare_req(uri) + require("luci.dispatcher").createindex() env = {} env.REQUEST_URI = uri - require("luci.dispatcher").createindex() -end - -function init_req(context) - env.SERVER_PROTOCOL = context.server_proto - env.REMOTE_ADDR = context.remote_addr - env.REQUEST_METHOD = context.request_method - env.PATH_INFO = "/" .. context.uri - env.REMOTE_PORT = context.remote_port - env.SERVER_ADDR = context.server_addr - env.SCRIPT_NAME = env.REQUEST_URI:sub(1, #env.REQUEST_URI - #env.PATH_INFO) end function handle_req(context) + env.SERVER_PROTOCOL = context.server_proto + env.REMOTE_ADDR = context.remote_addr + env.REQUEST_METHOD = context.request_method + env.PATH_INFO = context.uri + env.REMOTE_PORT = context.remote_port + env.SERVER_ADDR = context.server_addr + env.SCRIPT_NAME = env.REQUEST_URI:sub(1, #env.REQUEST_URI - #env.PATH_INFO) + + luci.sgi.webuci.initenv(env) luci.dispatcher.httpdispatch() end \ No newline at end of file diff --git a/applications/sgi-webuci/src/sgi/webuci.lua b/applications/sgi-webuci/src/sgi/webuci.lua index 39eab3c4a2..498bca9214 100644 --- a/applications/sgi-webuci/src/sgi/webuci.lua +++ b/applications/sgi-webuci/src/sgi/webuci.lua @@ -25,12 +25,13 @@ limitations under the License. ]]-- module("luci.sgi.webuci", package.seeall) --- Environment Table -luci.http.env = webuci.env - - local status_set = false +-- Initialize the environment +function initenv(env) + luci.http.env = env +end + -- Returns the main dispatcher URL function luci.http.dispatcher() return luci.http.env.SCRIPT_NAME or "" @@ -94,6 +95,6 @@ end -- Sets HTTP-Status-Header function luci.http.status(code, message) - print(webuci.env.SERVER_PROTOCOL .. " " .. tostring(code) .. " " .. message) + print(luci.http.env.SERVER_PROTOCOL .. " " .. tostring(code) .. " " .. message) status_set = true end diff --git a/core/src/dispatcher.lua b/core/src/dispatcher.lua index 3e8b4d6b6c..d69045c024 100644 --- a/core/src/dispatcher.lua +++ b/core/src/dispatcher.lua @@ -73,7 +73,7 @@ function httpdispatch() local pathinfo = luci.http.env.PATH_INFO or "" local c = tree - for s in pathinfo:gmatch("/([%w-]+)") do + for s in pathinfo:gmatch("([%w_]+)") do table.insert(request, s) end @@ -107,6 +107,14 @@ function dispatch() if track.setuser then luci.sys.process.setuser(track.setuser) end + + -- Init template engine + local tpl = require("luci.template") + tpl.viewns.translate = function(...) return require("luci.i18n").translate(...) end + tpl.viewns.controller = luci.http.dispatcher() + tpl.viewns.uploadctrl = luci.http.dispatcher_upload() + tpl.viewns.media = luci.config.main.mediaurlbase + tpl.viewns.resource = luci.config.main.resourcebase if c and type(c.target) == "function" then @@ -121,19 +129,42 @@ function dispatch() end end +-- Generates the dispatching tree +function createindex() + local path = luci.sys.libpath() .. "/controller/" + local suff = ".lua" + + if pcall(require, "fastindex") then + createindex_fastindex(path, suff) + else + createindex_plain(path, suff) + end +end + +-- Uses fastindex to create the dispatching tree +function createindex_fastindex(path, suffix) + local fi = fastindex.new("index") + fi.add(path .. "*" .. suffix) + fi.add(path .. "*/*" .. suffix) + fi.scan() + + for k, v in pairs(fi.indexes) do + local stat, mod = pcall(require, v[2]) + + luci.util.updfenv(v[1], luci.dispatcher) + pcall(v[1]) + end +end -- Calls the index function of all available controllers -function createindex() - local root = luci.sys.libpath() .. "/controller/" - local suff = ".lua" - +function createindex_plain(path, suffix) local controllers = luci.util.combine( - luci.fs.glob(root .. "*" .. suff) or {}, - luci.fs.glob(root .. "*/*" .. suff) or {} + luci.fs.glob(path .. "*" .. suffix) or {}, + luci.fs.glob(path .. "*/*" .. suffix) or {} ) for i,c in ipairs(controllers) do - c = "luci.controller." .. c:sub(#root+1, #c-#suff):gsub("/", ".") + c = "luci.controller." .. c:sub(#path+1, #c-#suffix):gsub("/", ".") stat, mod = pcall(require, c) if stat and mod and type(mod.index) == "function" then diff --git a/core/src/menu.lua b/core/src/menu.lua deleted file mode 100644 index 30cc5a1225..0000000000 --- a/core/src/menu.lua +++ /dev/null @@ -1,46 +0,0 @@ ---[[ -LuCI - Menu Builder - -Description: -Collects menu building information from controllers - -FileId: -$Id$ - -License: -Copyright 2008 Steven Barth