* Remove ffluci.util.__file__ as it relies on debug information
authorSteven Barth <steven@midlink.org>
Sat, 5 Apr 2008 18:35:33 +0000 (18:35 +0000)
committerSteven Barth <steven@midlink.org>
Sat, 5 Apr 2008 18:35:33 +0000 (18:35 +0000)
* Added ffluci.debug for things that rely on debug information
* Fixed a bug regarding path detection when Luci is bytecompiled

Makefile
src/ffluci/cbi.lua
src/ffluci/config.lua
src/ffluci/debug.lua [new file with mode: 0644]
src/ffluci/i18n.lua
src/ffluci/menu.lua
src/ffluci/template.lua
src/ffluci/util.lua

index 0aefd19..57b3efd 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
 LUAC = luac
 LUAC_OPTIONS = -s
 
-FILES = 
+FILES = ffluci/debug.lua
 
 CFILES = ffluci/util.lua ffluci/http.lua ffluci/fs.lua \
 ffluci/sys.lua ffluci/model/uci.lua ffluci/model/ipkg.lua \
index 5bc4049..1ccf2e5 100644 (file)
@@ -38,8 +38,9 @@ local instanceof = ffluci.util.instanceof
 function load(cbimap)
        require("ffluci.fs")
        require("ffluci.i18n")
+       require("ffluci.config")
        
-       local cbidir = ffluci.fs.dirname(ffluci.util.__file__()) .. "/model/cbi/"
+       local cbidir = ffluci.config.path .. "/model/cbi/"
        local func, err = loadfile(cbidir..cbimap..".lua")
        
        if not func then
index 8b94db8..8b1a73d 100644 (file)
@@ -28,6 +28,10 @@ limitations under the License.
 module("ffluci.config", package.seeall)
 require("ffluci.model.uci")
 require("ffluci.util")
+require("ffluci.debug")
+
+-- Our path (wtf Lua lacks __file__ support)
+path = ffluci.debug.path
 
 -- Warning! This is only for fallback and compatibility purporses! --
 main = {}
diff --git a/src/ffluci/debug.lua b/src/ffluci/debug.lua
new file mode 100644 (file)
index 0000000..f1132ed
--- /dev/null
@@ -0,0 +1,2 @@
+module("ffluci.debug", package.seeall)
+path = require("ffluci.fs").dirname(debug.getinfo(1, 'S').source:sub(2))
\ No newline at end of file
index c362d3e..11f4afe 100644 (file)
@@ -26,12 +26,10 @@ limitations under the License.
 
 module("ffluci.i18n", package.seeall)
 
-require("ffluci.fs")
-require("ffluci.util")
 require("ffluci.config")
 
 table   = {}
-i18ndir = ffluci.fs.dirname(ffluci.util.__file__()) .. "/i18n/"
+i18ndir = ffluci.config.path .. "/i18n/"
 
 -- Clears the translation table
 function clear()
index cbf47e2..5a5f421 100644 (file)
@@ -29,9 +29,10 @@ require("ffluci.fs")
 require("ffluci.util")
 require("ffluci.template")
 require("ffluci.i18n")
+require("ffluci.config")
 
 -- Default modelpath
-modelpath = ffluci.fs.dirname(ffluci.util.__file__()) .. "/model/menu/"
+modelpath = ffluci.config.path .. "/model/menu/"
 
 -- Menu definition extra scope
 scope = {
index 52bebbc..589f43c 100644 (file)
@@ -31,7 +31,7 @@ require("ffluci.fs")
 require("ffluci.i18n")
 require("ffluci.model.uci")
 
-viewdir = ffluci.fs.dirname(ffluci.util.__file__()) .. "/view/"
+viewdir = ffluci.config.path .. "/view/"
 
 
 -- Compile modes:
index a33d141..dfc88e3 100644 (file)
@@ -205,10 +205,4 @@ function validate(value, cast_number, cast_int)
        end
        
        return value
-end
-
-
--- Returns the filename of the calling script
-function __file__()
-       return debug.getinfo(2, 'S').source:sub(2)
 end
\ No newline at end of file