diff --git a/blog/view.lua b/blog/view.lua index b5a6cf6..1ccecad 100644 --- a/blog/view.lua +++ b/blog/view.lua @@ -14,14 +14,18 @@ end view.render = function(action, data, sort) view.html("top") local path = BLOG_ROOT.."/view" + local fn = nil + local e if action == "id" then - _G.dbmodel = data[0] - doscript(path.."/detail.ls") + fn, e = loadscript(path.."/detail.ls") else - _G.dbmodel = { data = data, order = sort } - doscript(path.."/entries.ls") + fn, e = loadscript(path.."/entries.ls") + end + if fn then + fn(data, sort) + else + echo(e) end - _G.dbmodel = nil view.html("bot") end return view \ No newline at end of file diff --git a/blog/view/detail.ls b/blog/view/detail.ls index 0e4fd60..5c7d767 100644 --- a/blog/view/detail.ls +++ b/blog/view/detail.ls @@ -1,6 +1,8 @@
No entry found
@@ -11,6 +13,8 @@No entry found
@@ -13,8 +15,8 @@ return end - for idx,v in pairs(model.order) do - local data = model.data[v] + for idx,v in pairs(order) do + local data = datas[v] ?>