diff --git a/info/controllers/IndexController.lua b/info/controllers/IndexController.lua index 54727bd..48f1ec8 100644 --- a/info/controllers/IndexController.lua +++ b/info/controllers/IndexController.lua @@ -1,38 +1,40 @@ - BaseController:subclass("IndexController", +BaseController:subclass( + "IndexController", { registry = {}, - models = { "sections", "category" } - }) + models = {"sections", "category"} + } +) local sectionsByCid = function(db, id) - local cond = { exp = { ["="] = { cid = id } } , order = { start = "DESC" } } + local cond = {exp = {["="] = {cid = id}}, order = {start = "DESC"}} local data, a = db:find(cond) - return data,a + return data, a end function IndexController:index(...) local args = {...} -- now read all the data -- get all root sections as the toc - local cond = { exp = { ["="] = { pid = 0 } }, order = { name = "ASC" } } + local cond = {exp = {["="] = {pid = 0}}, order = {name = "ASC"}} local data, a = self.category:find(cond) local toc = {} if not data then return self:error("Cannot query the ToC") end -- find all children category of the toc - for key,cat in pairs(data) do - cat.name = cat.name:gsub("^%d+%.","") - table.insert( toc, {cat.name, cat.id} ) - cond = { exp = { ["="] = { pid = cat.id } }, order = { name = "ASC" } } + for key, cat in pairs(data) do + cat.name = cat.name:gsub("^%d+%.", "") + table.insert(toc, {cat.name, cat.id}) + cond = {exp = {["="] = {pid = cat.id}}, order = {name = "ASC"}} local children, b = self.category:find(cond) if children and #children > 0 then - for k,v in pairs(children) do - v.sections = sectionsByCid(self.sections,v.id) + for k, v in pairs(children) do + v.sections = sectionsByCid(self.sections, v.id) end cat.children = children else - cat.sections = sectionsByCid(self.sections,cat.id) + cat.sections = sectionsByCid(self.sections, cat.id) end end self.template:set("data", data) @@ -47,4 +49,4 @@ end function IndexController:actionnotfound(...) return self:notoc(table.unpack({...})) -end \ No newline at end of file +end diff --git a/info/controllers/UserController.lua b/info/controllers/UserController.lua index 1bea4a4..77aab0b 100644 --- a/info/controllers/UserController.lua +++ b/info/controllers/UserController.lua @@ -1,13 +1,16 @@ -BaseController:subclass("UserController",{ - models = {"user"} -}) +BaseController:subclass( + "UserController", + { + models = {"user"} + } +) function UserController:index(...) local args = {...} local data = self.user:findAll() - if not data or not data[1] then + if not data or not data[1] then self:error("Cannot fetch user info") end self.template:set("data", data[1]) return true -end \ No newline at end of file +end diff --git a/silk/BaseObject.lua b/silk/BaseObject.lua index 4cd9e7b..efc5935 100644 --- a/silk/BaseObject.lua +++ b/silk/BaseObject.lua @@ -21,6 +21,7 @@ end function BaseObject:error(msg, trace) html() + --local line = debug.getinfo(1).currentline echo(msg) self:log(msg,"ERROR") if trace then