summaryrefslogtreecommitdiffstats
path: root/app/acf-util
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2010-01-13 16:11:18 +0000
committerTed Trask <ttrask01@yahoo.com>2010-01-13 16:11:18 +0000
commit0eebb26c9594f1c92b13e412e6ad24857143c288 (patch)
tree40504cff2acf2d0cfe97d4bea6d4194e3225f055 /app/acf-util
parentfbf9492b39641f0eef99c66b728c5d37e9bed932 (diff)
downloadacf-core-0eebb26c9594f1c92b13e412e6ad24857143c288.tar.bz2
acf-core-0eebb26c9594f1c92b13e412e6ad24857143c288.tar.xz
Moved skins from acf-alpine-baselayout.
Diffstat (limited to 'app/acf-util')
-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
5 files changed, 83 insertions, 1 deletions
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