diff options
-rw-r--r-- | trunk/etherpad/src/etherpad/admin/plugins.js | 4 | ||||
-rw-r--r-- | trunk/etherpad/src/plugins/testplugin/hooks.js | 15 | ||||
-rw-r--r-- | trunk/etherpad/src/plugins/testplugin/main.js | 26 |
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 |