summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/Makefile4
-rw-r--r--app/acf-util/acf-util.roles2
-rw-r--r--app/acf-util/skins-controller.lua14
-rw-r--r--app/acf-util/skins-model.lua49
-rw-r--r--app/acf-util/skins-read-html.lsp17
-rw-r--r--app/acf-util/skins.menu2
6 files changed, 87 insertions, 1 deletions
diff --git a/app/Makefile b/app/Makefile
index 4c5a7aa..502d850 100644
--- a/app/Makefile
+++ b/app/Makefile
@@ -18,6 +18,10 @@ APP_DIST= \
acf-util/password-model.lua \
acf-util/password-status-html.lsp \
acf-util/password.menu \
+ acf-util/skins-controller.lua \
+ acf-util/skins-model.lua \
+ acf-util/skins-read-html.lsp \
+ acf-util/skins.menu \
acf-util/welcome-controller.lua\
acf-util/welcome-html.lsp\
acf_www-controller.lua\
diff --git a/app/acf-util/acf-util.roles b/app/acf-util/acf-util.roles
index 7433fcc..c2639cf 100644
--- a/app/acf-util/acf-util.roles
+++ b/app/acf-util/acf-util.roles
@@ -1,4 +1,4 @@
GUEST=logon/logon,logon/logout,logon/status,welcome/read
USER=password/editme,roles/read
EXPERT=
-ADMIN=logon/logon,logon/logout,logon/status,password/editme,password/status,password/edituser,password/newuser,password/deleteuser,roles/read,roles/getpermslist,roles/viewuserroles,roles/viewroleperms,roles/viewroles,roles/editrole,roles/deleterole,roles/newrole,welcome/read,password/status,password/edituser,password/newuser,password/deleteuser,roles/getpermslist,roles/viewuserroles,roles/viewroleperms,roles/viewroles,roles/editrole,roles/deleterole,roles/newrole
+ADMIN=logon/logon,logon/logout,logon/status,password/editme,password/status,password/edituser,password/newuser,password/deleteuser,roles/read,roles/getpermslist,roles/viewuserroles,roles/viewroleperms,roles/viewroles,roles/editrole,roles/deleterole,roles/newrole,welcome/read,password/status,password/edituser,password/newuser,password/deleteuser,roles/getpermslist,roles/viewuserroles,roles/viewroleperms,roles/viewroles,roles/editrole,roles/deleterole,roles/newrole,skins/read,skins/update
diff --git a/app/acf-util/skins-controller.lua b/app/acf-util/skins-controller.lua
new file mode 100644
index 0000000..5d4d0d7
--- /dev/null
+++ b/app/acf-util/skins-controller.lua
@@ -0,0 +1,14 @@
+module (..., package.seeall)
+
+-- Public methods
+
+default_action = "read"
+
+read = function (self )
+ return self.model.get(self)
+end
+
+update = function (self )
+ return self:redirect_to_referrer(self.model.update(self, self.clientdata.skin or ""))
+end
+
diff --git a/app/acf-util/skins-model.lua b/app/acf-util/skins-model.lua
new file mode 100644
index 0000000..8b5a57e
--- /dev/null
+++ b/app/acf-util/skins-model.lua
@@ -0,0 +1,49 @@
+-- acf model for displaying logfiles recusivly
+module (..., package.seeall)
+
+require("fs")
+require("format")
+
+local function set_skins(self, skin)
+ local content = "\n"..(fs.read_file(self.conf.conffile) or "")
+ local count
+ content,count = string.gsub(content, "\n%s*skin%s*=[^\n]*", "\nskin="..format.escapespecialcharacters(skin))
+ if count == 0 then
+ content = "\nskin="..format.escapespecialcharacters(skin)..content
+ end
+ fs.write_file(self.conf.conffile, string.sub(content,2))
+ local cmdoutput = "New skin selected"
+ return cmdoutput, errtxt
+end
+
+local function list_skins(self)
+ local skinarray = {}
+ for i,file in ipairs(posix.dir(self.conf.wwwdir ..self.conf.skindir) or {}) do
+ -- Ignore files that begins with a '.' and 'cgi-bin' and only list folders
+ if not ((string.match(file, "^%.")) or (string.match(file, "^cgi[-]bin")) or (string.match(file, "^static")) or (posix.stat(self.conf.wwwdir .. self.conf.skindir .. file).type ~= "directory")) then
+ local entry = cfe({ value=file, label="Skin name" })
+ local current = conf.skin
+ entry.inuse = (file == current)
+ table.insert(skinarray, entry)
+ end
+ end
+ return cfe({ type="list", value=skinarray, label="Skins" })
+end
+
+
+get = function (self)
+ return list_skins(self)
+end
+
+update = function (self, newskin)
+ -- Make sure no one can inject code into the model.
+ local availableskins = list_skins(self)
+ local cmdoutput = "Failed to set skin"
+ local errtxt = "Invalid selection"
+ for i,skin in ipairs(availableskins.value) do
+ if ( skin.value == newskin) then
+ cmdoutput, errtxt = set_skins(self, newskin)
+ end
+ end
+ return cfe({ value=cmdoutput, errtxt=errtxt, label="Set skin result" })
+end
diff --git a/app/acf-util/skins-read-html.lsp b/app/acf-util/skins-read-html.lsp
new file mode 100644
index 0000000..95547a5
--- /dev/null
+++ b/app/acf-util/skins-read-html.lsp
@@ -0,0 +1,17 @@
+<% local view, viewlibrary, page_info, session = ... %>
+<% require("viewfunctions") %>
+
+<% displaycommandresults({"update"}, session) %>
+
+<h1>Available skins</h1>
+
+<DL>
+<% for i,skin in ipairs(view.value) do %>
+ <dt><%= html.html_escape(skin.value) %></dt>
+ <% if (skin.inuse) then %>
+ <dd>in use</dd>
+ <% else %>
+ <dd>[<a href="update?skin=<%= html.html_escape(skin.value) %>">use this skin</a>]</dd>
+ <% end %>
+<% end %>
+</DL>
diff --git a/app/acf-util/skins.menu b/app/acf-util/skins.menu
new file mode 100644
index 0000000..bd98be6
--- /dev/null
+++ b/app/acf-util/skins.menu
@@ -0,0 +1,2 @@
+#CAT GROUP/DESC TAB ACTION
+System 98Skins Status read