summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--[-rwxr-xr-x]tinydns-config-html.lsp7
-rw-r--r--tinydns-edit-html.lsp55
-rw-r--r--tinydns-listfiles-html.lsp34
-rw-r--r--tinydns-listpermissions-html.lsp59
-rw-r--r--tinydns-status-html.lsp28
-rw-r--r--tinydns-view-html.lsp17
6 files changed, 123 insertions, 77 deletions
diff --git a/tinydns-config-html.lsp b/tinydns-config-html.lsp
index 9264d05..2fdd23b 100755..100644
--- a/tinydns-config-html.lsp
+++ b/tinydns-config-html.lsp
@@ -1,14 +1,9 @@
<% local form, viewlibrary, page_info, session = ...
htmlviewfunctions = require("htmlviewfunctions")
-html = require("acf.html")
%>
<% if viewlibrary and viewlibrary.dispatch_component then
viewlibrary.dispatch_component("status")
end %>
-<h1><%= html.html_escape(form.label) %></h1>
-<%
- form.action = page_info.script .. page_info.prefix .. page_info.controller .. "/" .. page_info.action
- htmlviewfunctions.displayform(form)
-%>
+<% htmlviewfunctions.displayitem(form, page_info) %>
diff --git a/tinydns-edit-html.lsp b/tinydns-edit-html.lsp
index 2dcfc81..3ea17a7 100644
--- a/tinydns-edit-html.lsp
+++ b/tinydns-edit-html.lsp
@@ -18,6 +18,8 @@
var addEntry = '<tr><td> \
<a href="javascript:;"><img src="<%= html.html_escape(page_info.wwwprefix..page_info.staticdir) %>/tango/16x16/actions/list-add.png" width="16" height="16" title="Insert record"></a> \
</td></tr>';
+ <% local replaceableItem = cfe({label="ReplaceLabel", value="ReplaceValue", name="ReplaceName", descr="ReplaceExtra"}) %>
+ var replaceableEntry = '<% htmlviewfunctions.displayformitem(replaceableItem) %>';
function Entry(entryType,descr,num,descr0,descr1,descr2,descr3,descr4,descr5,descr6,descr7,descr8,descr9,descr10){
this.entryType=entryType;
@@ -121,7 +123,7 @@
name = "testme";
}
- form = form + '<div class='item'><p class='left'>' + entryType.descriptions[i] + '</p>\n<div class='right'>\n<input type="text" value="' + value + '" name="' + name + '">' + extra + '\n</div></div><!-- end .item -->';
+ form = form + replaceableEntry.replace("ReplaceLabel", entryType.descriptions[i]).replace("ReplaceValue", value).replace("ReplaceName", name).replace("ReplaceExtra", extra);
}
form = form + "\n</dl>";
entry.empty().append(form);
@@ -192,18 +194,34 @@
});
</script>
-<h1>Configuration</h1>
-<h2>Expert Configuration</h2>
-<h3>File Details</h3>
-<%
+<%
+local header_level0, header_level, header_level2
+if form.type == "form" then
+ header_level0 = htmlviewfunctions.displaysectionstart(cfe({label="Configuration"}), page_info)
+ header_level = htmlviewfunctions.displaysectionstart(cfe({label="Expert Configuration"}), page_info, htmlviewfunctions.incrementheader(header_level0))
+else
+ header_level = htmlviewfunctions.displaysectionstart(cfe({label="View File"}), page_info)
+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.mtime)
-%>
+if form.value.grep and form.value.grep.value and form.value.grep.value ~= "" then
+ htmlviewfunctions.displayitem(form.value.grep)
+end
+
+htmlviewfunctions.displaysectionend(header_level2)
-<h3>File Entries</h3>
-<% if form.descr then %><p class='descr'><%= string.gsub(html.html_escape(form.descr), "\n", "<br/>") %></p><% end %>
-<% if form.errtxt then %><p class='error'><%= string.gsub(html.html_escape(form.errtxt), "\n", "<br/>") %></p><% end %>
+htmlviewfunctions.displaysectionstart(cfe({label="File Entries"}), page_info, header_level2)
+if form.type == "form" then
+ htmlviewfunctions.displayformstart(form, page_info)
+ form.value.filename.type = "hidden"
+ htmlviewfunctions.displayformitem(form.value.filename, "filename")
+ form.value.filecontent.type = "hidden"
+ htmlviewfunctions.displayformitem(form.value.filecontent, "filecontent")
+end
+%>
<table id="entries">
<% for line in string.gmatch(html.html_escape(form.value.filecontent.value), "([^\n]*)\n?") do %>
<tr>
@@ -211,11 +229,16 @@ htmlviewfunctions.displayitem(form.value.mtime)
</tr>
<% end %>
</table>
-<% if form.value.filecontent.errtxt then %><p class='error'><%= string.gsub(html.html_escape(form.value.filecontent.errtxt), "\n", "<br/>") %></p><% end %>
+<%
+htmlviewfunctions.displayinfo(form.value.filecontent)
+
+if form.type == "form" then
+ htmlviewfunctions.displayformend(form)
+end
+htmlviewfunctions.displaysectionend(header_level2)
-<% form.action = page_info.script .. page_info.prefix .. page_info.controller .. "/" .. page_info.action %>
-<% htmlviewfunctions.displayformstart(form) %>
-<input type="hidden" name="filename" value="<%= html.html_escape(form.value.filename.value) %>">
-<input type="hidden" name="filecontent" value="<%= html.html_escape(form.value.filecontent.value) %>">
-<h2>Save and Apply Above Settings</h2>
-<% htmlviewfunctions.displayformend(form) %>
+htmlviewfunctions.displaysectionend(header_level)
+if form.type == "form" then
+ htmlviewfunctions.displaysectionend(header_level0)
+end
+%>
diff --git a/tinydns-listfiles-html.lsp b/tinydns-listfiles-html.lsp
index 151a1e7..098b97a 100644
--- a/tinydns-listfiles-html.lsp
+++ b/tinydns-listfiles-html.lsp
@@ -38,8 +38,10 @@ end
<% htmlviewfunctions.displaycommandresults({"delete", "edit", "editfile"}, session) %>
<% htmlviewfunctions.displaycommandresults({"newfile", "startstop"}, session, true) %>
-<h1>Configuration</h1>
-<h2>Edit/View Existing Domains</h2>
+<%
+local header_level = htmlviewfunctions.displaysectionstart(cfe({label="Configuration"}), page_info)
+local header_level2 = htmlviewfunctions.displaysectionstart(cfe({label="Edit/View Existing Domains"}), page_info, htmlviewfunctions.incrementheader(header_level))
+%>
<table id="list" class="tablesorter"><thead>
<tr>
<th>Action</th>
@@ -48,17 +50,26 @@ end
<th>File</th>
</tr>
</thead><tbody>
+<% local filename = cfe({ type="hidden", value="" }) %>
+<% local redir = cfe({ type="hidden", value=page_info.orig_action }) %>
<% for i,file in ipairs(form.value) do %>
<tr>
<td>
<%
- if viewlibrary.check_permission("delete") then io.write(html.link{value = "delete?submit=true&filename=" .. file.value.filename.value, label="Delete " }) end
- io.write(html.link{value = "view?filename=" .. file.value.filename.value, label="View " })
- if viewlibrary.check_permission("edit") then io.write(html.link{value = "edit?filename=" .. file.value.filename.value.."&redir="..page_info.orig_action, label="Edit " }) end
- if viewlibrary.check_permission("editfile") then io.write(html.link{value = "editfile?filename=" .. file.value.filename.value.."&redir="..page_info.orig_action, label="Expert " }) end
+ filename.value = file.value.filename.value
+ 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)
+ end
+ if viewlibrary.check_permission("editfile") then
+ htmlviewfunctions.displayitem(cfe({type="link", value={filename=filename, redir=redir}, label="", option="Expert", action="editfile"}), page_info, -1)
+ end
+ if viewlibrary.check_permission("delete") then
+ htmlviewfunctions.displayitem(cfe({type="form", value={filename=filename}, label="", option="Delete", action="delete"}), page_info, -1)
+ end
%>
</td>
- <td><span style="display:none"><%= convertsize(file.value.filesize.value) %>b</span><%= html.html_escape(file.value.filesize.value) %></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>
</tr>
@@ -67,13 +78,14 @@ end
<% if #form.value == 0 then %>
No domains defined
<% end %>
+<% htmlviewfunctions.displaysectionend(header_level2) %>
+<% htmlviewfunctions.displaysectionend(header_level) %>
<% if viewlibrary and viewlibrary.dispatch_component and viewlibrary.check_permission("newfile") then
- local newfileform = viewlibrary.dispatch_component("newfile", nil, true) %>
-<h2>Create New Domain</h2>
-<%
+ local newfileform = viewlibrary.dispatch_component("newfile", nil, true)
newfileform.action = page_info.script .. page_info.prefix .. page_info.controller .. "/newfile"
- htmlviewfunctions.displayform(newfileform)
+ newfileform.label = "Create New Domain"
+ htmlviewfunctions.displayitem(newfileform, page_info, header_level2)
end %>
<% if viewlibrary and viewlibrary.dispatch_component and viewlibrary.check_permission("startstop") then
diff --git a/tinydns-listpermissions-html.lsp b/tinydns-listpermissions-html.lsp
index 0662aba..eb7ecc6 100644
--- a/tinydns-listpermissions-html.lsp
+++ b/tinydns-listpermissions-html.lsp
@@ -16,37 +16,60 @@
<script type="text/javascript">
$(document).ready(function() {
- $("#userlist").tablesorter({widgets: ['zebra']});
- $("#rolelist").tablesorter({widgets: ['zebra']});
+ $("#userlist").tablesorter({headers: {0:{sorter: false}}, widgets: ['zebra']});
+ $("#rolelist").tablesorter({headers: {0:{sorter: false}}, widgets: ['zebra']});
});
</script>
<% htmlviewfunctions.displaycommandresults({"edituserpermissions", "editrolepermissions"}, session) %>
-<h1><%= html.html_escape(view.label) %></h1>
-
-<h2>User Permissions</h2>
+<% local header_level = htmlviewfunctions.displaysectionstart(view, page_info) %>
+<% local header_level2 = htmlviewfunctions.displaysectionstart(cfe({label="User Permissions"}), page_info, htmlviewfunctions.incrementheader(header_level)) %>
<table id="userlist" class="tablesorter"><thead>
-<tr><th>User</th><th>Permissions</th>
+ <tr>
+ <th>Action</th>
+ <th>User</th>
+ <th>Permissions</th>
+ </tr>
</thead><tbody>
+<% local userid = cfe({ type="hidden", value="" }) %>
+<% local redir = cfe({ type="hidden", value=page_info.orig_action }) %>
<% for i,user in ipairs(view.value.user) do %>
- <tr><td><%= html.link{value=page_info.script .. page_info.prefix .. page_info.controller .. "/edituserpermissions?userid=" .. user.id .. "&redir="..page_info.orig_action, label=user.id} %></td><td>
- <% for y,allowed in pairs(user.allowed) do
- print(html.html_escape(allowed), "<br/>")
- end %>
- </td></tr>
+ <% userid.value = user.id %>
+ <tr>
+ <td><% htmlviewfunctions.displayitem(cfe({type="link", value={userid=userid, redir=redir}, label="", option="Edit", action="edituserpermissions"}), page_info, -1) %></td>
+ <td><%= html.html_escape(user.id) %></td>
+ <td>
+ <% for y,allowed in pairs(user.allowed) do
+ print(html.html_escape(allowed), "<br/>")
+ end %>
+ </td>
+ </tr>
<% end %>
</tbody></table>
+<% htmlviewfunctions.displaysectionend(header_level2) %>
-<h2>Role Permissions</h2>
+<% htmlviewfunctions.displaysectionstart(cfe({label="Role Permissions"}), page_info, header_level2) %>
<table id="rolelist" class="tablesorter"><thead>
-<tr><th>Role</th><th>Permissions</th>
+ <tr>
+ <th>Action</th>
+ <th>Role</th>
+ <th>Permissions</th>
+ </tr>
</thead><tbody>
+<% local rolecfe = cfe({ type="hidden", value="" }) %>
<% for i,role in ipairs(view.value.role) do %>
- <tr><td><%= html.link{value=page_info.script .. page_info.prefix .. page_info.controller .. "/editrolepermissions?role=" .. role.id .. "&redir="..page_info.orig_action, label=role.id} %></td><td>
- <% for y,allowed in pairs(role.allowed) do
- print(html.html_escape(allowed), "<br/>")
- end %>
- </td></tr>
+ <% rolecfe.value = role.id %>
+ <tr>
+ <td><% htmlviewfunctions.displayitem(cfe({type="link", value={role=rolecfe, redir=redir}, label="", option="Edit", action="editrolepermissions"}), page_info, -1) %></td>
+ <td><%= html.html_escape(role.id) %></td>
+ <td>
+ <% for y,allowed in pairs(role.allowed) do
+ print(html.html_escape(allowed), "<br/>")
+ end %>
+ </td>
+ </tr>
<% end %>
</tbody></table>
+<% htmlviewfunctions.displaysectionend(header_level2) %>
+<% htmlviewfunctions.displaysectionend(header_level) %>
diff --git a/tinydns-status-html.lsp b/tinydns-status-html.lsp
index 77050d8..5ca1af4 100644
--- a/tinydns-status-html.lsp
+++ b/tinydns-status-html.lsp
@@ -6,37 +6,29 @@ html = require("acf.html")
<% htmlviewfunctions.displaycommandresults({"install","edit"}, session) %>
<% htmlviewfunctions.displaycommandresults({"startstop"}, session) %>
-<h1>System Info</h1>
<%
+local header_level = htmlviewfunctions.displaysectionstart(data, page_info)
htmlviewfunctions.displayitem(data.value.status)
htmlviewfunctions.displayitem(data.value.version)
if data.value.version and data.value.version.errtxt and viewlibrary.check_permission("apk-tools/apk/install") then
-%>
- <div class='item'><p class='left'>Install package</p>
- <div class='right'>
- <form action="<%= html.html_escape(page_info.script .. "/apk-tools/apk/install") %>" method="post">
- <input type='hidden' name='package' value='<%= html.html_escape(data.value.version.name) %>'>
- <input class='submit' type='submit' name='submit' value='Install'></form>
- </div></div><!-- end .item -->
-<%
+ local install = cfe({ type="form", value={}, label="Install package", option="Install", action=page_info.script.."/apk-tools/apk/install" })
+ install.value.package = cfe({ type="hidden", value=data.value.version.name })
+ htmlviewfunctions.displayitem(install, page_info, 0) -- header_level 0 means display inline without header
end
htmlviewfunctions.displayitem(data.value.autostart)
if not (data.value.version and data.value.version.errtxt) and data.value.autostart and data.value.autostart.errtxt and viewlibrary.check_permission("alpine-baselayout/rc/edit") then
-%>
- <div class='item'><p class='left'>Enable autostart</p>
- <div class='right'>
- <form action="<%= html.html_escape(page_info.script .. "/alpine-baselayout/rc/edit") %>" method="post">
- <input type='hidden' name='servicename' value='<%= html.html_escape(data.value.autostart.name) %>'>
- <input type='hidden' name='redir' value='<%= html.html_escape(page_info.orig_action) %>'>
- <input class='submit' type='submit' value='Enable'></form>
- </div></div><!-- end .item -->
-<%
+ local autostart = cfe({ type="link", value={}, label="Enable autostart", option="Enable", action=page_info.script.."/alpine-baselayout/rc/edit" })
+ autostart.value.servicename = cfe({ type="hidden", value=data.value.autostart.name })
+ autostart.value.redir = cfe({ type="hidden", value=page_info.orig_action })
+ htmlviewfunctions.displayitem(autostart, page_info, 0) -- header_level 0 means display inline without header
end
htmlviewfunctions.displayitem(data.value.configdir)
htmlviewfunctions.displayitem(data.value.listen)
+
+htmlviewfunctions.displaysectionend(header_level)
%>
<% if viewlibrary and viewlibrary.dispatch_component and viewlibrary.check_permission("startstop") then
diff --git a/tinydns-view-html.lsp b/tinydns-view-html.lsp
index 24ba38b..472bae3 100644
--- a/tinydns-view-html.lsp
+++ b/tinydns-view-html.lsp
@@ -1,4 +1,5 @@
<% local view, viewlibrary, page_info = ...
+htmlviewfunctions = require("htmlviewfunctions")
html = require("acf.html")
%>
@@ -47,10 +48,9 @@ html = require("acf.html")
});
</script>
-<h1>DNS Entries
-<% if view.filename then io.write(" for "..html.html_escape(string.gsub(view.filename, "^.*/", ""))) end %>
-</h1>
-<h2>Locations</h2>
+<% if view.filename then view.label = view.label.." for "..string.gsub(view.filename, "^.*/", "") end %>
+<% local header_level = htmlviewfunctions.displaysectionstart(view, page_info) %>
+<% local header_level2 = htmlviewfunctions.displaysectionstart(cfe({label="Locations"}), page_info, htmlviewfunctions.incrementheader(header_level)) %>
<ul id="locations">
<% local currentloc = ""
for i,loc in ipairs(view.value) do
@@ -75,6 +75,7 @@ end %>
<% else %>
</ul>
<% end %>
+<% htmlviewfunctions.displaysectionend(header_level2) %>
<%
local function doListIndents(next, indent)
@@ -104,7 +105,7 @@ local function doListIndents(next, indent)
end
%>
-<h2>Records</h2>
+<% htmlviewfunctions.displaysectionstart(cfe({label="Records"}), page_info, header_level2) %>
<form id="filter-list">Filter: <input name="filter" id="filter" value="" maxlength="30" size="30" type="text"></form>
<ul id="records">
<% local indent = {}
@@ -123,9 +124,7 @@ for j,entry in ipairs(view.value) do
<% end
end %>
</table>
- <% if entry.errtxt then %>
- <p class='error'><%= string.gsub(html.html_escape(entry.errtxt), "\n", "<br/>") %></p>
- <% end %>
+ <% htmlviewfunctions.displayinfo(entry) %>
</li></ul>
<% end
end
@@ -136,3 +135,5 @@ if #indent == 0 then %>
doListIndents("", indent) %>
</ul>
<% end %>
+<% htmlviewfunctions.displaysectionend(header_level2) %>
+<% htmlviewfunctions.displaysectionend(header_level) %>