Commit db70500c authored by Ted Trask's avatar Ted Trask

Change listfiles filesize to size, size and mtime not user-friendly, use...

Change listfiles filesize to size, size and mtime not user-friendly, use posix.stat over fs.stat, use new format functions
parent 9297525f
...@@ -3,20 +3,6 @@ htmlviewfunctions = require("htmlviewfunctions") ...@@ -3,20 +3,6 @@ htmlviewfunctions = require("htmlviewfunctions")
html = require("acf.html") 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"> <script type="text/javascript">
if (typeof jQuery == 'undefined') { if (typeof jQuery == 'undefined') {
document.write('<script type="text/javascript" src="<%= html.html_escape(page_info.wwwprefix) %>/js/jquery-latest.js"><\/script>'); document.write('<script type="text/javascript" src="<%= html.html_escape(page_info.wwwprefix) %>/js/jquery-latest.js"><\/script>');
...@@ -57,7 +43,7 @@ end %> ...@@ -57,7 +43,7 @@ end %>
<tr> <tr>
<td><% htmlviewfunctions.displayitem(cfe({type="link", value={filename=filename, redir=redir}, label="", option="Edit", action="expert"}), page_info, -1) %></td> <td><% htmlviewfunctions.displayitem(cfe({type="link", value={filename=filename, redir=redir}, label="", option="Edit", action="expert"}), page_info, -1) %></td>
<td><%= html.html_escape(file.filename) %></td> <td><%= html.html_escape(file.filename) %></td>
<td><span class="hide"><%= convertsize(file.filesize) %>b</span><%= html.html_escape(file.filesize) %></td> <td><span class="hide"><%= html.html_escape(file.size or 0) %>b</span><%= format.formatfilesize(file.size) %></td>
<td><%= html.html_escape(file.mtime) %></td> <td><%= html.html_escape(file.mtime) %></td>
</tr> </tr>
<% end %> <% end %>
......
...@@ -73,13 +73,14 @@ function mymodule.getfilelist() ...@@ -73,13 +73,14 @@ function mymodule.getfilelist()
local listed_files = {} local listed_files = {}
for i,name in ipairs(filelist) do for i,name in ipairs(filelist) do
local filedetails = fs.stat(name) or {} local filedetails = posix.stat(name) or {}
table.insert ( listed_files , {filename=name, mtime=filedetails.mtime or "---", filesize=filedetails.size or "0"} ) filedetails.filename=name
table.insert(listed_files, filedetails)
end end
table.sort(listed_files, function (a,b) return (a.filename < b.filename) end ) table.sort(listed_files, function (a,b) return (a.filename < b.filename) end )
return cfe({ type="list", value=listed_files, label="Lighttpd File List" }) return cfe({ type="structure", value=listed_files, label="Lighttpd File List" })
end end
function mymodule.getfiledetails(filename) function mymodule.getfiledetails(filename)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment