mirror of
https://github.com/codex-storage/deluge.git
synced 2025-02-06 00:23:32 +00:00
fix up the deluge-web plugin interface
This commit is contained in:
parent
d024c293ed
commit
2376e857d2
@ -29,6 +29,7 @@
|
|||||||
* this exception statement from your version. If you delete this exception
|
* this exception statement from your version. If you delete this exception
|
||||||
* statement from all source files in the program, then also delete it here.
|
* statement from all source files in the program, then also delete it here.
|
||||||
*/
|
*/
|
||||||
|
Ext.ns('Deluge');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @class Deluge.Plugin
|
* @class Deluge.Plugin
|
||||||
@ -44,9 +45,8 @@ Deluge.Plugin = Ext.extend(Ext.util.Observable, {
|
|||||||
name: null,
|
name: null,
|
||||||
|
|
||||||
constructor: function(config) {
|
constructor: function(config) {
|
||||||
this.name = config.name;
|
this.isDelugePlugin = true;
|
||||||
this.addEvents({
|
this.addEvents({
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @event enabled
|
* @event enabled
|
||||||
* @param {Plugin} plugin the plugin instance
|
* @param {Plugin} plugin the plugin instance
|
||||||
@ -59,8 +59,6 @@ Deluge.Plugin = Ext.extend(Ext.util.Observable, {
|
|||||||
*/
|
*/
|
||||||
"disabled": true
|
"disabled": true
|
||||||
});
|
});
|
||||||
this.isDelugePlugin = true;
|
|
||||||
Deluge.Plugins[this.name] = this;
|
|
||||||
Deluge.Plugin.superclass.constructor.call(this, config);
|
Deluge.Plugin.superclass.constructor.call(this, config);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -82,3 +80,5 @@ Deluge.Plugin = Ext.extend(Ext.util.Observable, {
|
|||||||
if (this.onEnable) this.onEnable();
|
if (this.onEnable) this.onEnable();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Ext.ns('Deluge.plugins');
|
||||||
|
@ -79,8 +79,8 @@ deluge.ui = {
|
|||||||
url: deluge.config.base + 'json'
|
url: deluge.config.base + 'json'
|
||||||
});
|
});
|
||||||
|
|
||||||
for (var plugin in deluge.dlugins) {
|
for (var plugin in Deluge.plugins) {
|
||||||
plugin = deluge.plugins[plugin];
|
plugin = new Deluge.plugins[plugin]();
|
||||||
plugin.enable();
|
plugin.enable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,22 +88,13 @@ class PluginManager(PluginManagerBase, component.Component):
|
|||||||
|
|
||||||
info = gather_info(plugin)
|
info = gather_info(plugin)
|
||||||
|
|
||||||
server = component.get("DelugeWeb").top_level
|
scripts = component.get("Scripts")
|
||||||
js = component.get("Javascript")
|
|
||||||
for directory in info["script_directories"]:
|
|
||||||
js.removeDirectory(directory, name.lower())
|
|
||||||
|
|
||||||
for script in info["scripts"]:
|
for script in info["scripts"]:
|
||||||
script = "/js/%s/%s" % (name.lower(), os.path.basename(script))
|
scripts.remove_script("%s/%s" % (name.lower(), os.path.basename(script).lower()))
|
||||||
if script not in server.scripts:
|
|
||||||
continue
|
|
||||||
server.scripts.remove(script)
|
|
||||||
|
|
||||||
for script in info["debug_scripts"]:
|
for script in info["debug_scripts"]:
|
||||||
script = "/js/%s/%s" % (name.lower(), os.path.basename(script))
|
scripts.remove_script("%s/%s" % (name.lower(), os.path.basename(script).lower()))
|
||||||
if script not in server.debug_scripts:
|
scripts.remove_script("%s/%s" % (name.lower(), os.path.basename(script).lower()))
|
||||||
continue
|
|
||||||
server.debug_scripts.remove(script)
|
|
||||||
|
|
||||||
super(PluginManager, self).disable_plugin(name)
|
super(PluginManager, self).disable_plugin(name)
|
||||||
|
|
||||||
@ -119,22 +110,15 @@ class PluginManager(PluginManagerBase, component.Component):
|
|||||||
|
|
||||||
info = gather_info(plugin)
|
info = gather_info(plugin)
|
||||||
|
|
||||||
server = component.get("DelugeWeb").top_level
|
scripts = component.get("Scripts")
|
||||||
js = component.get("Javascript")
|
|
||||||
for directory in info["script_directories"]:
|
|
||||||
js.addDirectory(directory, name.lower())
|
|
||||||
|
|
||||||
for script in info["scripts"]:
|
for script in info["scripts"]:
|
||||||
script = "/js/%s/%s" % (name.lower(), os.path.basename(script))
|
log.debug("adding script %s for %s", name, os.path.basename(script))
|
||||||
if script in server.scripts:
|
scripts.add_script("%s/%s" % (name.lower(), os.path.basename(script)), script)
|
||||||
continue
|
|
||||||
server.scripts.append(script)
|
|
||||||
|
|
||||||
for script in info["debug_scripts"]:
|
for script in info["debug_scripts"]:
|
||||||
script = "/js/%s/%s" % (name.lower(), os.path.basename(script))
|
log.debug("adding debug script %s for %s", name, os.path.basename(script))
|
||||||
if script in server.debug_scripts:
|
scripts.add_script("%s/%s" % (name.lower(), os.path.basename(script)), script, "debug")
|
||||||
continue
|
scripts.add_script("%s/%s" % (name.lower(), os.path.basename(script)), script, "dev")
|
||||||
server.debug_scripts.append(script)
|
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
"""
|
"""
|
||||||
|
@ -336,7 +336,7 @@ class ScriptResource(resource.Resource, component.Component):
|
|||||||
"""
|
"""
|
||||||
Adds a folder of scripts to the script resource.
|
Adds a folder of scripts to the script resource.
|
||||||
|
|
||||||
:param path: The path of the script (this supports globbing)
|
:param path: The path of the folder
|
||||||
:type path: string
|
:type path: string
|
||||||
:param filepath: The physical location of the script
|
:param filepath: The physical location of the script
|
||||||
:type filepath: string
|
:type filepath: string
|
||||||
@ -351,6 +351,22 @@ class ScriptResource(resource.Resource, component.Component):
|
|||||||
self.__scripts[type]["scripts"][path] = (filepath, recurse)
|
self.__scripts[type]["scripts"][path] = (filepath, recurse)
|
||||||
self.__scripts[type]["order"].append(path)
|
self.__scripts[type]["order"].append(path)
|
||||||
|
|
||||||
|
def remove_script(self, path, type=None):
|
||||||
|
"""
|
||||||
|
Removes a script or folder of scripts from the script resource.
|
||||||
|
|
||||||
|
:param path: The path of the folder
|
||||||
|
:type path: string
|
||||||
|
:keyword type: The type of script to add (normal, debug, dev)
|
||||||
|
:param type: string
|
||||||
|
"""
|
||||||
|
if type not in ("dev", "debug", "normal"):
|
||||||
|
type = "normal"
|
||||||
|
|
||||||
|
del self.__scripts[type]["scripts"][path]
|
||||||
|
self.__scripts[type]["order"].remove(path)
|
||||||
|
|
||||||
|
|
||||||
def get_scripts(self, type=None):
|
def get_scripts(self, type=None):
|
||||||
"""
|
"""
|
||||||
Returns a list of the scripts that can be used for producing
|
Returns a list of the scripts that can be used for producing
|
||||||
@ -457,22 +473,22 @@ class TopLevel(resource.Resource):
|
|||||||
js = ScriptResource()
|
js = ScriptResource()
|
||||||
|
|
||||||
# configure the dev scripts
|
# configure the dev scripts
|
||||||
js.add_script("ext-base.js", rpath("js", "ext-base-debug.js"), "dev")
|
js.add_script("ext-base-debug.js", rpath("js", "ext-base-debug.js"), "dev")
|
||||||
js.add_script("ext-all.js", rpath("js", "ext-all-debug.js"), "dev")
|
js.add_script("ext-all-debug.js", rpath("js", "ext-all-debug.js"), "dev")
|
||||||
js.add_script_folder("ext-extensions", rpath("js", "ext-extensions"), "dev")
|
js.add_script_folder("ext-extensions", rpath("js", "ext-extensions"), "dev")
|
||||||
js.add_script_folder("deluge-all", rpath("js", "deluge-all"), "dev")
|
js.add_script_folder("deluge-all", rpath("js", "deluge-all"), "dev")
|
||||||
|
|
||||||
# configure the debug scripts
|
# configure the debug scripts
|
||||||
js.add_script("ext-base.js", rpath("js", "ext-base-debug.js"), "debug")
|
js.add_script("ext-base-debug.js", rpath("js", "ext-base-debug.js"), "debug")
|
||||||
js.add_script("ext-all.js", rpath("js", "ext-all-debug.js"), "debug")
|
js.add_script("ext-all-debug.js", rpath("js", "ext-all-debug.js"), "debug")
|
||||||
js.add_script("ext-extensions.js", rpath("js", "ext-extensions-debug.js"), "debug")
|
js.add_script("ext-extensions-debug.js", rpath("js", "ext-extensions-debug.js"), "debug")
|
||||||
js.add_script("deluge-all.js", rpath("js", "deluge-all-debug.js"), "debug")
|
js.add_script("deluge-all-debug.js", rpath("js", "deluge-all-debug.js"), "debug")
|
||||||
|
|
||||||
# configure the normal scripts
|
# configure the normal scripts
|
||||||
js.add_script("ext-base.js", rpath("js", "ext-base.js"), "debug")
|
js.add_script("ext-base.js", rpath("js", "ext-base.js"))
|
||||||
js.add_script("ext-all.js", rpath("js", "ext-all.js"), "debug")
|
js.add_script("ext-all.js", rpath("js", "ext-all.js"))
|
||||||
js.add_script("ext-extensions.js", rpath("js", "ext-extensions.js"), "debug")
|
js.add_script("ext-extensions.js", rpath("js", "ext-extensions.js"))
|
||||||
js.add_script("deluge-all.js", rpath("js", "deluge-all.js"), "debug")
|
js.add_script("deluge-all.js", rpath("js", "deluge-all.js"))
|
||||||
|
|
||||||
self.putChild("js", js)
|
self.putChild("js", js)
|
||||||
|
|
||||||
@ -487,18 +503,6 @@ class TopLevel(resource.Resource):
|
|||||||
theme = CONFIG_DEFAULTS.get("theme")
|
theme = CONFIG_DEFAULTS.get("theme")
|
||||||
self.__stylesheets.insert(1, "themes/css/xtheme-%s.css" % theme)
|
self.__stylesheets.insert(1, "themes/css/xtheme-%s.css" % theme)
|
||||||
|
|
||||||
@property
|
|
||||||
def scripts(self):
|
|
||||||
return self.__scripts
|
|
||||||
|
|
||||||
@property
|
|
||||||
def debug_scripts(self):
|
|
||||||
return self.__debug_scripts
|
|
||||||
|
|
||||||
@property
|
|
||||||
def dev_scripts(self):
|
|
||||||
return self.__dev_scripts
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def stylesheets(self):
|
def stylesheets(self):
|
||||||
return self.__stylesheets
|
return self.__stylesheets
|
||||||
|
Loading…
x
Reference in New Issue
Block a user