diff options
author | Ted Trask <ttrask01@yahoo.com> | 2010-01-21 13:12:12 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2010-01-21 13:12:12 +0000 |
commit | f669bf6ec4bb0b49b123dd31db6998c4be914454 (patch) | |
tree | 0506e9ae3ae8c398516522135be99a0c93242a54 | |
parent | 6518f55980acc9f1e763978eff5dae532eaeb227 (diff) | |
download | acf-core-f669bf6ec4bb0b49b123dd31db6998c4be914454.tar.bz2 acf-core-f669bf6ec4bb0b49b123dd31db6998c4be914454.tar.xz |
Changes to skins to allow user skins to be added
page_info.skindir is no longer available to views, but staticdir is.
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | acf.conf | 11 | ||||
-rw-r--r-- | app/acf-util/password-status-html.lsp | 2 | ||||
-rw-r--r-- | app/acf-util/roles-viewroles-html.lsp | 4 | ||||
-rw-r--r-- | app/acf-util/skins-model.lua | 21 | ||||
-rw-r--r-- | app/acf_www-controller.lua | 2 | ||||
-rw-r--r-- | app/template-html.lsp | 6 | ||||
-rw-r--r-- | lib/viewfunctions.lua | 4 |
8 files changed, 31 insertions, 23 deletions
@@ -52,5 +52,9 @@ phony+=install install: install-recursive $(CONF_FILES) mkdir -p $(DESTDIR)/etc/acf cp $(CONF_FILES) $(DESTDIR)/etc/acf + mkdir -p $(DESTDIR)/etc/acf/skins + ln -s $(DESTDIR)/etc/acf/skins $(DESTDIR)/$(wwwdir)/userskins + +include config.mk .PHONY: $(phony) @@ -1,13 +1,16 @@ # Configuration file for Alpine Configuration Framework # Directories where the application resides -# appdir and libdir may be comma-separated lists +# appdir, libdir, and skindir may be comma-separated lists # paths are checked from left to right # for .lua and .lsp files - the first found file will be used # for .roles and .menu files - all files will be combined appdir=/usr/share/acf/app/ libdir=/usr/share/acf/lib/ wwwdir=/usr/share/acf/www/ +staticdir=/skins/static/ +skindir=/skins/,/userskins/ +# skins are found in subdirectories of wwwdir/skindir # sessiondir is where the session state files are stored sessiondir=/tmp/ @@ -16,9 +19,9 @@ sessiondir=/tmp/ # only applies to web access, client access will always use system logger logfile = /var/log/acf.log -# ACF is skinnable - these specifiy the active skin -skindir=/skins/ -skin=alps +# ACF is skinnable - this specifies the active skin +# will attempt to load skin/basename(skin).css +skin=/skins/alps # Auditing can be done before and/or after a commit (controller permitting) # ${TEMPFILE} and ${CONFFILE} are used precommit diff --git a/app/acf-util/password-status-html.lsp b/app/acf-util/password-status-html.lsp index 4a34fab..a26bdee 100644 --- a/app/acf-util/password-status-html.lsp +++ b/app/acf-util/password-status-html.lsp @@ -12,7 +12,7 @@ <H2>Existing account</H2> <DL> <% for name,user in pairs(form.value) do %> - <DT><IMG SRC='/skins/static/tango/16x16/apps/system-users.png' HEIGHT='16' WIDTH='16'> <%= html.html_escape(name) %></DT> + <DT><IMG SRC='<%= html.html_escape(page_info.staticdir) %>/tango/16x16/apps/system-users.png' HEIGHT='16' WIDTH='16'> <%= html.html_escape(name) %></DT> <DD><TABLE> <TR> <TD STYLE='border:none;'><B><%= html.html_escape(user.value.userid.label) %></B></TD> diff --git a/app/acf-util/roles-viewroles-html.lsp b/app/acf-util/roles-viewroles-html.lsp index b2c5aa7..c7d6fc5 100644 --- a/app/acf-util/roles-viewroles-html.lsp +++ b/app/acf-util/roles-viewroles-html.lsp @@ -15,7 +15,7 @@ <TABLE> <% if view.value.defined_roles then %> <% for x,role in pairs(view.value.defined_roles.value) do %> - <TR><TD><dt><img src='/skins/static/tango/16x16/apps/system-users.png' height='16' width='16'> <%= html.html_escape(role) %></dt> + <TR><TD><dt><img src='<%= html.html_escape(page_info.staticdir) %>/tango/16x16/apps/system-users.png' height='16' width='16'> <%= html.html_escape(role) %></dt> <dd> [<a href='viewroleperms?role=<%= html.html_escape(role) %>'>View this role</a>] [<a href='editrole?role=<%= html.html_escape(role) %>&redir=<%= html.html_escape(page_info.orig_action) %>'>Edit this role</a>] @@ -25,7 +25,7 @@ <% end %> <% if view.value.default_roles then %> <% for x,role in pairs(view.value.default_roles.value) do %> - <TR><TD><dt><img src='/skins/static/tango/16x16/categories/applications-system.png' height='16' width='16'> <%= html.html_escape(role) %></dt> + <TR><TD><dt><img src='<%= html.html_escape(page_info.staticdir) %>/tango/16x16/categories/applications-system.png' height='16' width='16'> <%= html.html_escape(role) %></dt> <dd> [<a href='viewroleperms?role=<%= html.html_escape(role) %>'>View this role</a>] [<a href='editrole?role=<%= html.html_escape(role) %>&redir=<%= html.html_escape(page_info.orig_action) %>'>Edit this role</a>] diff --git a/app/acf-util/skins-model.lua b/app/acf-util/skins-model.lua index 8b5a57e..860a943 100644 --- a/app/acf-util/skins-model.lua +++ b/app/acf-util/skins-model.lua @@ -1,4 +1,3 @@ --- acf model for displaying logfiles recusivly module (..., package.seeall) require("fs") @@ -7,9 +6,9 @@ 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)) + content,count = string.gsub(content, "\n%s*skin%s*=[^\n]*", "\nskin="..skin) if count == 0 then - content = "\nskin="..format.escapespecialcharacters(skin)..content + content = "\nskin="..skin..content end fs.write_file(self.conf.conffile, string.sub(content,2)) local cmdoutput = "New skin selected" @@ -18,13 +17,15 @@ 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) + for skin in string.gmatch(self.conf.skindir, "[^,]+") do + for i,file in ipairs(posix.dir(self.conf.wwwdir ..skin) 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 .. skin .. file).type ~= "directory")) then + local entry = cfe({ value=skin..file, label="Skin name" }) + local current = conf.skin + entry.inuse = (file == current) + table.insert(skinarray, entry) + end end end return cfe({ type="list", value=skinarray, label="Skins" }) diff --git a/app/acf_www-controller.lua b/app/acf_www-controller.lua index ab6dddb..0b6d80d 100644 --- a/app/acf_www-controller.lua +++ b/app/acf_www-controller.lua @@ -221,7 +221,7 @@ local view_resolver = function(self) prefix = self.conf.prefix, script = self.conf.script, appname = self.conf.appname, - skindir = self.conf.skindir or "", + staticdir = self.conf.staticdir or "", skin = self.conf.skin or "", orig_action = self.conf.orig_action or self.conf.prefix .. self.conf.controller .. "/" .. self.conf.action, clientdata = self.clientdata, diff --git a/app/template-html.lsp b/app/template-html.lsp index 2b0d58c..0490b0b 100644 --- a/app/template-html.lsp +++ b/app/template-html.lsp @@ -23,10 +23,10 @@ if viewlibrary and viewlibrary.dispatch_component then end %> <title><%= html.html_escape(hostname .. " - " .. pageinfo.controller .. "->" .. pageinfo.action) %></title> -<link rel="stylesheet" type="text/css" href="<%= html.html_escape(pageinfo.skindir) %>static/reset.css"> -<link rel="stylesheet" type="text/css" href="<%= html.html_escape(pageinfo.skindir .. pageinfo.skin.."/"..pageinfo.skin..".css") %>"> +<link rel="stylesheet" type="text/css" href="<%= html.html_escape(pageinfo.staticdir) %>/reset.css"> +<link rel="stylesheet" type="text/css" href="<%= html.html_escape(pageinfo.skin.."/"..posix.basename(pageinfo.skin)..".css") %>"> <!--[if IE]> -<link rel="stylesheet" type="text/css" href="<%= html.html_escape(pageinfo.skindir .. pageinfo.skin.."/"..pageinfo.skin.."-ie.css") %>"> +<link rel="stylesheet" type="text/css" href="<%= html.html_escape(pageinfo.skin.."/"..posix.basename(pageinfo.skin).."-ie.css") %>"> <![endif]--> </head> <body> diff --git a/lib/viewfunctions.lua b/lib/viewfunctions.lua index a45831c..f827cff 100644 --- a/lib/viewfunctions.lua +++ b/lib/viewfunctions.lua @@ -220,7 +220,7 @@ function displaypagination(page_data, page_info) io.write('<div align="right">Pages:') local p = page_data.page if p > 1 then - io.write("<a href="..link..(p-1).."><img SRC='/skins/static/tango/16x16/actions/go-previous.png' HEIGHT='16' WIDTH='16'></a>") + io.write("<a href="..link..(p-1).."><img SRC='<%= html.html_escape(page_info.staticdir) %>/tango/16x16/actions/go-previous.png' HEIGHT='16' WIDTH='16'></a>") pagelink(1) end local links = {(p-3)-(p-3)%10, p-2, p-1, p, p+1, p+2, (p+12)-(p+12)%10} @@ -237,7 +237,7 @@ function displaypagination(page_data, page_info) end if p<page_data.numpages then pagelink(page_data.numpages) - io.write("<a href="..link..(p+1).."><img SRC='/skins/static/tango/16x16/actions/go-next.png' HEIGHT='16' WIDTH='16'></a>") + io.write("<a href="..link..(p+1).."><img SRC='<%= html.html_escape(page_info.staticdir) %>/tango/16x16/actions/go-next.png' HEIGHT='16' WIDTH='16'></a>") end io.write("</div>") end |