X-Git-Url: https://git.enpas.org/?a=blobdiff_plain;f=util%2Fpluginloader.lua;h=31ab1e882fa0fcb595dab277c3bfb8b46f39dcf7;hb=8ffa161dfeecc372aa41361b35208508802a73ac;hp=956b92bd640f2d5b437f43ea8b41bcfea2286568;hpb=bca1a48421947ca7d627c23433effed81a1d91f2;p=prosody.git diff --git a/util/pluginloader.lua b/util/pluginloader.lua index 956b92bd..31ab1e88 100644 --- a/util/pluginloader.lua +++ b/util/pluginloader.lua @@ -12,8 +12,6 @@ local plugin_dir = CFG_PLUGINDIR or "./plugins/"; local io_open, os_time = io.open, os.time; local loadstring, pairs = loadstring, pairs; -local datamanager = require "util.datamanager"; - module "pluginloader" local function load_file(name) @@ -25,16 +23,30 @@ local function load_file(name) end function load_resource(plugin, resource, loader) - if not resource then - resource = "mod_"..plugin..".lua"; + local path, name = plugin:match("([^/]*)/?(.*)"); + if name == "" then + if not resource then + resource = "mod_"..plugin..".lua"; + end + loader = loader or load_file; + + local content, err = loader(plugin.."/"..resource); + if not content then content, err = loader(resource); end + -- TODO add support for packed plugins + + return content, err; + else + if not resource then + resource = "mod_"..name..".lua"; + end + loader = loader or load_file; + + local content, err = loader(plugin.."/"..resource); + if not content then content, err = loader(path.."/"..resource); end + -- TODO add support for packed plugins + + return content, err; end - loader = loader or load_file; - - local content, err = loader(plugin.."/"..resource); - if not content then content, err = loader(resource); end - -- TODO add support for packed plugins - - return content, err; end function load_code(plugin, resource)