diff options
-rw-r--r-- | tinydns-controller.lua | 9 | ||||
-rw-r--r-- | tinydns-edit-html.lsp | 2 | ||||
-rw-r--r-- | tinydns-listfiles-html.lsp | 22 | ||||
-rw-r--r-- | tinydns-model.lua | 9 |
4 files changed, 14 insertions, 28 deletions
diff --git a/tinydns-controller.lua b/tinydns-controller.lua index 9af5d36..1e1953e 100644 --- a/tinydns-controller.lua +++ b/tinydns-controller.lua @@ -31,14 +31,7 @@ function mymodule.newfile(self) end function mymodule.listfiles(self) - local configfiles = self.model.getfilelist(self, self.sessiondata.userinfo.userid) - local config = {} - for k,v in pairs(configfiles.value) do - local filedetails = self.model.get_filedetails(self, v, self.sessiondata.userinfo.userid) - table.insert(config,filedetails) - end - - return cfe({ type="list", value=config, label="Config files" }) + return self.model.getfilelist(self, self.sessiondata.userinfo.userid) end function mymodule.edit(self) diff --git a/tinydns-edit-html.lsp b/tinydns-edit-html.lsp index 0b14b36..212f222 100644 --- a/tinydns-edit-html.lsp +++ b/tinydns-edit-html.lsp @@ -211,7 +211,7 @@ end header_level2 = htmlviewfunctions.displaysectionstart(cfe({label="File Details"}), page_info, htmlviewfunctions.incrementheader(header_level)) htmlviewfunctions.displayitem(form.value.filename) -htmlviewfunctions.displayitem(form.value.filesize) +htmlviewfunctions.displayitem(form.value.size) htmlviewfunctions.displayitem(form.value.mtime) if form.value.grep and form.value.grep.value and form.value.grep.value ~= "" then htmlviewfunctions.displayitem(form.value.grep) diff --git a/tinydns-listfiles-html.lsp b/tinydns-listfiles-html.lsp index 098b97a..8a35d4f 100644 --- a/tinydns-listfiles-html.lsp +++ b/tinydns-listfiles-html.lsp @@ -3,20 +3,6 @@ htmlviewfunctions = require("htmlviewfunctions") html = require("acf.html") %> -<% -function convertsize(size) - if string.find(size, "k$") then - return tonumber(string.match(size, "[%d.]*")) * 1024.0 - elseif string.find(size, "M$") then - return tonumber(string.match(size, "[%d.]*")) * 1024.0 * 1024.0 - elseif string.find(size, "G$") then - return tonumber(string.match(size, "[%d.]*")) + 1024.0 * 1024.0 * 1024.0 - else - return tonumber(string.match(size, "[%d.]*")) - end -end -%> - <script type="text/javascript"> if (typeof jQuery == 'undefined') { document.write('<script type="text/javascript" src="<%= html.html_escape(page_info.wwwprefix) %>/js/jquery-latest.js"><\/script>'); @@ -56,7 +42,7 @@ local header_level2 = htmlviewfunctions.displaysectionstart(cfe({label="Edit/Vie <tr> <td> <% - filename.value = file.value.filename.value + filename.value = file.filename htmlviewfunctions.displayitem(cfe({type="link", value={filename=filename}, label="", option="View", action="view"}), page_info, -1) if viewlibrary.check_permission("edit") then htmlviewfunctions.displayitem(cfe({type="link", value={filename=filename, redir=redir}, label="", option="Edit", action="edit"}), page_info, -1) @@ -69,9 +55,9 @@ local header_level2 = htmlviewfunctions.displaysectionstart(cfe({label="Edit/Vie end %> </td> - <td><span class="hide"><%= convertsize(file.value.filesize.value) %>b</span><%= html.html_escape(file.value.filesize.value) %></td> - <td><%= html.html_escape(file.value.mtime.value) %></td> - <td><%= html.html_escape(string.gsub(file.value.filename.value, "^.*/", "")) %></td> + <td><span class="hide"><%= html.html_escape(file.size or 0) %>b</span><%= format.formatfilesize(file.size) %></td> + <td><%= format.formattime(file.mtime) %></td> + <td><%= html.html_escape(string.gsub(file.filename, "^.*/", "")) %></td> </tr> <% end %> </tbody></table> diff --git a/tinydns-model.lua b/tinydns-model.lua index b44d45a..16a95dd 100644 --- a/tinydns-model.lua +++ b/tinydns-model.lua @@ -271,7 +271,14 @@ end function mymodule.getfilelist(self, userid) configfiles = searchforconfigfiles(self, userid) - return cfe({ type="list", value=configfiles, label="List of config files" }) + local listed_files = {} + for i,name in pairs(configfiles) do + local filedetails = posix.stat(name) or {} + filedetails.filename = name + table.insert(listed_files, filedetails) + end + + return cfe({ type="structure", value=listed_files, label="Config files" }) end function mymodule.get_filedetails(self, path, userid) |