summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn McLear <john@mclear.co.uk>2012-06-22 03:53:50 -0700
committerJohn McLear <john@mclear.co.uk>2012-06-22 03:53:50 -0700
commite4ff4021ab016728a711dd98e8a734e0868ffd53 (patch)
tree3cf1a8dafe548a9dec9e9c153db5cba7bdccad4b
parentab467310f58d6c4e9cb1d73ebf2fc30a51a827c5 (diff)
parent476cfc8da0d26b876480665ece4e7ff9a85315fc (diff)
downloadetherpad-lite-e4ff4021ab016728a711dd98e8a734e0868ffd53.zip
Merge pull request #810 from redhog/aceEditEvent
Plugin/hook features&bugfixes
-rw-r--r--src/node/hooks/express/adminplugins.js5
-rw-r--r--src/static/js/ace2_inner.js14
-rw-r--r--src/static/js/pluginfw/hooks.js2
-rw-r--r--src/static/js/pluginfw/plugins.js14
-rw-r--r--src/templates/admin/plugins-info.html30
-rw-r--r--src/templates/admin/plugins.html3
6 files changed, 61 insertions, 7 deletions
diff --git a/src/node/hooks/express/adminplugins.js b/src/node/hooks/express/adminplugins.js
index 7b21206c..fc274a07 100644
--- a/src/node/hooks/express/adminplugins.js
+++ b/src/node/hooks/express/adminplugins.js
@@ -16,6 +16,11 @@ exports.expressCreateServer = function (hook_name, args, cb) {
"ep_etherpad-lite/templates/admin/plugins.html",
render_args), {});
});
+ args.app.get('/admin/plugins/info', function(req, res) {
+ res.send(eejs.require(
+ "ep_etherpad-lite/templates/admin/plugins-info.html",
+ {}), {});
+ });
}
exports.socketio = function (hook_name, args, cb) {
diff --git a/src/static/js/ace2_inner.js b/src/static/js/ace2_inner.js
index 723d410f..cc9f1288 100644
--- a/src/static/js/ace2_inner.js
+++ b/src/static/js/ace2_inner.js
@@ -341,6 +341,11 @@ function Ace2Inner(){
return rep;
};
+ editorInfo.ace_getAuthor = function()
+ {
+ return thisAuthor;
+ }
+
var currentCallStack = null;
function inCallStack(type, action)
@@ -439,6 +444,14 @@ function Ace2Inner(){
try
{
result = action();
+
+ hooks.callAll('aceEditEvent', {
+ callstack: currentCallStack,
+ editorInfo: editorInfo,
+ rep: rep,
+ documentAttributeManager: documentAttributeManager
+ });
+
//console.log("Just did action for: "+type);
cleanExit = true;
}
@@ -522,6 +535,7 @@ function Ace2Inner(){
{
return rep.lines.atOffset(charOffset).key;
}
+
function dispose()
{
diff --git a/src/static/js/pluginfw/hooks.js b/src/static/js/pluginfw/hooks.js
index 49e46c60..7281cac9 100644
--- a/src/static/js/pluginfw/hooks.js
+++ b/src/static/js/pluginfw/hooks.js
@@ -102,7 +102,7 @@ exports.aCallAll = function (hook_name, args, cb) {
exports.callFirst = function (hook_name, args) {
if (!args) args = {};
- if (plugins.hooks[hook_name][0] === undefined) return [];
+ if (plugins.hooks[hook_name] === undefined) return [];
return exports.syncMapFirst(plugins.hooks[hook_name], function (hook) {
return hookCallWrapper(hook, hook_name, args);
});
diff --git a/src/static/js/pluginfw/plugins.js b/src/static/js/pluginfw/plugins.js
index 1f66da41..1d486223 100644
--- a/src/static/js/pluginfw/plugins.js
+++ b/src/static/js/pluginfw/plugins.js
@@ -41,14 +41,16 @@ exports.formatParts = function () {
return _.map(exports.parts, function (part) { return part.full_name; }).join("\n");
};
-exports.formatHooks = function () {
+exports.formatHooks = function (hook_set_name) {
var res = [];
- _.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);
+ var hooks = exports.extractHooks(exports.parts, hook_set_name || "hooks");
+
+ _.chain(hooks).keys().forEach(function (hook_name) {
+ _.forEach(hooks[hook_name], function (hook) {
+ res.push("<dt>" + hook.hook_name + "</dt><dd>" + hook.hook_fn_name + " from " + hook.part.full_name + "</dd>");
});
});
- return res.join("\n");
+ return "<dl>" + res.join("\n") + "</dl>";
};
exports.loadFn = function (path, hookName) {
@@ -62,7 +64,7 @@ exports.loadFn = function (path, hookName) {
return fn;
};
-exports.extractHooks = function (parts, hook_set_name, plugins) {
+exports.extractHooks = function (parts, hook_set_name) {
var hooks = {};
_.each(parts,function (part) {
_.chain(part[hook_set_name] || {})
diff --git a/src/templates/admin/plugins-info.html b/src/templates/admin/plugins-info.html
new file mode 100644
index 00000000..22f87073
--- /dev/null
+++ b/src/templates/admin/plugins-info.html
@@ -0,0 +1,30 @@
+<%
+ var plugins = require("ep_etherpad-lite/static/js/pluginfw/plugins");
+%>
+
+<html>
+ <head>
+ <title>Plugin information</title>
+ <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0">
+ <link rel="stylesheet" href="../../static/css/admin.css">
+ </head>
+ <body>
+ <div id="wrapper">
+ <h1>Etherpad Lite</h1>
+ <div class="separator"></div>
+
+ <h2>Installed plugins</h2>
+ <pre><%= plugins.formatPlugins() %></pre>
+
+ <h2>Installed parts</h2>
+ <pre><%= plugins.formatParts() %></pre>
+
+ <h2>Installed hooks</h2>
+ <h3>Server side hooks</h3>
+ <div><%= plugins.formatHooks() %></div>
+
+ <h3>Client side hooks</h3>
+ <div><%= plugins.formatHooks("client_hooks") %></div>
+ </div>
+ </body>
+</html>
diff --git a/src/templates/admin/plugins.html b/src/templates/admin/plugins.html
index 97001269..104f6b98 100644
--- a/src/templates/admin/plugins.html
+++ b/src/templates/admin/plugins.html
@@ -20,6 +20,9 @@
<h1>Etherpad Lite</h1>
+
+ <a href="/admin/plugins/info">Technical information on installed plugins</a>
+
<div class="separator"></div>
<h2>Installed plugins</h2>
<table>