From 137be4c8f1821527aadac13c9e461313f6eb3cf4 Mon Sep 17 00:00:00 2001 From: Damien Churchill Date: Mon, 14 Sep 2009 16:31:59 +0000 Subject: [PATCH] add a method to gather the plugins resources for when they need to be loaded after the ui --- deluge/ui/web/json_api.py | 4 ++++ deluge/ui/web/pluginmanager.py | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/deluge/ui/web/json_api.py b/deluge/ui/web/json_api.py index 6a16ffe36..d2f438bc5 100644 --- a/deluge/ui/web/json_api.py +++ b/deluge/ui/web/json_api.py @@ -785,6 +785,10 @@ class WebApi(JSONComponent): def get_plugin_info(self, name): return component.get("Web.PluginManager").get_plugin_info(name) + @export + def get_plugin_resources(self, name): + return component.get("Web.PluginManager").get_plugin_resources(name) + @export def register_event_listener(self, event): """ diff --git a/deluge/ui/web/pluginmanager.py b/deluge/ui/web/pluginmanager.py index 464a17de8..8a9007173 100644 --- a/deluge/ui/web/pluginmanager.py +++ b/deluge/ui/web/pluginmanager.py @@ -135,3 +135,17 @@ class PluginManager(PluginManagerBase, component.Component): def update(self): pass + + def get_plugin_resources(self, name): + # Get the plugin instance + try: + plugin = component.get("WebPlugin." + name) + except KeyError: + log.info("Plugin has no web ui") + return + info = gather_info(plugin) + info["name"] = name + info["scripts"] = ["/js/%s/%s" % (name.lower(), os.path.basename(s)) for s in info["scripts"]] + info["debug_scripts"] = ["/js/%s/%s" % (name.lower(), os.path.basename(s)) for s in info["debug_scripts"]] + del info["script_directories"] + return info \ No newline at end of file