1
0
mirror of https://github.com/lxsang/antd-web-apps synced 2024-12-29 02:38:22 +01:00
antd-web-apps/blog/view.lua

40 lines
1.0 KiB
Lua
Raw Normal View History

2018-02-23 19:52:10 +01:00
local view = {}
view.html = function(name)
local path = BLOG_ROOT.."/view/"..name..".html"
2018-02-25 01:57:42 +01:00
if unix.exists(path) then
std.f(path)
2018-02-23 19:52:10 +01:00
else
echo("Cannot find "..path)
end
end
2018-03-07 14:18:25 +01:00
view.render = function(action, data, sort, min, max)
2018-02-23 19:52:10 +01:00
local path = BLOG_ROOT.."/view"
2018-02-24 19:14:46 +01:00
local fn = nil
local e
2018-02-23 19:52:10 +01:00
if action == "id" then
2018-02-25 01:57:42 +01:00
--echo(bytes.__tostring(std.b64decode(data[0].rendered)):gsub("%%","%%%%"))
--return true
2018-02-24 19:14:46 +01:00
fn, e = loadscript(path.."/detail.ls")
2018-02-25 01:57:42 +01:00
--echo(data[0].rendered)
--fn = require("blog.view.compiledd")
2018-06-05 14:36:39 +02:00
elseif action == "analyse" then
fn, e = loadscript(path.."/analyse.ls")
2018-02-23 19:52:10 +01:00
else
2018-02-25 01:57:42 +01:00
--fn = require("blog.view.compiledd")
2018-02-25 02:31:13 +01:00
2018-02-24 19:14:46 +01:00
fn, e = loadscript(path.."/entries.ls")
end
if fn then
2018-03-07 14:18:25 +01:00
local r,o = pcall(fn, data, sort, min, max, action)
2018-02-25 01:57:42 +01:00
if not r then
echo(o)
end
2018-02-24 19:14:46 +01:00
else
2018-02-25 02:31:13 +01:00
loadscript(path.."/top.ls")("Welcome to my blog")
2018-02-24 19:14:46 +01:00
echo(e)
2018-02-23 19:52:10 +01:00
end
view.html("bot")
end
return view