Commits

Daniel Poelzleithner committed ea2e8f3

allow webmcp path to be set in cgi script

this allows another script to include the webmcp script when the cwd is not the cgi-bin. the script needs to set the WEBMCP_PATH variable.

  • Participants
  • Parent commits 1da1078

Comments (0)

Files changed (1)

File framework/cgi-bin/webmcp.lua

 _WEBMCP_VERSION = "1.1.1"
 
 -- include "../lib/" in search path for libraries
+if not WEBMCP_PATH then
+  WEBMCP_PATH = "../"
+end
+
 do
-  package.path = '../lib/?.lua;' .. package.path
+  package.path = WEBMCP_PATH..'lib/?.lua;' .. package.path
   -- find out which file name extension shared libraries have
   local slib_exts = {}
   for ext in string.gmatch(package.cpath, "%?%.([A-Za-z0-9_-]+)") do
   end
   local paths = {}
   for ext in pairs(slib_exts) do
-    paths[#paths+1] = "../accelerator/?." .. ext
+    paths[#paths+1] = WEBMCP_PATH.."accelerator/?." .. ext
   end
   for ext in pairs(slib_exts) do
-    paths[#paths+1] = "../lib/?." .. ext
+    paths[#paths+1] = WEBMCP_PATH.."lib/?." .. ext
   end
   paths[#paths+1] = package.cpath
   package.cpath = table.concat(paths, ";")
       not string.find(key, "^__")
     then
       category        = "env"
-      base_path       = "../env/"
+      base_path       = WEBMCP_PATH.."/env/"
       merge           = true
       merge_base_path = app_base .. "/env/"
       file_key        = key
     return rawget(self, key)
   end
   install_autoloader(_G, nil, {})
-  try_exec("../env/__init.lua")
+  try_exec(WEBMCP_PATH.."env/__init.lua")
 end
 
 -- interactive console mode