mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-19 22:23:33 +01:00
Inject plugins into hooks.
This commit is contained in:
parent
3631f0ece3
commit
9394495364
3 changed files with 13 additions and 9 deletions
|
@ -1,4 +1,3 @@
|
||||||
var plugins = require("./plugins");
|
|
||||||
var async = require("async");
|
var async = require("async");
|
||||||
var _ = require("underscore");
|
var _ = require("underscore");
|
||||||
|
|
||||||
|
@ -71,8 +70,8 @@ exports.flatten = function (lst) {
|
||||||
|
|
||||||
exports.callAll = function (hook_name, args) {
|
exports.callAll = function (hook_name, args) {
|
||||||
if (!args) args = {};
|
if (!args) args = {};
|
||||||
if (plugins.hooks[hook_name] === undefined) return [];
|
if (exports.plugins.hooks[hook_name] === undefined) return [];
|
||||||
return _.flatten(_.map(plugins.hooks[hook_name], function (hook) {
|
return _.flatten(_.map(exports.plugins.hooks[hook_name], function (hook) {
|
||||||
return hookCallWrapper(hook, hook_name, args);
|
return hookCallWrapper(hook, hook_name, args);
|
||||||
}), true);
|
}), true);
|
||||||
}
|
}
|
||||||
|
@ -80,9 +79,9 @@ exports.callAll = function (hook_name, args) {
|
||||||
exports.aCallAll = function (hook_name, args, cb) {
|
exports.aCallAll = function (hook_name, args, cb) {
|
||||||
if (!args) args = {};
|
if (!args) args = {};
|
||||||
if (!cb) cb = function () {};
|
if (!cb) cb = function () {};
|
||||||
if (plugins.hooks[hook_name] === undefined) return cb(null, []);
|
if (exports.plugins.hooks[hook_name] === undefined) return cb(null, []);
|
||||||
async.map(
|
async.map(
|
||||||
plugins.hooks[hook_name],
|
exports.plugins.hooks[hook_name],
|
||||||
function (hook, cb) {
|
function (hook, cb) {
|
||||||
hookCallWrapper(hook, hook_name, args, function (res) { cb(null, res); });
|
hookCallWrapper(hook, hook_name, args, function (res) { cb(null, res); });
|
||||||
},
|
},
|
||||||
|
@ -94,8 +93,8 @@ exports.aCallAll = function (hook_name, args, cb) {
|
||||||
|
|
||||||
exports.callFirst = function (hook_name, args) {
|
exports.callFirst = function (hook_name, args) {
|
||||||
if (!args) args = {};
|
if (!args) args = {};
|
||||||
if (plugins.hooks[hook_name] === undefined) return [];
|
if (exports.plugins.hooks[hook_name] === undefined) return [];
|
||||||
return exports.syncMapFirst(plugins.hooks[hook_name], function (hook) {
|
return exports.syncMapFirst(exports.plugins.hooks[hook_name], function (hook) {
|
||||||
return hookCallWrapper(hook, hook_name, args);
|
return hookCallWrapper(hook, hook_name, args);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -103,9 +102,9 @@ exports.callFirst = function (hook_name, args) {
|
||||||
exports.aCallFirst = function (hook_name, args, cb) {
|
exports.aCallFirst = function (hook_name, args, cb) {
|
||||||
if (!args) args = {};
|
if (!args) args = {};
|
||||||
if (!cb) cb = function () {};
|
if (!cb) cb = function () {};
|
||||||
if (plugins.hooks[hook_name] === undefined) return cb(null, []);
|
if (exports.plugins.hooks[hook_name] === undefined) return cb(null, []);
|
||||||
exports.mapFirst(
|
exports.mapFirst(
|
||||||
plugins.hooks[hook_name],
|
exports.plugins.hooks[hook_name],
|
||||||
function (hook, cb) {
|
function (hook, cb) {
|
||||||
hookCallWrapper(hook, hook_name, args, function (res) { cb(null, res); });
|
hookCallWrapper(hook, hook_name, args, function (res) { cb(null, res); });
|
||||||
},
|
},
|
||||||
|
|
|
@ -374,6 +374,8 @@
|
||||||
|
|
||||||
plugins.baseURL = baseURL;
|
plugins.baseURL = baseURL;
|
||||||
plugins.update(function () {
|
plugins.update(function () {
|
||||||
|
hooks.plugins = plugins;
|
||||||
|
|
||||||
// Call documentReady hook
|
// Call documentReady hook
|
||||||
$(function() {
|
$(function() {
|
||||||
hooks.aCallAll('documentReady');
|
hooks.aCallAll('documentReady');
|
||||||
|
|
|
@ -179,6 +179,9 @@
|
||||||
plugins.baseURL = baseURL;
|
plugins.baseURL = baseURL;
|
||||||
|
|
||||||
plugins.update(function () {
|
plugins.update(function () {
|
||||||
|
var hooks = require('ep_etherpad-lite/static/js/pluginfw/hooks');
|
||||||
|
hooks.plugins = plugins;
|
||||||
|
|
||||||
var timeslider = require('ep_etherpad-lite/static/js/timeslider')
|
var timeslider = require('ep_etherpad-lite/static/js/timeslider')
|
||||||
timeslider.baseURL = baseURL;
|
timeslider.baseURL = baseURL;
|
||||||
timeslider.init();
|
timeslider.init();
|
||||||
|
|
Loading…
Reference in a new issue