end
function action_download(...)
+ local fs = require "nixio.fs"
local argv = parse_cmdline(...)
if argv then
local fd = io.popen(table.concat(argv, " ") .. " 2>/dev/null")
local name
if chunk:match("[%z\1-\8\14-\31]") then
luci.http.header("Content-Disposition", "attachment; filename=%s"
- % argv[1]:gsub("%W+", ".") .. ".bin")
+ % fs.basename(argv[1]):gsub("%W+", ".") .. ".bin")
luci.http.prepare_content("application/octet-stream")
else
luci.http.header("Content-Disposition", "attachment; filename=%s"
- % argv[1]:gsub("%W+", ".") .. ".txt")
+ % fs.basename(argv[1]):gsub("%W+", ".") .. ".txt")
luci.http.prepare_content("text/plain")
end
-%>
+<% css = [[
+
+.commandbox {
+ height: 12em;
+ width: 30%;
+ float: left;
+ height: 12em;
+ margin: 5px;
+ position: relative;
+}
+
+.commandbox h3 {
+ font-size: 1.5em !important;
+ line-height: 2em !important;
+ margin: 0 !important;
+}
+
+.commandbox input[type="text"] {
+ width: 50% !important;
+}
+
+.commandbox div {
+ position: absolute;
+ left: 0;
+ bottom: 1.5em;
+}
+
+]] -%>
+
<%+header%>
<script type="text/javascript" src="<%=resource%>/cbi.js"></script>
legend.style.display = 'none';
output.parentNode.style.display = 'block';
output.innerHTML = String.format(
- '<div class="alert-message warning"><%:Access command with%> <a href="%s">%s</a></div>',
+ '<div class="alert-message"><%:Access command with%> <a href="%s">%s</a></div>',
link, link
);
<fieldset class="cbi-section">
<% local _, command; for _, command in ipairs(commands) do %>
- <div style="width:30%; float:left; height:150px; position:relative">
+ <div class="commandbox">
<h3><%=pcdata(command.name)%></h3>
<p><%:Command:%> <code><%=pcdata(command.command)%></code></p>
<% if command.param == "1" then %>
- <p><%:Arguments:%> <input style="width: 50%" type="text" id="<%=command['.name']%>" /></p>
+ <p><%:Arguments:%> <input type="text" id="<%=command['.name']%>" /></p>
<% end %>
- <div style="position:absolute; left:0; bottom:20px">
+ <div>
<input type="button" value="<%:Run%>" class="cbi-button cbi-button-apply" onclick="command_run('<%=command['.name']%>')" />
<input type="button" value="<%:Download%>" class="cbi-button cbi-button-download" onclick="command_download('<%=command['.name']%>')" />
<% if command.public == "1" then %>