summaryrefslogtreecommitdiffstats
path: root/weblog-listfiles-html.lsp
blob: 673afa8977d6ff0a317acc5b527069d446b000bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<% local view, viewlibrary, page_info, session = ... 
htmlviewfunctions = require("htmlviewfunctions")
html = require("acf.html")
%>

<%
function convertsize(size)
	if string.find(size, "k$") then
		return tonumber(string.match(size, "%d*")) * 1024
	elseif string.find(string.match(size, "%d*"), "M$") then
		return tonumber(size) * 1024 * 1024
	elseif string.find(size, "G$") then
		return tonumber(string.match(size, "%d*")) + 1024 * 1024 * 1024
	else
		return tonumber(size)
	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>');
	}
</script>

<script type="text/javascript">
	if (typeof $.tablesorter == 'undefined') {
		document.write('<script type="text/javascript" src="<%= html.html_escape(page_info.wwwprefix) %>/js/jquery.tablesorter.js"><\/script>');
	}
</script>

<script type="text/javascript">
	$(document).ready(function() {
		$("#files").tablesorter({headers: {1:{sorter: 'digit'}, 2:{sorter: 'usLongDate'}}, widgets: ['zebra']});
	});
</script>

<% htmlviewfunctions.displaycommandresults({"editfile"}, session) %>

<h1>File List</h1>
<table id="files" class="tablesorter"><thead>
	<tr>
		<th>File</th>
		<th>Size</th>
		<th>Last Modified</th>
	</tr>
</thead><tbody>
	<% for k,v in ipairs( view.value ) do
		io.write( "<tr><td><a href=\"" .. html.html_escape(page_info.script .. page_info.prefix .. page_info.controller) .. "/editfile?filename=" .. html.html_escape(v.filename) .. "&redir=" .. html.html_escape(page_info.orig_action) .. "\">" .. html.html_escape(v.filename) .. '</a></td><td><span style="display:none">'..convertsize(v.size).."b</span>" .. html.html_escape(v.size) .."</td><td>" .. html.html_escape(v.mtime) .."</td></tr>\n" )
	end %>
</tbody></table>