diff options
author | Egil Moeller <egil.moller@freecode.no> | 2012-04-05 01:48:12 +0200 |
---|---|---|
committer | Egil Moeller <egil.moller@freecode.no> | 2012-04-05 01:48:12 +0200 |
commit | 8cd1298a16c0ec2391cb7b4909be327a557d91ec (patch) | |
tree | 3025863da92e8bfb42f8c3f0bb91e85ce6f48ee3 /src | |
parent | 4325f0b9076fa3ab1eb8f846129ca513fada699b (diff) | |
download | etherpad-lite-8cd1298a16c0ec2391cb7b4909be327a557d91ec.zip |
Added init hook to install plugin database default content and the like
Diffstat (limited to 'src')
-rw-r--r-- | src/static/js/pluginfw/plugins.js | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/static/js/pluginfw/plugins.js b/src/static/js/pluginfw/plugins.js index 058f1351..7eb82d38 100644 --- a/src/static/js/pluginfw/plugins.js +++ b/src/static/js/pluginfw/plugins.js @@ -93,6 +93,28 @@ if (exports.isClient) { } } else { +exports.callInit = function (cb) { + var hooks = require("./hooks"); + async.map( + Object.keys(exports.plugins), + function (plugin_name, cb) { + var plugin = exports.plugins[plugin_name]; + fs.stat(path.normalize(path.join(plugin.package.path, ".ep_initialized")), function (err, stats) { + if (err) { + async.waterfall([ + function (cb) { fs.writeFile(path.normalize(path.join(plugin.package.path, ".ep_initialized")), 'done', cb); }, + function (cb) { hooks.aCallAll("init_" + plugin_name, {}, cb); }, + cb, + ]); + } else { + cb(); + } + }); + }, + function () { cb(); } + ); +} + exports.update = function (cb) { exports.getPackages(function (er, packages) { var parts = []; @@ -104,11 +126,12 @@ exports.update = function (cb) { exports.loadPlugin(packages, plugin_name, plugins, parts, cb); }, function (err) { + if (err) cb(err); exports.plugins = plugins; exports.parts = exports.sortParts(parts); exports.hooks = exports.extractHooks(exports.parts, "hooks"); exports.loaded = true; - cb(err); + exports.callInit(cb); } ); }); |