From ec8ef3ca69e9ad4c23e4509b9d4c3366c0f9edb3 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Wed, 3 Dec 2008 09:55:50 -0500 Subject: [PATCH] Automatically add plugins context to plugins[file.leafName] --- liberator/content/io.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/liberator/content/io.js b/liberator/content/io.js index 25a67916..5078e898 100644 --- a/liberator/content/io.js +++ b/liberator/content/io.js @@ -28,18 +28,26 @@ the terms of any one of the MPL, the GPL or the LGPL. }}} ***** END LICENSE BLOCK *****/ plugins.contexts = {}; -function Script(name) +function Script(file) { - let self = plugins.contexts[name] + let self = plugins.contexts[file.path] if (self) { if (self.onUnload) self.onUnload(); return self; } - plugins.contexts[name] = this; - this.NAME = name; + plugins.contexts[file.path] = this; + this.NAME = file.leafName.replace(/\..*/, "").replace(/-([a-z])/, function (_0, _1) _1.toUpperCase()); + this.PATH = file.path; this.__context__ = this; + + // This belongs elsewhere + for (let [,dir] in Iterator(io.getRuntimeDirectories("plugin"))) + { + if (dir.contains(file, false)) + plugins[name] = this.NAME; + } } Script.prototype = plugins; @@ -833,7 +841,7 @@ lookup: { try { - liberator.loadScript(uri.spec, new Script(file.path)); + liberator.loadScript(uri.spec, new Script(file)); } catch (e) {