diff options
author | Ted Trask <ttrask01@yahoo.com> | 2009-12-31 09:07:05 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2009-12-31 09:07:05 +0000 |
commit | be4063286a0b8f46754c082178517b3c684c3dff (patch) | |
tree | 32966a8ba376048fa34b718cd6663138aea87249 /app | |
parent | bd1d77b3b8278dfab279fe31ff88eab953bdd4c0 (diff) | |
download | acf-core-be4063286a0b8f46754c082178517b3c684c3dff.tar.bz2 acf-core-be4063286a0b8f46754c082178517b3c684c3dff.tar.xz |
Allow appdir and libdir to be comma-separated lists of directories.
Diffstat (limited to 'app')
-rw-r--r-- | app/acf_cli-controller.lua | 6 | ||||
-rw-r--r-- | app/acf_www-controller.lua | 50 |
2 files changed, 37 insertions, 19 deletions
diff --git a/app/acf_cli-controller.lua b/app/acf_cli-controller.lua index ef82c70..3d4a3e9 100644 --- a/app/acf_cli-controller.lua +++ b/app/acf_cli-controller.lua @@ -5,13 +5,15 @@ require("posix") mvc = {} mvc.on_load = function (self, parent) -- Make sure we have some kind of sane defaults for libdir - self.conf.libdir = self.conf.libdir or ( posix.dirname(self.conf.appdir) .. "/lib/" ) + self.conf.libdir = self.conf.libdir or ( string.match(self.conf.appdir, "[^,]+/") .. "/lib/" ) self.conf.script = "" self.conf.default_prefix = "/acf-util/" self.conf.default_controller = "welcome" -- this sets the package path for us and our children - package.path= self.conf.libdir .. "?.lua;" .. package.path + for p in string.gmatch(self.conf.libdir, "[^,]+") do + package.path= p .. "?.lua;" .. package.path + end self.session = {} local x=require("session") diff --git a/app/acf_www-controller.lua b/app/acf_www-controller.lua index 1977491..017b574 100644 --- a/app/acf_www-controller.lua +++ b/app/acf_www-controller.lua @@ -27,7 +27,7 @@ local function build_menus(self) self.sessiondata.permissions = permissions --Build the menu - local cats = m.get_menuitems(self.conf.appdir) + local cats = m.get_menuitems(self) -- now, loop through menu and remove actions without permission -- go in reverse so we can remove entries while looping for x = #cats,1,-1 do @@ -80,6 +80,15 @@ end -- ctlr-action-view, then ctlr-view, then action-view, then view -- cannot be local function because of recursion find_template = function ( appdir, prefix, controller, action, viewtype ) + if string.find(appdir, ",") then + local template + for p in string.gmatch(appdir, "[^,]+") do + template = find_template(p, prefix, controller, action, viewtype) + if template then break end + end + return template + end + local targets = { appdir .. prefix .. "template-" .. controller .. "-" .. action .. "-" .. viewtype .. ".lsp", @@ -108,17 +117,19 @@ end -- look for a view -- ctlr-action-view, then ctlr-view local find_view = function ( appdir, prefix, controller, action, viewtype ) - local names = { appdir .. prefix .. controller .. "-" .. - action .. "-" .. viewtype .. ".lsp", - appdir .. prefix .. controller .. "-" .. - viewtype .. ".lsp" } - local file - -- search for view - for i,filename in ipairs (names) do - file = io.open(filename) - if file then - file:close() - return filename + for p in string.gmatch(appdir, "[^,]+") do + local names = { p .. prefix .. controller .. "-" .. + action .. "-" .. viewtype .. ".lsp", + p .. prefix .. controller .. "-" .. + viewtype .. ".lsp" } + local file + -- search for view + for i,filename in ipairs (names) do + file = io.open(filename) + if file then + file:close() + return filename + end end end return nil @@ -126,8 +137,11 @@ end local has_view = function(self) require("fs") - local file = posix.stat(self.conf.appdir .. self.conf.prefix .. self.conf.controller .. "-" .. self.conf.action .. "-" .. (self.conf.viewtype or "html") .. ".lsp", "type") - return file == "regular" or file == "link" + for p in string.gmatch(self.conf.appdir, "[^,]+") do + local file = posix.stat(p .. self.conf.prefix .. self.conf.controller .. "-" .. self.conf.action .. "-" .. (self.conf.viewtype or "html") .. ".lsp", "type") + if file == "regular" or file == "link" then return true end + end + return false end -- This function is made available within the view to allow loading of components @@ -226,8 +240,8 @@ mvc.on_load = function (self, parent) --logevent("acf_www-controller mvc.on_load") -- Make sure we have some kind of sane defaults for libdir, wwwdir, and sessiondir - self.conf.libdir = self.conf.libdir or ( posix.dirname(self.conf.appdir) .. "/lib/" ) - self.conf.wwwdir = self.conf.wwwdir or ( posix.dirname(self.conf.appdir) .. "/www/" ) + self.conf.libdir = self.conf.libdir or ( string.match(self.conf.appdir, "[^,]+/") .. "/lib/" ) + self.conf.wwwdir = self.conf.wwwdir or ( string.match(self.conf.appdir, "[^,]+/") .. "/www/" ) self.conf.sessiondir = self.conf.sessiondir or "/tmp/" self.conf.script = ENV.SCRIPT_NAME self.conf.default_prefix = "/acf-util/" @@ -238,7 +252,9 @@ mvc.on_load = function (self, parent) parent_exception_handler = parent.exception_handler -- this sets the package path for us and our children - package.path= self.conf.libdir .. "?.lua;" .. package.path + for p in string.gmatch(self.conf.libdir, "[^,]+") do + package.path= p .. "?.lua;" .. package.path + end sessionlib=require ("session") |