aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorWaqas Hussain <waqas20@gmail.com>2010-07-31 12:32:34 +0500
committerWaqas Hussain <waqas20@gmail.com>2010-07-31 12:32:34 +0500
commit6f80673f10e91e6f2d8f3ed3fcf0c6b30187f839 (patch)
tree7f62e20f21dbe971776011df121432aed1227269 /util
parent95fec897d970e2cae9740d4bce71a56378850ffb (diff)
downloadprosody-6f80673f10e91e6f2d8f3ed3fcf0c6b30187f839.tar.gz
prosody-6f80673f10e91e6f2d8f3ed3fcf0c6b30187f839.zip
util.pluginloader: Fix loading of plugins, plugin libraries and resources in subfolders (e.g., when loading 'a/b', load 'a/mod_b.lua', and not 'mod_a/b.lua').
Diffstat (limited to 'util')
-rw-r--r--util/pluginloader.lua32
1 files changed, 23 insertions, 9 deletions
diff --git a/util/pluginloader.lua b/util/pluginloader.lua
index 956b92bd..07b4e5c7 100644
--- a/util/pluginloader.lua
+++ b/util/pluginloader.lua
@@ -25,16 +25,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)