mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-24 17:36:14 -04:00
Merge branch 'develop' of git://github.com/Pita/etherpad-lite
This commit is contained in:
commit
6120a0b7aa
20 changed files with 1197 additions and 295 deletions
|
@ -1,10 +1,13 @@
|
|||
var plugins = require("ep_etherpad-lite/static/js/pluginfw/plugins");
|
||||
var _;
|
||||
|
||||
/* FIXME: Ugly hack, in the future, use same code for server & client */
|
||||
if (plugins.isClient) {
|
||||
var async = require("ep_etherpad-lite/static/js/pluginfw/async");
|
||||
var async = require("ep_etherpad-lite/static/js/pluginfw/async");
|
||||
_ = require("ep_etherpad-lite/static/js/underscore");
|
||||
} else {
|
||||
var async = require("async");
|
||||
_ = require("underscore");
|
||||
}
|
||||
|
||||
exports.bubbleExceptions = true
|
||||
|
@ -41,7 +44,7 @@ exports.flatten = function (lst) {
|
|||
exports.callAll = function (hook_name, args) {
|
||||
if (!args) args = {};
|
||||
if (plugins.hooks[hook_name] === undefined) return [];
|
||||
return exports.flatten(plugins.hooks[hook_name].map(function (hook) {
|
||||
return exports.flatten(_.map(plugins.hooks[hook_name], function (hook) {
|
||||
return hookCallWrapper(hook, hook_name, args);
|
||||
}));
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
exports.isClient = typeof global != "object";
|
||||
|
||||
var _;
|
||||
|
||||
if (!exports.isClient) {
|
||||
var npm = require("npm/lib/npm.js");
|
||||
var readInstalled = require("./read-installed.js");
|
||||
|
@ -11,6 +13,11 @@ if (!exports.isClient) {
|
|||
var tsort = require("./tsort");
|
||||
var util = require("util");
|
||||
var extend = require("node.extend");
|
||||
_ = require("underscore");
|
||||
}else{
|
||||
var $, jQuery
|
||||
$ = jQuery = require("ep_etherpad-lite/static/js/rjquery").$;
|
||||
_ = require("ep_etherpad-lite/static/js/underscore");
|
||||
}
|
||||
|
||||
exports.prefix = 'ep_';
|
||||
|
@ -27,17 +34,17 @@ exports.ensure = function (cb) {
|
|||
}
|
||||
|
||||
exports.formatPlugins = function () {
|
||||
return Object.keys(exports.plugins).join(", ");
|
||||
return _.keys(exports.plugins).join(", ");
|
||||
}
|
||||
|
||||
exports.formatParts = function () {
|
||||
return exports.parts.map(function (part) { return part.full_name; }).join("\n");
|
||||
return _.map(exports.parts, function (part) { return part.full_name; }).join("\n");
|
||||
}
|
||||
|
||||
exports.formatHooks = function () {
|
||||
var res = [];
|
||||
Object.keys(exports.hooks).forEach(function (hook_name) {
|
||||
exports.hooks[hook_name].forEach(function (hook) {
|
||||
_.chain(exports.hooks).keys().forEach(function (hook_name) {
|
||||
_.forEach(exports.hooks[hook_name], function (hook) {
|
||||
res.push(hook.hook_name + ": " + hook.hook_fn_name + " from " + hook.part.full_name);
|
||||
});
|
||||
});
|
||||
|
@ -47,7 +54,7 @@ exports.formatHooks = function () {
|
|||
exports.loadFn = function (path) {
|
||||
var x = path.split(":");
|
||||
var fn = require(x[0]);
|
||||
x[1].split(".").forEach(function (name) {
|
||||
_.each(x[1].split("."), function (name) {
|
||||
fn = fn[name];
|
||||
});
|
||||
return fn;
|
||||
|
@ -55,8 +62,8 @@ exports.loadFn = function (path) {
|
|||
|
||||
exports.extractHooks = function (parts, hook_set_name) {
|
||||
var hooks = {};
|
||||
parts.forEach(function (part) {
|
||||
Object.keys(part[hook_set_name] || {}).forEach(function (hook_name) {
|
||||
_.each(parts,function (part) {
|
||||
_.chain(part[hook_set_name] || {}).keys().each(function (hook_name) {
|
||||
if (hooks[hook_name] === undefined) hooks[hook_name] = [];
|
||||
var hook_fn_name = part[hook_set_name][hook_name];
|
||||
var hook_fn = exports.loadFn(part[hook_set_name][hook_name]);
|
||||
|
@ -79,6 +86,9 @@ if (exports.isClient) {
|
|||
exports.hooks = exports.extractHooks(exports.parts, "client_hooks");
|
||||
exports.loaded = true;
|
||||
cb();
|
||||
}).error(function(xhr, s, err){
|
||||
console.error("Failed to load plugin-definitions: " + err);
|
||||
cb();
|
||||
});
|
||||
}
|
||||
} else {
|
||||
|
@ -111,7 +121,7 @@ exports.getPackages = function (cb) {
|
|||
if (er) cb(er, null);
|
||||
var packages = {};
|
||||
function flatten(deps) {
|
||||
Object.keys(deps).forEach(function (name) {
|
||||
_.chain(deps).keys().each(function (name) {
|
||||
if (name.indexOf(exports.prefix) == 0) {
|
||||
packages[name] = extend({}, deps[name]);
|
||||
// Delete anything that creates loops so that the plugin
|
||||
|
@ -143,7 +153,7 @@ exports.loadPlugin = function (packages, plugin_name, plugins, parts, cb) {
|
|||
var plugin = JSON.parse(data);
|
||||
plugin.package = packages[plugin_name];
|
||||
plugins[plugin_name] = plugin;
|
||||
plugin.parts.forEach(function (part) {
|
||||
_.each(plugin.parts, function (part) {
|
||||
part.plugin = plugin_name;
|
||||
part.full_name = plugin_name + "/" + part.name;
|
||||
parts[part.full_name] = part;
|
||||
|
@ -158,11 +168,11 @@ exports.loadPlugin = function (packages, plugin_name, plugins, parts, cb) {
|
|||
|
||||
exports.partsToParentChildList = function (parts) {
|
||||
var res = [];
|
||||
Object.keys(parts).forEach(function (name) {
|
||||
(parts[name].post || []).forEach(function (child_name) {
|
||||
_.chain(parts).keys().forEach(function (name) {
|
||||
_.each(parts[name].post || [], function (child_name) {
|
||||
res.push([name, child_name]);
|
||||
});
|
||||
(parts[name].pre || []).forEach(function (parent_name) {
|
||||
_.each(parts[name].pre || [], function (parent_name) {
|
||||
res.push([parent_name, name]);
|
||||
});
|
||||
if (!parts[name].pre && !parts[name].post) {
|
||||
|
@ -172,6 +182,8 @@ exports.partsToParentChildList = function (parts) {
|
|||
return res;
|
||||
}
|
||||
|
||||
|
||||
// Used only in Node, so no need for _
|
||||
exports.sortParts = function(parts) {
|
||||
return tsort(
|
||||
exports.partsToParentChildList(parts)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue