mirror of
https://github.com/lxsang/antd-web-apps
synced 2024-12-25 17:08:22 +01:00
fix
This commit is contained in:
parent
30762988cf
commit
48ad3a30da
@ -1,8 +1,7 @@
|
||||
PostController = BaseController:extends{
|
||||
class = "PostController",
|
||||
BaseController:subclass("PostController", {
|
||||
registry = {},
|
||||
models = { "post" }
|
||||
}
|
||||
})
|
||||
|
||||
function PostController:index(...)
|
||||
local args = {...}
|
||||
|
@ -1,8 +1,8 @@
|
||||
PostModel = BaseModel:extends{
|
||||
BaseModel:subclass("PostModel", {
|
||||
registry = {},
|
||||
name = "post",
|
||||
fields = {
|
||||
cid = "NUMERIC",
|
||||
content = "TEXT"
|
||||
}
|
||||
}
|
||||
})
|
@ -1,8 +1,8 @@
|
||||
IndexController = BaseController:extends{
|
||||
class = "IndexController",
|
||||
registry = {},
|
||||
models = { "sections", "category" }
|
||||
}
|
||||
BaseController:subclass("IndexController",
|
||||
{
|
||||
registry = {},
|
||||
models = { "sections", "category" }
|
||||
})
|
||||
|
||||
local sectionsByCid = function(db, id)
|
||||
local cond = { exp = { ["="] = { cid = id } } , order = { start = "DESC" } }
|
||||
|
@ -1,6 +1,4 @@
|
||||
TocController = BaseController:extends{
|
||||
class = "TocController"
|
||||
}
|
||||
BaseController:subclass("TocController")
|
||||
|
||||
function TocController:index(...)
|
||||
return true
|
||||
|
@ -1,7 +1,6 @@
|
||||
UserController = BaseController:extends{
|
||||
class = "UserController",
|
||||
BaseController:subclass("UserController",{
|
||||
models = {"user"}
|
||||
}
|
||||
})
|
||||
|
||||
function UserController:index(...)
|
||||
local args = {...}
|
||||
|
@ -1,4 +1,4 @@
|
||||
CategoryModel = BaseModel:extends{
|
||||
BaseModel:subclass("CategoryModel",{
|
||||
registry = {},
|
||||
name = "cv_cat",
|
||||
fields = {
|
||||
@ -6,4 +6,4 @@ CategoryModel = BaseModel:extends{
|
||||
name = "TEXT",
|
||||
pid = "NUMERIC"
|
||||
}
|
||||
}
|
||||
})
|
@ -1,4 +1,4 @@
|
||||
SectionsModel = BaseModel:extends{
|
||||
BaseModel:subclass("SectionsModel",{
|
||||
name = "cv_sections",
|
||||
fields = {
|
||||
title = "TEXT",
|
||||
@ -10,4 +10,4 @@ SectionsModel = BaseModel:extends{
|
||||
publish = "NUMERIC",
|
||||
cid = "NUMERIC",
|
||||
}
|
||||
}
|
||||
})
|
@ -1,4 +1,4 @@
|
||||
UserModel = BaseModel:extends{
|
||||
BaseModel:subclass("UserModel",{
|
||||
registry = {},
|
||||
name = "user",
|
||||
fields = {
|
||||
@ -9,4 +9,4 @@ UserModel = BaseModel:extends{
|
||||
email = "TEXT",
|
||||
url = "TEXT"
|
||||
}
|
||||
}
|
||||
})
|
@ -1,9 +1,11 @@
|
||||
-- create class
|
||||
BaseController = BaseObject:extends{
|
||||
class="BaseController",
|
||||
registry = {},
|
||||
models = {},
|
||||
main = false }
|
||||
BaseObject:subclass("BaseController",
|
||||
{
|
||||
registry = {},
|
||||
models = {},
|
||||
main = false
|
||||
})
|
||||
|
||||
-- set the name here in each subclasses
|
||||
function BaseController:initialize()
|
||||
for k, v in pairs(self.models) do
|
||||
@ -24,6 +26,10 @@ function BaseController:initialize()
|
||||
self.template = Template:new{registry = self.registry}
|
||||
end
|
||||
|
||||
function BaseController:print(...)
|
||||
return self:actionnotfound("print")
|
||||
end
|
||||
|
||||
function BaseController:redirect(url)
|
||||
std.status(301, "Moved Permanently")
|
||||
std.custom_header("Content-Type","text/html")
|
||||
@ -64,7 +70,7 @@ function BaseController:modelnotfound(...)
|
||||
end
|
||||
-- The not found controller
|
||||
|
||||
NotfoundController = BaseController:extends{ registry = {}, models = {} }
|
||||
BaseController:subclass("NotfoundController",{ registry = {}, models = {} })
|
||||
|
||||
function NotfoundController:index(...)
|
||||
local args = {...}
|
||||
@ -74,7 +80,7 @@ function NotfoundController:index(...)
|
||||
end
|
||||
|
||||
-- The asset controller for the static file
|
||||
AssetController = BaseController:extends{name= "AssetController",registry={}, models={}}
|
||||
BaseController:subclass("AssetController", {registry={}, models={}})
|
||||
function AssetController:index(...)
|
||||
local args = {...}
|
||||
return self:get(table.unpack(args))
|
||||
|
@ -1,6 +1,6 @@
|
||||
|
||||
-- create class
|
||||
BaseModel = BaseObject:extends{class="BaseModel",registry = {}}
|
||||
BaseObject:subclass("BaseModel", {registry = {}})
|
||||
|
||||
function BaseModel:initialize()
|
||||
self.db = self.registry.db
|
||||
|
@ -1,5 +1,8 @@
|
||||
BaseObject = Object:extends{registry = {}, class="BaseObject"}
|
||||
|
||||
function BaseObject:subclass(name, args)
|
||||
_G[name] = self:extends(args)
|
||||
_G[name].class = name
|
||||
end
|
||||
|
||||
function BaseObject:log(msg, level)
|
||||
level = level or "INFO"
|
||||
@ -12,6 +15,10 @@ function BaseObject:debug(msg)
|
||||
self:log(msg, "DEBUG")
|
||||
end
|
||||
|
||||
function BaseObject:print()
|
||||
print(self.class)
|
||||
end
|
||||
|
||||
function BaseObject:error(msg, trace)
|
||||
html()
|
||||
echo(msg)
|
||||
|
@ -2,7 +2,7 @@ sqlite = modules.sqlite()
|
||||
|
||||
if sqlite == nil then return 0 end
|
||||
-- create class
|
||||
DBHelper = BaseObject:extends{db=nil, class='DBHelper'}
|
||||
BaseObject:subclass("DBHelper",{db={}})
|
||||
|
||||
function DBHelper:createTable(tbl, m)
|
||||
if self:available(tbl) then return true end
|
||||
|
@ -1,6 +1,6 @@
|
||||
|
||||
--define the class
|
||||
Router = BaseObject:extends{class="Router",registry = {}}
|
||||
BaseObject:subclass ("Router",{registry = {}})
|
||||
function Router:setPath(path)
|
||||
self.path = path
|
||||
end
|
||||
|
@ -1,5 +1,5 @@
|
||||
-- create class
|
||||
Template = BaseObject:extends{class="Template",registry = {}}
|
||||
BaseObject:subclass("Template",{registry = {}})
|
||||
|
||||
function Template:initialize()
|
||||
self.vars = {}
|
||||
|
Loading…
Reference in New Issue
Block a user