1
0
mirror of https://github.com/lxsang/antd-web-apps synced 2024-11-20 02:18:20 +01:00
antd-web-apps/blog/view.lua
2018-02-25 02:31:13 +01:00

38 lines
922 B
Lua

local view = {}
view.html = function(name)
local path = BLOG_ROOT.."/view/"..name..".html"
if unix.exists(path) then
std.f(path)
else
echo("Cannot find "..path)
end
end
view.render = function(action, data, sort)
local path = BLOG_ROOT.."/view"
local fn = nil
local e
if action == "id" then
--echo(bytes.__tostring(std.b64decode(data[0].rendered)):gsub("%%","%%%%"))
--return true
fn, e = loadscript(path.."/detail.ls")
--echo(data[0].rendered)
--fn = require("blog.view.compiledd")
else
--fn = require("blog.view.compiledd")
fn, e = loadscript(path.."/entries.ls")
end
if fn then
local r,o = pcall(fn, data, sort)
if not r then
echo(o)
end
else
loadscript(path.."/top.ls")("Welcome to my blog")
echo(e)
end
view.html("bot")
end
return view