From eb046ff591c5abe9f2cd1f493ab8756d0abf61cf Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Sat, 12 Apr 2014 04:08:02 +0000 Subject: Changes to use new htmlviewfunctions functions and change connectedpeers to return cfe --- openssh-config-html.lsp | 2 +- openssh-connectedpeers-html.lsp | 19 +++++++++++-------- openssh-listauth-html.lsp | 12 ++++++------ openssh-listusers-html.lsp | 13 ++++++++----- openssh-model.lua | 6 +++--- openssh-welcome-html.lsp | 2 +- 6 files changed, 30 insertions(+), 24 deletions(-) diff --git a/openssh-config-html.lsp b/openssh-config-html.lsp index 2da497b..34e58b4 100644 --- a/openssh-config-html.lsp +++ b/openssh-config-html.lsp @@ -7,4 +7,4 @@ html = require("acf.html") viewlibrary.dispatch_component("status") end %> -<% htmlviewfunctions.displayitem(form, 1, page_info) %> +<% htmlviewfunctions.displayitem(form, page_info) %> diff --git a/openssh-connectedpeers-html.lsp b/openssh-connectedpeers-html.lsp index 9740e72..363d726 100644 --- a/openssh-connectedpeers-html.lsp +++ b/openssh-connectedpeers-html.lsp @@ -1,17 +1,19 @@ -<% local data, viewlibrary, page_info = ... +<% local data, viewlibrary, page_info, session = ... +htmlviewfunctions = require("htmlviewfunctions") html = require("acf.html") %> -

Connected peers

+<% local header_level = htmlviewfunctions.displaysectionstart(data, page_info) %> +<% local header_level2 = htmlviewfunctions.incrementheader(header_level) %> <% -if #data == 0 then +if #data.value == 0 then io.write("

No peers found

\n") end local col1="180px" -for k,v in pairs(data) do - io.write("

" .. html.html_escape(v.host)) - if v.name and v.name ~= v.host then io.write(" - "..html.html_escape(v.name)) end - io.write("

\n") +for k,v in pairs(data.value) do + local label = v.host + if v.name and v.name ~= v.host then label = label.." - "..html.html_escape(v.name) end + htmlviewfunctions.displaysectionstart(cfe({label=label}), page_info, header_level2) io.write("") for i=1, v.cnt do io.write("") @@ -43,6 +45,7 @@ for k,v in pairs(data) do io.write("") end io.write("
") + htmlviewfunctions.displaysectionend(header_level2) end %> - +<% htmlviewfunctions.displaysectionend(header_level) %> diff --git a/openssh-listauth-html.lsp b/openssh-listauth-html.lsp index 8d8ebad..d0b5e3e 100644 --- a/openssh-listauth-html.lsp +++ b/openssh-listauth-html.lsp @@ -23,7 +23,7 @@ <% htmlviewfunctions.displaycommandresults({"deleteauth"}, session) %> <% htmlviewfunctions.displaycommandresults({"addauth"}, session, true) %> -

Authorized Keys for <%= html.html_escape(view.value.user.value) %>

+<% local header_level = htmlviewfunctions.displaysectionstart(cfe({label="Authorized Keys for "..view.value.user.value}), page_info) %> @@ -31,14 +31,13 @@ +<% local user = cfe({ type="hidden", value=view.value.user.value }) %> +<% local authid = cfe({ type="hidden", value="" }) %> <% for i,auth in ipairs(view.value.auth.value) do %> @@ -46,5 +45,6 @@ <% end %>
ActionKey
-
" method="post"> - - - -
+ <% authid.value = auth.id %> + <% htmlviewfunctions.displayitem(cfe({type="form", value={user=user, auth=authid}, label="", option="Delete", action="deleteauth"}), page_info, -1) %>
<%= html.html_escape(auth.id) %> <% if #auth.key>32 then io.write(html.html_escape(string.sub(auth.key,0,16)) .. " ... " .. html.html_escape(string.sub(auth.key, -16))) else io.write(html.html_escape(auth.key)) end %>

In order to preserve keys with lbu, you must add /<% if view.value.user.value ~= "root" then io.write("home/") end %><%= view.value.user.value %>/.ssh/authorized_keys to lbu include +<% htmlviewfunctions.displaysectionend(header_level) %> <% viewlibrary.dispatch_component("addauth", {user=view.value.user.value}) %> diff --git a/openssh-listusers-html.lsp b/openssh-listusers-html.lsp index 69c80e0..ea6da7c 100644 --- a/openssh-listusers-html.lsp +++ b/openssh-listusers-html.lsp @@ -1,10 +1,13 @@ <% local view, viewlibrary, page_info, session = ... %> +<% htmlviewfunctions = require("htmlviewfunctions") %> <% html = require("acf.html") %> -

System User Accounts

+<% local header_level = htmlviewfunctions.displaysectionstart(cfe({label="System User Accounts"}), page_info) %> <% for i,user in ipairs(view.value) do %> -
<%= html.html_escape(user) %>
-
+ <% htmlviewfunctions.displayitemstart() %> + <%= html.html_escape(user) %> + <% htmlviewfunctions.displayitemmiddle() %> + <% htmlviewfunctions.displayitem(cfe({type="link", value={user=cfe({type="hidden", value=user})}, label="", option="Edit", action="listauth"}), page_info, -1) %> + <% htmlviewfunctions.displayitemend() %> <% end %> +<% htmlviewfunctions.displaysectionend(header_level) %> diff --git a/openssh-model.lua b/openssh-model.lua index 8eb946b..d672960 100644 --- a/openssh-model.lua +++ b/openssh-model.lua @@ -124,7 +124,7 @@ function mymodule.update_config(self, config) end function mymodule.list_conn_peers() - local output = {} + local output = cfe({ type="structure", value={}, label="Connected peers" }) local netstat = {} local ps = {} local who = {} @@ -172,8 +172,8 @@ function mymodule.list_conn_peers() end end end - table.insert(output, v) - output[#output]['host'] = peer + output.value[#output.value+1] = v + output.value[#output.value].host = peer end return output diff --git a/openssh-welcome-html.lsp b/openssh-welcome-html.lsp index e194aec..f5394c5 100644 --- a/openssh-welcome-html.lsp +++ b/openssh-welcome-html.lsp @@ -1,7 +1,7 @@ <% local data, viewlibrary, page_info, session = ... %> -<% if viewlibrary and viewlibrary.dispatch_component and viewlibrary.check_permission("connectedpeers") then +<% if viewlibrary and viewlibrary.dispatch_component and viewlibrary.check_permission("status") then viewlibrary.dispatch_component("status") end %> -- cgit v1.2.3