mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-22 08:26:16 -04:00
Integrated hooks into templates and provided a blokc/hook for the left and right editbar menu
This commit is contained in:
parent
05c2e0fde5
commit
a5366a0a16
5 changed files with 83 additions and 57 deletions
|
@ -25,7 +25,8 @@
|
|||
"hooks": {
|
||||
"somehookname": "ep_fintest/otherpart:somehook",
|
||||
"morehook": "ep_fintest/otherpart:morehook",
|
||||
"expressCreateServer": "ep_fintest/otherpart:expressServer"
|
||||
"expressCreateServer": "ep_fintest/otherpart:expressServer",
|
||||
"eejsBlock_editbarMenuLeft": "ep_fintest/otherpart:eejsBlock_editbarMenuLeft"
|
||||
},
|
||||
"client_hooks": {
|
||||
"somehookname": "ep_fintest/static/js/test:bar"
|
||||
|
|
|
@ -14,3 +14,12 @@ exports.expressServer = function (hook_name, args, cb) {
|
|||
res.send("<em>Abra cadabra</em>");
|
||||
});
|
||||
}
|
||||
|
||||
exports.eejsBlock_editbarMenuLeft = function (hook_name, args, cb) {
|
||||
args.content = args.content + '\
|
||||
<li id="testButton" onClick="window.pad&&pad.editbarClick(\'clearauthorship\');return false;">\
|
||||
<a class="buttonicon buttonicon-test" title="Test test test"></a>\
|
||||
</li>\
|
||||
';
|
||||
return cb();
|
||||
}
|
||||
|
|
|
@ -2,4 +2,6 @@
|
|||
|
||||
<% e.begin_define_block("foo"); %>
|
||||
YY
|
||||
<% e.super(); %>
|
||||
ZZ
|
||||
<% e.end_define_block(); %>
|
||||
|
|
|
@ -16,12 +16,13 @@
|
|||
|
||||
/* Basic usage:
|
||||
*
|
||||
* require("./eejs").require("./examples/foo.ejs")
|
||||
* require("./index").require("./examples/foo.ejs")
|
||||
*/
|
||||
|
||||
var ejs = require("ejs");
|
||||
var fs = require("fs");
|
||||
var path = require("path");
|
||||
var hooks = require("ep_etherpad-lite/static/js/pluginfw/hooks.js");
|
||||
|
||||
exports.info = {
|
||||
buf_stack: [],
|
||||
|
@ -62,17 +63,26 @@ exports.begin_define_block = function (name) {
|
|||
exports.begin_capture();
|
||||
}
|
||||
|
||||
exports.super = function () {
|
||||
exports.info.buf.push('<!eejs!super!>');
|
||||
}
|
||||
|
||||
exports.end_define_block = function () {
|
||||
content = exports.end_capture();
|
||||
var name = exports.info.block_stack.pop();
|
||||
if (typeof exports.info.blocks[name].content == "undefined")
|
||||
exports.info.blocks[name].content = content;
|
||||
else if (typeof exports.info.blocks[name].content.indexOf('<!eejs!super!>'))
|
||||
exports.info.blocks[name].content = exports.info.blocks[name].content.replace('<!eejs!super!>', content);
|
||||
|
||||
return exports.info.blocks[name].content;
|
||||
}
|
||||
|
||||
exports.end_block = function () {
|
||||
var res = exports.end_define_block();
|
||||
exports.info.buf.push(res);
|
||||
var name = exports.info.block_stack[exports.info.block_stack.length-1];
|
||||
var args = {content: exports.end_define_block()};
|
||||
hooks.callAll("eejsBlock_" + name, args);
|
||||
exports.info.buf.push(args.content);
|
||||
}
|
||||
|
||||
exports.begin_block = exports.begin_define_block;
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
<div id="editbar">
|
||||
<ul id="menu_left">
|
||||
<% e.begin_block("editbarMenuLeft"); %>
|
||||
<li id="bold" onClick="window.pad&&pad.editbarClick('bold');return false">
|
||||
<a class="buttonicon buttonicon-bold" title="Bold (ctrl-B)"></a>
|
||||
</li>
|
||||
|
@ -51,8 +52,10 @@
|
|||
<li id="clearAuthorship" onClick="window.pad&&pad.editbarClick('clearauthorship');return false;">
|
||||
<a class="buttonicon buttonicon-clearauthorship" title="Clear Authorship Colors"></a>
|
||||
</li>
|
||||
<% e.end_block(); %>
|
||||
</ul>
|
||||
<ul id="menu_right">
|
||||
<% e.begin_block("editbarMenuRight"); %>
|
||||
<li id="settingslink" onClick="window.pad&&pad.editbarClick('settings');return false;">
|
||||
<a class="buttonicon buttonicon-settings" id="settingslink" title="Settings of this pad"></a>
|
||||
</li>
|
||||
|
@ -70,6 +73,7 @@
|
|||
<span class="buttonicon buttonicon-showusers" id="usericonback"></span>
|
||||
<span id="online_count">1</span>
|
||||
</li>
|
||||
<% e.end_block(); %>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue