summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2015-12-30 14:11:02 +0000
committerTed Trask <ttrask01@yahoo.com>2015-12-30 14:11:02 +0000
commit6e61bf8def93b609398c723b15017989d00cb320 (patch)
treee350937c3c00d2456f13982cf8bb28a7cc39faa8
parente64af24d6521807a5beae3d1aa6e9d74c4acf138 (diff)
downloadacf-squid-6e61bf8def93b609398c723b15017989d00cb320.tar.bz2
acf-squid-6e61bf8def93b609398c723b15017989d00cb320.tar.xz
Change listfiles to return cfe structure with details rather than list
-rw-r--r--squid-listfiles-html.lsp8
-rw-r--r--squid-model.lua32
2 files changed, 27 insertions, 13 deletions
diff --git a/squid-listfiles-html.lsp b/squid-listfiles-html.lsp
index d1ff90f..6a1b1f3 100644
--- a/squid-listfiles-html.lsp
+++ b/squid-listfiles-html.lsp
@@ -33,6 +33,8 @@ end %>
<tr>
<th>Action</th>
<th>File</th>
+ <th>Size</th>
+ <th>Last Modified</th>
</tr>
</thead><tbody>
<% local filename = cfe({ type="hidden", value="" }) %>
@@ -41,7 +43,7 @@ end %>
<tr>
<td>
<%
- filename.value = file
+ filename.value = file.filename
if viewlibrary.check_permission("editfile") then
htmlviewfunctions.displayitem(cfe({type="link", value={filename=filename, redir=redir}, label="", option="Edit", action="editfile"}), page_info, -1)
end
@@ -50,7 +52,9 @@ end %>
end
%>
</td>
- <td><%= html.html_escape(file) %></td>
+ <td><%= html.html_escape(file.filename) %></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>
</tr>
<% end %>
</tbody></table>
diff --git a/squid-model.lua b/squid-model.lua
index a3f3989..1f818f3 100644
--- a/squid-model.lua
+++ b/squid-model.lua
@@ -35,6 +35,19 @@ local validate_config = function(newconfig)
return success, newconfig
end
+local getfilelist = function()
+ local filelist = {}
+ if not fs.is_dir(baseurl) then fs.create_directory(baseurl) end
+ for file in posix.files(baseurl) do
+ file = baseurl..file
+ if fs.is_file(file) and file ~= squidconf and file ~= squiddigestusers then
+ table.insert(filelist, file)
+ end
+ end
+ table.sort(filelist)
+ return filelist
+end
+
mymodule.getstatus = function()
return modelfunctions.getstatus(processname, packagename, "Squid status")
end
@@ -358,15 +371,12 @@ end
--]]
function mymodule.listfiles()
- local retval = cfe({ type="list", value={}, label="Squid Files" })
- if not fs.is_dir(baseurl) then fs.create_directory(baseurl) end
- for file in posix.files(baseurl) do
- file = baseurl..file
- if fs.is_file(file) and file ~= squidconf and file ~= squiddigestusers then
- table.insert(retval.value, file)
- end
+ local retval = cfe({ type="structure", value={}, label="Squid Files" })
+ for i,file in ipairs(getfilelist()) do
+ local filedetails = posix.stat(file)
+ filedetails.filename = file
+ table.insert(retval.value, filedetails)
end
- table.sort(retval.value)
return retval
end
@@ -403,11 +413,11 @@ function mymodule.createfile(self, filedetails)
end
function mymodule.readfile(filename)
- return modelfunctions.getfiledetails(filename, mymodule.listfiles().value)
+ return modelfunctions.getfiledetails(filename, getfilelist())
end
function mymodule.updatefile(self, filedetails)
- return modelfunctions.setfiledetails(self, filedetails, mymodule.listfiles().value)
+ return modelfunctions.setfiledetails(self, filedetails, getfilelist())
end
function mymodule.getdeletefile(self, clientdata)
@@ -419,7 +429,7 @@ end
function mymodule.deletefile(self, delfile)
delfile.errtxt = "Failed to delete Squid File"
delfile.value.filename.errtxt = "Invalid filename"
- for i,file in ipairs(mymodule.listfiles().value) do
+ for i,file in ipairs(getfilelist()) do
if delfile.value.filename.value == file then
delfile.errtxt = nil
delfile.value.filename.errtxt = nil