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