1
0
mirror of https://github.com/lxsang/antd-web-apps synced 2024-11-20 02:18:20 +01:00

allow controller to change view layout

This commit is contained in:
Xuan Sang LE 2018-08-22 19:50:52 +02:00
parent 0ee4a9314f
commit 3eefab1bdb
4 changed files with 6 additions and 28 deletions

View File

@ -18,6 +18,7 @@ function PostController:edit(...)
else
self.template:set("auth", false)
end
self:setLayout("admin")
--self:redirect("/category/put/1")
return true
end

View File

@ -1,27 +0,0 @@
<html>
<head>
<title>Application pages</title>
<!--link rel="stylesheet" type="text/css" href="<?=HTTP_ROOT?>/asset/get/grs/ubuntu-regular.css" />
<link rel="stylesheet" type="text/css" href="<?=HTTP_ROOT?>/asset/get/style.css" />
<link rel="stylesheet" type="text/css" href="<?=HTTP_ROOT?>/asset/get/rst/font-awesome.css" />
<script type="text/javascript" src="<?=HTTP_ROOT?>/asset/get/rst/gscripts/riot.min.js"> </script>
<script type="text/javascript" src="<?=HTTP_ROOT?>/asset/get/rst/resources/antos_tags.js"></script>
<script type="text/javascript" src="<?=HTTP_ROOT?>/asset/get/rst/gscripts/jquery-3.2.1.min.js"> </script>
<script type="text/javascript" src="<?=HTTP_ROOT?>/asset/get/rst/main.js"></script>
<script type="text/javascript" src="<?=HTTP_ROOT?>/asset/get/rst/gscripts/showdown.min.js"></script-->
</head>
<body>
<div id="desktop">
<?lua
local args = {...}
local views = args[1]
for k, v in pairs(views) do
echo(k.." -> ")
v:render()
echo("<br/>")
end
--views.__main__:render()
?>
</div>
</body>
</html>

View File

@ -27,6 +27,10 @@ function BaseController:redirect(url)
std.header_flush()
end
function BaseController:setLayout(name)
self.registry.layout = name
end
function BaseController:setSession(key, value)
SESSION[key] = value
end

View File

@ -75,7 +75,7 @@ function Router:delegate()
end
-- now require the main page to put the view
local fn, e = loadscript(WWW_ROOT..DIR_SEP.."index.ls")
local fn, e = loadscript(VIEW_ROOT..DIR_SEP..self.registry.layout..DIR_SEP.."index.ls")
html()
if fn then
local r,o = pcall(fn, views)