mirror of
https://github.com/lxsang/antd-web-apps
synced 2025-07-17 06:09:50 +02:00
the info page now use the silk framework
This commit is contained in:
@ -68,7 +68,8 @@ NotfoundController = BaseController:extends{ registry = {}, models = {} }
|
||||
|
||||
function NotfoundController:index(...)
|
||||
local args = {...}
|
||||
self:error("404: Controller "..args[1].." not found")
|
||||
local error = args[2] or ""
|
||||
self:error("404: Controller "..args[1].." not found : "..error)
|
||||
return false
|
||||
end
|
||||
|
||||
@ -86,9 +87,9 @@ function AssetController:get(...)
|
||||
if POLICY.mimes[mime] then
|
||||
std.header(mime)
|
||||
if std.isBinary(path) then
|
||||
std.f(path)
|
||||
else
|
||||
std.fb(path)
|
||||
else
|
||||
std.f(path)
|
||||
end
|
||||
end
|
||||
return false
|
||||
|
@ -22,4 +22,5 @@ function BaseObject:error(msg, trace)
|
||||
else
|
||||
error(msg)
|
||||
end
|
||||
return false
|
||||
end
|
@ -44,11 +44,11 @@ function Router:infer(url)
|
||||
local controller_path = self.path.."."..controller_name
|
||||
-- require the controller module
|
||||
-- ignore the error
|
||||
pcall(require, controller_path)
|
||||
local r,e = pcall(require, controller_path)
|
||||
--require(controller_path)
|
||||
if not _G[controller_name] then
|
||||
data.controller = NotfoundController:new{ registry = self.registry }
|
||||
data.args = {controller_name}
|
||||
data.args = {controller_name, e}
|
||||
data.action = "index"
|
||||
data.name = "notfound"
|
||||
else
|
||||
@ -113,9 +113,9 @@ function Router:dependencies(url)
|
||||
end
|
||||
|
||||
function Router:call(data)
|
||||
data.controller.template:setView(data.action, data.name)
|
||||
local obj = data.controller[data.action](data.controller,table.unpack(data.args))
|
||||
if obj then
|
||||
data.controller.template:setView(data.action, data.name)
|
||||
return data.controller.template
|
||||
else
|
||||
return false
|
||||
|
@ -11,21 +11,32 @@ function Template:set(k, v, ow)
|
||||
end
|
||||
end
|
||||
|
||||
function Template:get(k)
|
||||
return self.vars[k]
|
||||
end
|
||||
|
||||
function Template:remove(k)
|
||||
self.vars[k] = nil
|
||||
end
|
||||
|
||||
-- infer view path
|
||||
function Template:setView(name, controller)
|
||||
self.path = VIEW_ROOT..DIR_SEP..self.registry.layout..DIR_SEP..controller..DIR_SEP..name..".ls"
|
||||
if ulib.exists(self.path) then
|
||||
self.name = name
|
||||
if controller then
|
||||
self.controller = controller
|
||||
end
|
||||
end
|
||||
function Template:path()
|
||||
local path = VIEW_ROOT..DIR_SEP..self.registry.layout..DIR_SEP..self.controller..DIR_SEP..self.name..".ls"
|
||||
if ulib.exists(path) then
|
||||
return path
|
||||
else
|
||||
self:error("View not found: "..self.path)
|
||||
self:error("View not found: "..path)
|
||||
end
|
||||
end
|
||||
-- render the page
|
||||
function Template:render()
|
||||
local fn, e = loadscript(self.path)
|
||||
local fn, e = loadscript(self:path())
|
||||
if fn then
|
||||
local r,o = pcall(fn, self.vars)
|
||||
if not r then
|
||||
|
Reference in New Issue
Block a user