mirror of
https://github.com/lxsang/antd-web-apps
synced 2024-11-19 18:08:21 +01:00
fix
This commit is contained in:
parent
b07da22b52
commit
5f5c165f0b
@ -17,9 +17,6 @@ LOG_ROOT = WWW_ROOT..DIR_SEP.."logs"
|
||||
|
||||
-- require needed library
|
||||
require(BASE_FRW.."silk.api")
|
||||
-- need to define this
|
||||
-- basically it initialize an session object
|
||||
-- session_start()
|
||||
|
||||
-- registry object store global variables
|
||||
local REGISTRY = {}
|
||||
|
@ -1,6 +1,6 @@
|
||||
BUILDDIR = ../build/info
|
||||
|
||||
copyfiles = index.ls style.css
|
||||
copyfiles = index.ls style.css router.lua models views controllers
|
||||
|
||||
main:
|
||||
- mkdir $(BUILDDIR)
|
||||
|
10
info/controllers/IndexController.lua
Normal file
10
info/controllers/IndexController.lua
Normal file
@ -0,0 +1,10 @@
|
||||
IndexController = BaseController:extends{
|
||||
class = "IndexController",
|
||||
registry = {},
|
||||
models = { "sections", "user", "category" }
|
||||
}
|
||||
|
||||
function IndexController:index(...)
|
||||
local args = {...}
|
||||
return true
|
||||
end
|
9
info/models/CategoryModel.lua
Normal file
9
info/models/CategoryModel.lua
Normal file
@ -0,0 +1,9 @@
|
||||
CategoryModel = BaseModel:extends{
|
||||
registry = {},
|
||||
name = "cv_cat",
|
||||
fields = {
|
||||
publish = "NUMERIC",
|
||||
name = "TEXT",
|
||||
pid = "NUMERIC"
|
||||
}
|
||||
}
|
13
info/models/SectionsModel.lua
Normal file
13
info/models/SectionsModel.lua
Normal file
@ -0,0 +1,13 @@
|
||||
SectionsModel = BaseModel:extends{
|
||||
name = "cv_sections",
|
||||
fields = {
|
||||
title = "TEXT",
|
||||
start = "NUMERIC",
|
||||
location = "TEXT",
|
||||
["end"] = "NUMERIC",
|
||||
content = "TEXT",
|
||||
subtitle = "TEXT",
|
||||
publish = "NUMERIC",
|
||||
cid = "NUMERIC",
|
||||
}
|
||||
}
|
12
info/models/UserModel.lua
Normal file
12
info/models/UserModel.lua
Normal file
@ -0,0 +1,12 @@
|
||||
UserModel = BaseModel:extends{
|
||||
registry = {},
|
||||
name = "user",
|
||||
fields = {
|
||||
address = "TEXT",
|
||||
Phone = "TEXT",
|
||||
shortbiblio = "TEXT",
|
||||
fullname = "TEXT",
|
||||
email = "TEXT",
|
||||
url = "TEXT"
|
||||
}
|
||||
}
|
54
info/router.lua
Normal file
54
info/router.lua
Normal file
@ -0,0 +1,54 @@
|
||||
|
||||
-- the rewrite rule for the framework
|
||||
-- should be something like this
|
||||
-- ^\/apps\/+(.*)$ = /apps/router.lua?r=<1>&<query>
|
||||
-- some global variables
|
||||
DIR_SEP = "/"
|
||||
WWW_ROOT = "/opt/www/htdocs/info"
|
||||
HTTP_ROOT = "https://apps.localhost:9195/"
|
||||
-- class path: path.to.class
|
||||
BASE_FRW = ""
|
||||
-- class path: path.to.class
|
||||
CONTROLLER_ROOT = BASE_FRW.."info.controllers"
|
||||
MODEL_ROOT = BASE_FRW.."info.models"
|
||||
-- file path: path/to/file
|
||||
VIEW_ROOT = WWW_ROOT..DIR_SEP.."views"
|
||||
LOG_ROOT = WWW_ROOT..DIR_SEP.."logs"
|
||||
|
||||
-- require needed library
|
||||
require(BASE_FRW.."silk.api")
|
||||
|
||||
-- registry object store global variables
|
||||
local REGISTRY = {}
|
||||
-- set logging level
|
||||
REGISTRY.logger = Logger:new{ levels = {INFO = true, ERROR = true, DEBUG = true}}
|
||||
REGISTRY.db = DBHelper:new{db="mrsang"}
|
||||
REGISTRY.layout = 'default'
|
||||
|
||||
REGISTRY.db:open()
|
||||
local router = Router:new{registry = REGISTRY}
|
||||
REGISTRY.router = router
|
||||
router:setPath(CONTROLLER_ROOT)
|
||||
--router:route('edit', 'post/edit', "ALL" )
|
||||
|
||||
-- example of depedencies to the current main route
|
||||
-- each layout may have different dependencies
|
||||
local default_routes_dependencies = {
|
||||
edit = {
|
||||
url = "post/edit",
|
||||
visibility = {
|
||||
shown = true,
|
||||
routes = {
|
||||
["post/index"] = true
|
||||
}
|
||||
}
|
||||
},
|
||||
--category = {
|
||||
-- url = "cat/index",
|
||||
-- visibility = "ALL"
|
||||
--}
|
||||
}
|
||||
router:route('default', default_routes_dependencies )
|
||||
router:delegate()
|
||||
if REGISTRY.db then REGISTRY.db:close() end
|
||||
|
3
info/views/default/index/index.ls
Normal file
3
info/views/default/index/index.ls
Normal file
@ -0,0 +1,3 @@
|
||||
<?lua
|
||||
echo("main page")
|
||||
?>
|
9
info/views/default/layout.ls
Normal file
9
info/views/default/layout.ls
Normal file
@ -0,0 +1,9 @@
|
||||
<?lua
|
||||
echo("<h1>Default page</h1>")
|
||||
|
||||
local args = {...}
|
||||
local views = args[1]
|
||||
if views.__main__ then
|
||||
views.__main__:render()
|
||||
end
|
||||
?>
|
@ -77,7 +77,7 @@ function Router:delegate()
|
||||
end
|
||||
-- now require the main page to put the view
|
||||
|
||||
local fn, e = loadscript(VIEW_ROOT..DIR_SEP..self.registry.layout..DIR_SEP.."index.ls")
|
||||
local fn, e = loadscript(VIEW_ROOT..DIR_SEP..self.registry.layout..DIR_SEP.."layout.ls")
|
||||
html()
|
||||
if fn then
|
||||
local r,o = pcall(fn, views)
|
||||
|
54
silk/router.lua.tpl
Normal file
54
silk/router.lua.tpl
Normal file
@ -0,0 +1,54 @@
|
||||
|
||||
-- the rewrite rule for the framework
|
||||
-- should be something like this
|
||||
-- ^\/apps\/+(.*)$ = /apps/router.lua?r=<1>&<query>
|
||||
-- some global variables
|
||||
DIR_SEP = "/"
|
||||
WWW_ROOT = "/opt/www/htdocs/apps"
|
||||
HTTP_ROOT = "https://apps.localhost:9195/"
|
||||
-- class path: path.to.class
|
||||
BASE_FRW = ""
|
||||
-- class path: path.to.class
|
||||
CONTROLLER_ROOT = BASE_FRW.."apps.controllers"
|
||||
MODEL_ROOT = BASE_FRW.."apps.models"
|
||||
-- file path: path/to/file
|
||||
VIEW_ROOT = WWW_ROOT..DIR_SEP.."views"
|
||||
LOG_ROOT = WWW_ROOT..DIR_SEP.."logs"
|
||||
|
||||
-- require needed library
|
||||
require(BASE_FRW.."silk.api")
|
||||
|
||||
-- registry object store global variables
|
||||
local REGISTRY = {}
|
||||
-- set logging level
|
||||
REGISTRY.logger = Logger:new{ levels = {INFO = true, ERROR = true, DEBUG = true}}
|
||||
REGISTRY.db = DBHelper:new{db="iosapps"}
|
||||
REGISTRY.layout = 'default'
|
||||
|
||||
REGISTRY.db:open()
|
||||
local router = Router:new{registry = REGISTRY}
|
||||
REGISTRY.router = router
|
||||
router:setPath(CONTROLLER_ROOT)
|
||||
--router:route('edit', 'post/edit', "ALL" )
|
||||
|
||||
-- example of depedencies to the current main route
|
||||
-- each layout may have different dependencies
|
||||
local default_routes_dependencies = {
|
||||
edit = {
|
||||
url = "post/edit",
|
||||
visibility = {
|
||||
shown = true,
|
||||
routes = {
|
||||
["post/index"] = true
|
||||
}
|
||||
}
|
||||
},
|
||||
--category = {
|
||||
-- url = "cat/index",
|
||||
-- visibility = "ALL"
|
||||
--}
|
||||
}
|
||||
router:route('default', default_routes_dependencies )
|
||||
router:delegate()
|
||||
if REGISTRY.db then REGISTRY.db:close() end
|
||||
|
Loading…
Reference in New Issue
Block a user