From da8d6a71739aa6e1eff39a099893b33b1ad51569 Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Wed, 23 Dec 2009 09:06:05 +0000 Subject: Fixed bug in loading controllers - allow '.' in path --- www/cgi-bin/mvc.lua | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'www') diff --git a/www/cgi-bin/mvc.lua b/www/cgi-bin/mvc.lua index a36878c..d7824d1 100755 --- a/www/cgi-bin/mvc.lua +++ b/www/cgi-bin/mvc.lua @@ -36,7 +36,7 @@ new = function (self, modname) -- If no clientdata, then clientdata is a null table if self.clientdata == nil then c.clientdata = {} - end + end -- If we don't have an application name, use the modname if (self.conf == nil ) or (self.conf.appname == nil) then @@ -215,8 +215,8 @@ soft_require = function (self, name ) -- and if it doesnt exist silently fail. -- This version allows things from /usr/local/lua/5.1 to -- be loaded - package.path = self.conf.appdir .. "?" .. ".lua;" .. package.path - local t = require(name) + package.path = self.conf.appdir .. dirname(name) .. "/?.lua;" .. package.path + local t = require(basename(name)) package.path = PATH return t end @@ -234,13 +234,8 @@ basename = function (string, suffix) end -- see man dirname.1 -dirname = function ( string) - string = string or "" - -- strip trailing / first - string = string.gsub (string, "/$", "") - local basename = basename ( string) - string = string.sub(string, 1, #string - #basename - 1) - return(string) +dirname = function (string) + return (string.gsub (string or "", "/?[^/]*$", "")) end -- look in various places for a config file, and store it in self.conf -- cgit v1.2.3