Merge pull request #810 from redhog/aceEditEvent

Plugin/hook features&bugfixes
This commit is contained in:
John McLear 2012-06-22 03:53:50 -07:00
commit e4ff4021ab
6 changed files with 61 additions and 7 deletions

View file

@ -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) {

View file

@ -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()
{

View file

@ -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);
});

View file

@ -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] || {})

View file

@ -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>

View file

@ -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>