mirror of
https://github.com/lxsang/antd-web-apps
synced 2024-12-27 09:58:20 +01:00
add silk frame work
This commit is contained in:
parent
3fadbfce2e
commit
5bf7933c3a
26
apps/index.lua
Normal file
26
apps/index.lua
Normal file
@ -0,0 +1,26 @@
|
||||
-- require needed library
|
||||
require("silk.api")
|
||||
-- need to define this
|
||||
-- basically it initialize an session object
|
||||
session_start()
|
||||
|
||||
-- some global variables
|
||||
DIR_SEP = ""
|
||||
WWW_ROOT = ""
|
||||
HTTP_ROOT = ""
|
||||
MODEL_ROOT = ""
|
||||
CONTROLLER_ROOT = ""
|
||||
VIEW_ROOT = ""
|
||||
|
||||
-- registry object store global variables
|
||||
local REGISTRY = {}
|
||||
-- set logging level
|
||||
REGISTRY.logger = Logger{ levels = {INFO = true, ERROR = true, DEBUG = true}}
|
||||
REGISTRY.db = nil
|
||||
REGISTRY.layout = 'default'
|
||||
|
||||
local router = Router{registry = REGISTRY}
|
||||
REGISTRY.router = router
|
||||
router.setPath(CONTROLLER_ROOT)
|
||||
router.delegate()
|
||||
|
22
apps/silk/BaseController.lua
Normal file
22
apps/silk/BaseController.lua
Normal file
@ -0,0 +1,22 @@
|
||||
-- create class
|
||||
BaseController = Object:extends{registry = {}, models = {}}
|
||||
-- set the name here in each subclasses
|
||||
function BaseController:initialize()
|
||||
-- create model object here
|
||||
--- infer the class here
|
||||
end
|
||||
|
||||
function BaseController:redirect()
|
||||
end
|
||||
|
||||
function BaseController:checkSession(key)
|
||||
end
|
||||
function BaseController:setSession(key)
|
||||
end
|
||||
function BaseController:getSession(key)
|
||||
end
|
||||
function BaseController:removeSession(key)
|
||||
end
|
||||
function BaseController:index()
|
||||
error("#index: subclasses responsibility")
|
||||
end
|
21
apps/silk/BaseModel.lua
Normal file
21
apps/silk/BaseModel.lua
Normal file
@ -0,0 +1,21 @@
|
||||
-- This is the base model class
|
||||
require("OOP")
|
||||
require("sqlite")
|
||||
-- create class
|
||||
BaseModel = Object:extends{registry = {}, name = ""}
|
||||
|
||||
function BaseModel:initialize()
|
||||
end
|
||||
|
||||
function BaseModel:create()
|
||||
end
|
||||
|
||||
function BaseModel:update()
|
||||
end
|
||||
|
||||
function BaseModel:delete()
|
||||
end
|
||||
|
||||
|
||||
function BaseModel:findAll(cond)
|
||||
end
|
20
apps/silk/Logger.lua
Normal file
20
apps/silk/Logger.lua
Normal file
@ -0,0 +1,20 @@
|
||||
Logger = Object:extends{registry = {}, levels = {}}
|
||||
|
||||
function Logger:initialize()
|
||||
end
|
||||
|
||||
function Logger:log(msg,level)
|
||||
end
|
||||
|
||||
function Logger:info(msg)
|
||||
self.log(msg, "INFO")
|
||||
end
|
||||
|
||||
function Logger:debug(msg)
|
||||
self.log(msg, "DEBUG")
|
||||
end
|
||||
|
||||
|
||||
function Logger:error(msg)
|
||||
self.log(msg, "ERROR")
|
||||
end
|
35
apps/silk/Router.lua
Normal file
35
apps/silk/Router.lua
Normal file
@ -0,0 +1,35 @@
|
||||
|
||||
--define the class
|
||||
Router = Object:extends{registry = {}}
|
||||
function Router:setPath(path)
|
||||
self.path = path
|
||||
end
|
||||
|
||||
function Router:initialize()
|
||||
self.args = {}
|
||||
self.routes = {}
|
||||
end
|
||||
|
||||
function Router:setArgs(args)
|
||||
self.args = args
|
||||
end
|
||||
|
||||
function Router:arg(name)
|
||||
return self.args[name]
|
||||
end
|
||||
|
||||
function Router:getController(url)
|
||||
-- TODO
|
||||
end
|
||||
|
||||
function Router:delegate()
|
||||
-- TODO
|
||||
end
|
||||
|
||||
|
||||
function Router:setInitRoute(name, url, visibility)
|
||||
self.routes[name] = {
|
||||
url = url,
|
||||
visibility = visibility
|
||||
}
|
||||
end
|
21
apps/silk/Template.lua
Normal file
21
apps/silk/Template.lua
Normal file
@ -0,0 +1,21 @@
|
||||
-- This is the base model class
|
||||
require("OOP")
|
||||
-- create class
|
||||
Template = Object:extends{registry = {}}
|
||||
|
||||
function Template:initialize()
|
||||
self.vars = {}
|
||||
end
|
||||
|
||||
function Template:set(k, v, ow)
|
||||
end
|
||||
|
||||
function Template:remove(k)
|
||||
end
|
||||
|
||||
-- infer view path
|
||||
function setView(name, controller)
|
||||
end
|
||||
-- render the page
|
||||
function render()
|
||||
end
|
11
apps/silk/api.lua
Normal file
11
apps/silk/api.lua
Normal file
@ -0,0 +1,11 @@
|
||||
require("OOP")
|
||||
require("sqlite")
|
||||
require("silk.Router")
|
||||
require("silk.BaseController")
|
||||
require("silk.BaseModel")
|
||||
require("silk.Logger")
|
||||
require("silk.Template")
|
||||
|
||||
function Object:extends(o)
|
||||
return self:inherit(o)
|
||||
end
|
@ -1,7 +0,0 @@
|
||||
-- This is the base model class
|
||||
require("OOP")
|
||||
-- create class
|
||||
BaseController = Object:inherit{db=nil, name=''}
|
||||
|
||||
function BaseController:do()
|
||||
end
|
@ -1,8 +0,0 @@
|
||||
-- This is the base model class
|
||||
require("OOP")
|
||||
require("sqlite")
|
||||
-- create class
|
||||
BaseModel = Object:inherit{db=nil, name=''}
|
||||
|
||||
function BaseModel:do()
|
||||
end
|
@ -1,7 +0,0 @@
|
||||
-- This is the base model class
|
||||
require("OOP")
|
||||
-- create class
|
||||
BaseView = Object:inherit{db=nil, name=''}
|
||||
|
||||
function BaseView:do()
|
||||
end
|
Loading…
Reference in New Issue
Block a user