aboutsummaryrefslogtreecommitdiffstats
path: root/trunk
diff options
context:
space:
mode:
authorEgil Moeller <egil.moller@freecode.no>2010-03-13 11:21:00 +0100
committerEgil Moeller <egil.moller@freecode.no>2010-03-13 11:21:00 +0100
commitf0103348955a6e282ad608228b310035d5a868e9 (patch)
treed0f25a1d9d4fd281effbbabaa2cb4bc027f4a05e /trunk
parentf60fc17c398721a83b93c65a29cb263f6912bfdf (diff)
downloadetherpad-f0103348955a6e282ad608228b310035d5a868e9.tar.gz
etherpad-f0103348955a6e282ad608228b310035d5a868e9.tar.xz
etherpad-f0103348955a6e282ad608228b310035d5a868e9.zip
Made it possible to split out parts of a plugin into separate files
Diffstat (limited to 'trunk')
-rw-r--r--trunk/etherpad/src/etherpad/admin/plugins.js4
-rw-r--r--trunk/etherpad/src/plugins/testplugin/hooks.js15
-rw-r--r--trunk/etherpad/src/plugins/testplugin/main.js26
3 files changed, 28 insertions, 17 deletions
diff --git a/trunk/etherpad/src/etherpad/admin/plugins.js b/trunk/etherpad/src/etherpad/admin/plugins.js
index 8500acb..3df1ad1 100644
--- a/trunk/etherpad/src/etherpad/admin/plugins.js
+++ b/trunk/etherpad/src/etherpad/admin/plugins.js
@@ -55,7 +55,9 @@ function loadAvailablePlugin(pluginName) {
var pluginModulePath = pluginFile.getPath().replace(new RegExp("src/\(.*\)\.js"), "$1").replace("/", ".", "g");
var importStmt = "import('" + pluginModulePath + "')";
try {
- return execution.fancyAssEval(importStmt, "main;");
+ var res = execution.fancyAssEval(importStmt, "main;");
+ res = new res.init();
+ return res;
} catch (e) {
log.info({errorLoadingPlugin:exceptionutils.getStackTracePlain(e)});
}
diff --git a/trunk/etherpad/src/plugins/testplugin/hooks.js b/trunk/etherpad/src/plugins/testplugin/hooks.js
new file mode 100644
index 0000000..493a2c2
--- /dev/null
+++ b/trunk/etherpad/src/plugins/testplugin/hooks.js
@@ -0,0 +1,15 @@
+import("etherpad.log");
+import("dispatch.{Dispatcher,PrefixMatcher,forward}");
+import("plugins.testplugin.controllers.testplugin");
+
+function serverStartup() {
+ log.info("Server startup for testplugin");
+}
+
+function serverShutdown() {
+ log.info("Server shutdown for testplugin");
+}
+
+function handlePath() {
+ return [[PrefixMatcher('/ep/testplugin/'), forward(testplugin)]];
+}
diff --git a/trunk/etherpad/src/plugins/testplugin/main.js b/trunk/etherpad/src/plugins/testplugin/main.js
index f5d736b..74a6cfe 100644
--- a/trunk/etherpad/src/plugins/testplugin/main.js
+++ b/trunk/etherpad/src/plugins/testplugin/main.js
@@ -1,10 +1,15 @@
import("etherpad.log");
-import("etherpad.admin.plugins");
-import("dispatch.{Dispatcher,PrefixMatcher,forward}");
-import("plugins.testplugin.controllers.testplugin");
+import("plugins.testplugin.hooks");
-hooks = ['serverStartup', 'serverShutdown', 'handlePath'];
-description = 'Test Plugin';
+function init() {
+ this.hooks = ['serverStartup', 'serverShutdown', 'handlePath'];
+ this.description = 'Test Plugin';
+ this.serverStartup = hooks.serverStartup;
+ this.serverShutdown = hooks.serverShutdown;
+ this.handlePath = hooks.handlePath;
+ this.install = install;
+ this.uninstall = uninstall;
+}
function install() {
log.info("Installing testplugin");
@@ -14,14 +19,3 @@ function uninstall() {
log.info("Uninstalling testplugin");
}
-function serverStartup() {
- log.info("Server startup for testplugin");
-}
-
-function serverShutdown() {
- log.info("Server shutdown for testplugin");
-}
-
-function handlePath() {
- return [[PrefixMatcher('/ep/testplugin/'), forward(testplugin)]];
-} \ No newline at end of file