diff options
author | Ted Trask <ttrask01@yahoo.com> | 2009-12-30 14:34:45 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2009-12-30 14:34:45 +0000 |
commit | c43cc708d84d8e433e0db6b3dffe5d94c3e5da3b (patch) | |
tree | e6e8cba0d3065e462034c2aee67317f07e363913 | |
parent | b19b44c100ad4ed2c3f807f118555193789a668d (diff) | |
download | acf-alpine-baselayout-c43cc708d84d8e433e0db6b3dffe5d94c3e5da3b.tar.bz2 acf-alpine-baselayout-c43cc708d84d8e433e0db6b3dffe5d94c3e5da3b.tar.xz |
Modified skins to remove hardcoded /usr/share/acf/ path.
-rw-r--r-- | skins-controller.lua | 4 | ||||
-rw-r--r-- | skins-model.lua | 24 |
2 files changed, 13 insertions, 15 deletions
diff --git a/skins-controller.lua b/skins-controller.lua index e344524..5d4d0d7 100644 --- a/skins-controller.lua +++ b/skins-controller.lua @@ -5,10 +5,10 @@ module (..., package.seeall) default_action = "read" read = function (self ) - return self.model.get() + return self.model.get(self) end update = function (self ) - return self:redirect_to_referrer(self.model.update(self.clientdata.skin or "")) + return self:redirect_to_referrer(self.model.update(self, self.clientdata.skin or "")) end diff --git a/skins-model.lua b/skins-model.lua index d4f7c34..8b5a57e 100644 --- a/skins-model.lua +++ b/skins-model.lua @@ -4,25 +4,23 @@ module (..., package.seeall) require("fs") require("format") -local function set_skins(skin) - local conffile = "/etc/acf/acf.conf" - local content = "\n"..(fs.read_file(conffile) or "") +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(conffile, string.sub(content,2)) + fs.write_file(self.conf.conffile, string.sub(content,2)) local cmdoutput = "New skin selected" return cmdoutput, errtxt end -local function list_skins() - local path = "/usr/share/acf/www/skins/" +local function list_skins(self) local skinarray = {} - for i,file in ipairs(posix.dir(path) or {}) do + 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(path .. file).type ~= "directory")) then + 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) @@ -33,18 +31,18 @@ local function list_skins() end -get = function () - return list_skins() +get = function (self) + return list_skins(self) end -update = function (newskin) +update = function (self, newskin) -- Make sure no one can inject code into the model. - local availableskins = list_skins() + 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(newskin) + cmdoutput, errtxt = set_skins(self, newskin) end end return cfe({ value=cmdoutput, errtxt=errtxt, label="Set skin result" }) |