* Updated dispatcher to use fastindex if available
* Updated webuci SGI * Updated dispatcher
This commit is contained in:
parent
1da3c32a73
commit
5f40074c0e
7 changed files with 63 additions and 90 deletions
|
@ -1,7 +1,10 @@
|
|||
<%
|
||||
local c = luci.model.uci.sections("freifunk").community
|
||||
|
||||
<h1><%:welcome Willkommen%>!</h1>
|
||||
<p>
|
||||
Du bist jetzt mit dem freien Funknetz
|
||||
<a href="<%~freifunk.community.homepage%>"><%~freifunk.community.name%></a> verbunden.<br />
|
||||
<a href="<%=c.homepage%>"><%=c.name%></a> verbunden.<br />
|
||||
Wir sind ein experimentelles Gemeinschaftsnetzwerk, aber kein Internetanbieter.
|
||||
</p>
|
||||
|
||||
|
@ -20,12 +23,12 @@ Bitte sei Dir dessen bewusst und verhalte Dich dementsprechend:
|
|||
<p>
|
||||
Wenn Du unsere Idee gut findest, kannst Du uns unterstützen:
|
||||
<ul>
|
||||
<li><a href="<%~freifunk.community.homepage%>">Werde selbst Freifunker oder teile deinen Internetzugang!</a></li>
|
||||
<li><a href="<%=c.homepage%>">Werde selbst Freifunker oder teile deinen Internetzugang!</a></li>
|
||||
<li>Betreibe deine anderen WLAN-Geräte <em>NICHT</em> auf den Kanälen 1-5, diese stören oft unser Netz.</li>
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Mit einem Klick auf <em><%:accept Annehmen%></em> kannst du für <%~luci_splash.general.leasetime%> Stunden
|
||||
Mit einem Klick auf <em><%:accept Annehmen%></em> kannst du für <%=c.leasetime%> Stunden
|
||||
über unser Netz das Internet verwenden. Dann wirst du erneut aufgefordet, diese Bedingungen zu akzeptieren.
|
||||
</p>
|
|
@ -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
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,46 +0,0 @@
|
|||
--[[
|
||||
LuCI - Menu Builder
|
||||
|
||||
Description:
|
||||
Collects menu building information from controllers
|
||||
|
||||
FileId:
|
||||
$Id$
|
||||
|
||||
License:
|
||||
Copyright 2008 Steven Barth <steven@midlink.org>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
]]--
|
||||
module("luci.menu", package.seeall)
|
||||
|
||||
require("luci.fs")
|
||||
require("luci.util")
|
||||
require("luci.sys")
|
||||
require("luci.dispatcher")
|
||||
|
||||
-- Default modelpath
|
||||
modelpattern = luci.sys.libpath() .. "/model/menu/*.lua"
|
||||
|
||||
-- Menu definition extra scope
|
||||
scope = {
|
||||
translate = function(...) return require("luci.i18n").translate(...) end,
|
||||
loadtrans = function(...) return require("luci.i18n").loadc(...) end,
|
||||
isfile = luci.fs.isfile
|
||||
}
|
||||
|
||||
-- Returns the menu information
|
||||
function get()
|
||||
return menu
|
||||
end
|
|
@ -50,12 +50,6 @@ compiler_enable_bytecode = false
|
|||
|
||||
-- Define the namespace for template modules
|
||||
viewns = {
|
||||
translate = function(...) return require("luci.i18n").translate(...) end,
|
||||
config = function(...) return require("luci.model.uci").get(...) or "" end,
|
||||
controller = luci.http.dispatcher(),
|
||||
uploadctrl = luci.http.dispatcher_upload(),
|
||||
media = luci.config.main.mediaurlbase,
|
||||
resource = luci.config.main.resourcebase,
|
||||
write = io.write,
|
||||
include = function(name) Template(name):render(getfenv(2)) end,
|
||||
}
|
||||
|
@ -94,7 +88,6 @@ function compile(template)
|
|||
-- Replacements
|
||||
local r_include = "')\ninclude('%s')\nwrite('"
|
||||
local r_i18n = "'..translate('%1','%2')..'"
|
||||
local r_uci = "'..config('%1','%2','%3')..'"
|
||||
local r_pexec = "'..(%s or '')..'"
|
||||
local r_exec = "')\n%s\nwrite('"
|
||||
|
||||
|
@ -106,8 +99,6 @@ function compile(template)
|
|||
re = r_include:format(sanitize(string.sub(v, 2)))
|
||||
elseif p == ":" then
|
||||
re = sanitize(v):gsub(":(.-) (.+)", r_i18n)
|
||||
elseif p == "~" then
|
||||
re = sanitize(v):gsub("~(.-)%.(.-)%.(.+)", r_uci)
|
||||
elseif p == "=" then
|
||||
re = r_pexec:format(v:sub(2))
|
||||
else
|
||||
|
|
|
@ -1,14 +1,8 @@
|
|||
module("luci.controller.admin.status", package.seeall)
|
||||
|
||||
function index()
|
||||
local page = node("admin", "status")
|
||||
page.target = template("admin_status/index")
|
||||
page.title = "Status"
|
||||
page.order = 20
|
||||
|
||||
local page = node("admin", "status", "syslog")
|
||||
page.target = action_syslog
|
||||
page.title = "Systemprotokoll"
|
||||
entry({"admin", "status"}, template("admin_status/index"), "Status", 20)
|
||||
entry({"admin", "status", "syslog"}, action_syslog, "Systemprotokoll")
|
||||
end
|
||||
|
||||
function action_syslog()
|
||||
|
|
Loading…
Reference in a new issue