From a15984cf2eacb65eed22a39cacc9641a7b39032a Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Fri, 25 Apr 2014 07:00:06 +0000 Subject: Changes to use new htmlviewfunctions functions --- tinydns-config-html.lsp | 7 +---- tinydns-edit-html.lsp | 55 ++++++++++++++++++++++++++----------- tinydns-listfiles-html.lsp | 34 +++++++++++++++-------- tinydns-listpermissions-html.lsp | 59 ++++++++++++++++++++++++++++------------ tinydns-status-html.lsp | 28 +++++++------------ tinydns-view-html.lsp | 17 ++++++------ 6 files changed, 123 insertions(+), 77 deletions(-) mode change 100755 => 100644 tinydns-config-html.lsp diff --git a/tinydns-config-html.lsp b/tinydns-config-html.lsp old mode 100755 new mode 100644 index 9264d05..2fdd23b --- 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 %> -

<%= html.html_escape(form.label) %>

-<% - 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 = ' \ \ '; + <% 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 + '

' + entryType.descriptions[i] + '

\n
\n' + extra + '\n
'; + form = form + replaceableEntry.replace("ReplaceLabel", entryType.descriptions[i]).replace("ReplaceValue", value).replace("ReplaceName", name).replace("ReplaceExtra", extra); } form = form + "\n"; entry.empty().append(form); @@ -192,18 +194,34 @@ }); -

Configuration

-

Expert Configuration

-

File Details

-<% +<% +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) -

File Entries

-<% if form.descr then %>

<%= string.gsub(html.html_escape(form.descr), "\n", "
") %>

<% end %> -<% if form.errtxt then %>

<%= string.gsub(html.html_escape(form.errtxt), "\n", "
") %>

<% 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 +%> <% for line in string.gmatch(html.html_escape(form.value.filecontent.value), "([^\n]*)\n?") do %> @@ -211,11 +229,16 @@ htmlviewfunctions.displayitem(form.value.mtime) <% end %>
-<% if form.value.filecontent.errtxt then %>

<%= string.gsub(html.html_escape(form.value.filecontent.errtxt), "\n", "
") %>

<% 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) %> - - -

Save and Apply Above Settings

-<% 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) %> -

Configuration

-

Edit/View Existing Domains

+<% +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)) +%> @@ -48,17 +50,26 @@ end +<% local filename = cfe({ type="hidden", value="" }) %> +<% local redir = cfe({ type="hidden", value=page_info.orig_action }) %> <% for i,file in ipairs(form.value) do %> - + @@ -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) %> -

Create New Domain

-<% + 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 @@ <% htmlviewfunctions.displaycommandresults({"edituserpermissions", "editrolepermissions"}, session) %> -

<%= html.html_escape(view.label) %>

- -

User Permissions

+<% local header_level = htmlviewfunctions.displaysectionstart(view, page_info) %> +<% local header_level2 = htmlviewfunctions.displaysectionstart(cfe({label="User Permissions"}), page_info, htmlviewfunctions.incrementheader(header_level)) %>
ActionFile
<% - 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 %> <%= convertsize(file.value.filesize.value) %>b<%= html.html_escape(file.value.filesize.value) %><%= convertsize(file.value.filesize.value) %>b<%= html.html_escape(file.value.filesize.value) %> <%= html.html_escape(file.value.mtime.value) %> <%= html.html_escape(string.gsub(file.value.filename.value, "^.*/", "")) %>
- + + + + + +<% 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 %> - + <% userid.value = user.id %> + + + + + <% end %>
UserPermissions
ActionUserPermissions
<%= html.link{value=page_info.script .. page_info.prefix .. page_info.controller .. "/edituserpermissions?userid=" .. user.id .. "&redir="..page_info.orig_action, label=user.id} %> - <% for y,allowed in pairs(user.allowed) do - print(html.html_escape(allowed), "
") - end %> -
<% htmlviewfunctions.displayitem(cfe({type="link", value={userid=userid, redir=redir}, label="", option="Edit", action="edituserpermissions"}), page_info, -1) %><%= html.html_escape(user.id) %> + <% for y,allowed in pairs(user.allowed) do + print(html.html_escape(allowed), "
") + end %> +
+<% htmlviewfunctions.displaysectionend(header_level2) %> -

Role Permissions

+<% htmlviewfunctions.displaysectionstart(cfe({label="Role Permissions"}), page_info, header_level2) %> - + + + + + +<% local rolecfe = cfe({ type="hidden", value="" }) %> <% for i,role in ipairs(view.value.role) do %> - + <% rolecfe.value = role.id %> + + + + + <% end %>
RolePermissions
ActionRolePermissions
<%= html.link{value=page_info.script .. page_info.prefix .. page_info.controller .. "/editrolepermissions?role=" .. role.id .. "&redir="..page_info.orig_action, label=role.id} %> - <% for y,allowed in pairs(role.allowed) do - print(html.html_escape(allowed), "
") - end %> -
<% htmlviewfunctions.displayitem(cfe({type="link", value={role=rolecfe, redir=redir}, label="", option="Edit", action="editrolepermissions"}), page_info, -1) %><%= html.html_escape(role.id) %> + <% for y,allowed in pairs(role.allowed) do + print(html.html_escape(allowed), "
") + end %> +
+<% 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) %> -

System Info

<% +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 -%> -

Install package

-
-
" method="post"> - -
-
-<% + 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 -%> -

Enable autostart

-
-
" method="post"> - - -
-
-<% + 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") }); -

DNS Entries -<% if view.filename then io.write(" for "..html.html_escape(string.gsub(view.filename, "^.*/", ""))) end %> -

-

Locations

+<% 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)) %> <% end %> +<% htmlviewfunctions.displaysectionend(header_level2) %> <% local function doListIndents(next, indent) @@ -104,7 +105,7 @@ local function doListIndents(next, indent) end %> -

Records

+<% htmlviewfunctions.displaysectionstart(cfe({label="Records"}), page_info, header_level2) %>
Filter:
<% end end @@ -136,3 +135,5 @@ if #indent == 0 then %> doListIndents("", indent) %> <% end %> +<% htmlviewfunctions.displaysectionend(header_level2) %> +<% htmlviewfunctions.displaysectionend(header_level) %> -- cgit v1.2.3