diff options
author | Ted Trask <ttrask01@yahoo.com> | 2008-06-02 19:27:56 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2008-06-02 19:27:56 +0000 |
commit | aed2d1a213fa8366a72e65a2f56e031df4b843f4 (patch) | |
tree | 40776f5898306019c36533d25ad11c7de446f30f /skins-model.lua | |
parent | 1ad185d3004918e3fabf86f4c752093ff369ea81 (diff) | |
download | acf-alpine-baselayout-aed2d1a213fa8366a72e65a2f56e031df4b843f4.tar.bz2 acf-alpine-baselayout-aed2d1a213fa8366a72e65a2f56e031df4b843f4.tar.xz |
Modified skins to use cfe's more properly.
git-svn-id: svn://svn.alpinelinux.org/acf/alpine-baselayout/trunk@1194 ab2d0c66-481e-0410-8bed-d214d4d58bed
Diffstat (limited to 'skins-model.lua')
-rw-r--r-- | skins-model.lua | 41 |
1 files changed, 16 insertions, 25 deletions
diff --git a/skins-model.lua b/skins-model.lua index ad323a6..e637023 100644 --- a/skins-model.lua +++ b/skins-model.lua @@ -1,49 +1,40 @@ -- acf model for displaying logfiles recusivly module (..., package.seeall) --- no initializer in model - use controller.init for that - local function set_skins(skin) - cmdtxt = "/bin/sed -i 's/skin=.*/skin=" .. skin .. "/' /etc/acf/acf.conf" - local cmd, error = io.popen ( cmdtxt ) - local cmdoutput = cmd:read("*a") - cmd:close() - return cmdtxt + local cmd = "/bin/sed -i 's/skin=.*/skin=" .. skin .. "/' /etc/acf/acf.conf" + local f, errtxt = io.popen(cmd) + local cmdoutput = f:read("*a") + f:close() + return cfe({ value=cmdoutput, errtxt=errtxt, label="Set skin result" }) end local function list_skins() local path = "/usr/share/acf/www/skins/" local skinarray = {} - local skins = {} - local k,v - for k,v in pairs(posix.dir(path) or {}) do + for i,file in ipairs(posix.dir(path) or {}) do -- Ignore files that begins with a '.' and 'cgi-bin' and only list folders - if not ((string.match(v, "^%.")) or (string.match(v, "^cgi[-]bin")) or (string.match(v, "^static")) or (posix.stat(path .. v).type ~= "directory")) then - local f = v + if not ((string.match(file, "^%.")) or (string.match(file, "^cgi[-]bin")) or (string.match(file, "^static")) or (posix.stat(path .. file).type ~= "directory")) then + local entry = cfe({ value=file, label="Skin name" }) local current = conf.skin - if (current == f) then - table.insert(skinarray, {name=f, inuse="In use"}) - else - table.insert(skinarray, {name=f}) - end + entry.inuse = (file == current) + table.insert(skinarray, entry) end end - return skinarray + return cfe({ type="list", value=skinarray, label="Skins" }) end -get = function (self) +get = function () return list_skins() end -update = function (self,skin) +update = function (newskin) -- Make sure no one can inject code into the model. local availableskins = list_skins() - for i = 1 , table.maxn(availableskins) do - if ( availableskins[i].name == skin) and (skin ~= nil) then - return set_skins(skin) + for i,skin in ipairs(availableskins.value) do + if ( skin.value == newskin) then + return set_skins(newskin) end end end - - |