From 07c33c77c4b41a3181064beacc407565738c4929 Mon Sep 17 00:00:00 2001 From: d-a-n Date: Tue, 2 Oct 2012 22:10:18 +0300 Subject: [PATCH 1/8] Updated docs for new pad hooks (add, edit, remove) --- doc/api/hooks_server-side.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/doc/api/hooks_server-side.md b/doc/api/hooks_server-side.md index 06ec7374b..be5564a66 100644 --- a/doc/api/hooks_server-side.md +++ b/doc/api/hooks_server-side.md @@ -64,6 +64,34 @@ This hook gets called upon the rendering of an ejs template block. For any speci Have a look at `src/templates/pad.html` and `src/templates/timeslider.html` to see which blocks are available. +## padCreated +Called from: src/node/db/Pad.js + +1. pad - the pad instance + +This hook gets called when a new pad was created. + +## padLoaded +Called from: src/node/db/Pad.js + +1. pad - the pad instance + +This hook gets called when an pad was loaded. + +## padUpdated +Called from: src/node/db/Pad.js + +1. pad - the pad instance + +This hook gets called when an existing pad was updated. + +## padRemoved +Called from: src/node/db/Pad.js + +1. pad - the pad instance + +This hook gets called when an existing pad was removed/deleted. + ## socketio Called from: src/node/hooks/express/socketio.js From c0f2e557d36f5b13604fff603ff26d5a9e4d0f64 Mon Sep 17 00:00:00 2001 From: d-a-n Date: Tue, 2 Oct 2012 22:11:54 +0300 Subject: [PATCH 2/8] Updated docs for new pad hooks (add, edit, remove) --- doc/api/hooks_server-side.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/doc/api/hooks_server-side.md b/doc/api/hooks_server-side.md index be5564a66..b6ee1604c 100644 --- a/doc/api/hooks_server-side.md +++ b/doc/api/hooks_server-side.md @@ -67,6 +67,8 @@ Have a look at `src/templates/pad.html` and `src/templates/timeslider.html` to s ## padCreated Called from: src/node/db/Pad.js +Things in context: + 1. pad - the pad instance This hook gets called when a new pad was created. @@ -74,6 +76,8 @@ This hook gets called when a new pad was created. ## padLoaded Called from: src/node/db/Pad.js +Things in context: + 1. pad - the pad instance This hook gets called when an pad was loaded. @@ -81,6 +85,8 @@ This hook gets called when an pad was loaded. ## padUpdated Called from: src/node/db/Pad.js +Things in context: + 1. pad - the pad instance This hook gets called when an existing pad was updated. @@ -88,6 +94,8 @@ This hook gets called when an existing pad was updated. ## padRemoved Called from: src/node/db/Pad.js +Things in context: + 1. pad - the pad instance This hook gets called when an existing pad was removed/deleted. From 64a3d60b943bdf7ae643f3fcb5791ffbc95b77ae Mon Sep 17 00:00:00 2001 From: d-a-n Date: Tue, 2 Oct 2012 22:30:13 +0300 Subject: [PATCH 3/8] Added pad hooks (create, load, edit, remove) --- src/node/db/Pad.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/node/db/Pad.js b/src/node/db/Pad.js index ad2d59f38..cf04f9bc0 100644 --- a/src/node/db/Pad.js +++ b/src/node/db/Pad.js @@ -16,6 +16,7 @@ var padMessageHandler = require("../handler/PadMessageHandler"); var readOnlyManager = require("./ReadOnlyManager"); var crypto = require("crypto"); var randomString = require("../utils/randomstring"); +var hooks = require('ep_etherpad-lite/static/js/pluginfw/hooks'); //serialization/deserialization attributes var attributeBlackList = ["id"]; @@ -86,6 +87,12 @@ Pad.prototype.appendRevision = function appendRevision(aChangeset, author) { // set the author to pad if(author) authorManager.addPad(author, this.id); + + if (this.head == 0) { + hooks.callAll("padCreated", this); + } else { + hooks.callAll("padUpdated", this); + } }; //save all attributes to the database @@ -368,6 +375,7 @@ Pad.prototype.init = function init(text, callback) { _this.appendRevision(firstChangeset, ''); } + hooks.callAll("padLoaded", _this); callback(null); }); }; @@ -467,6 +475,7 @@ Pad.prototype.remove = function remove(callback) { { db.remove("pad:"+padID); padManager.unloadPad(padID); + hooks.callAll("padRemoved", padID ); callback(); } ], function(err) From 4652751285ed4c4788442910574350f163f51ca9 Mon Sep 17 00:00:00 2001 From: d-a-n Date: Tue, 2 Oct 2012 22:32:30 +0300 Subject: [PATCH 4/8] Updated docs for new pad hooks (add, edit, remove) --- doc/api/hooks_server-side.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/hooks_server-side.md b/doc/api/hooks_server-side.md index b6ee1604c..84ca44904 100644 --- a/doc/api/hooks_server-side.md +++ b/doc/api/hooks_server-side.md @@ -96,7 +96,7 @@ Called from: src/node/db/Pad.js Things in context: -1. pad - the pad instance +1. pad id This hook gets called when an existing pad was removed/deleted. From 754c559d632c08be58f06c3eedb3a9494c51dedf Mon Sep 17 00:00:00 2001 From: d-a-n Date: Wed, 3 Oct 2012 13:35:31 +0300 Subject: [PATCH 5/8] Changed pad hook names to follow naming conventions. --- doc/api/hooks_server-side.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/api/hooks_server-side.md b/doc/api/hooks_server-side.md index 84ca44904..bc56f19bb 100644 --- a/doc/api/hooks_server-side.md +++ b/doc/api/hooks_server-side.md @@ -64,7 +64,7 @@ This hook gets called upon the rendering of an ejs template block. For any speci Have a look at `src/templates/pad.html` and `src/templates/timeslider.html` to see which blocks are available. -## padCreated +## padCreate Called from: src/node/db/Pad.js Things in context: @@ -73,16 +73,16 @@ Things in context: This hook gets called when a new pad was created. -## padLoaded +## padLoad Called from: src/node/db/Pad.js Things in context: 1. pad - the pad instance -This hook gets called when an pad was loaded. +This hook gets called when an pad was loaded. If a new pad was created and loaded this event will be emitted too. -## padUpdated +## padUpdate Called from: src/node/db/Pad.js Things in context: @@ -91,7 +91,7 @@ Things in context: This hook gets called when an existing pad was updated. -## padRemoved +## padRemove Called from: src/node/db/Pad.js Things in context: From 358e4817310eceec8df664f3c428ba0afdc430dc Mon Sep 17 00:00:00 2001 From: d-a-n Date: Wed, 3 Oct 2012 13:41:40 +0300 Subject: [PATCH 6/8] Changed pad hook names to follow naming conventions. Arguments will now be passed as hash. --- src/node/db/Pad.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/node/db/Pad.js b/src/node/db/Pad.js index cf04f9bc0..d6ea8277d 100644 --- a/src/node/db/Pad.js +++ b/src/node/db/Pad.js @@ -89,9 +89,9 @@ Pad.prototype.appendRevision = function appendRevision(aChangeset, author) { authorManager.addPad(author, this.id); if (this.head == 0) { - hooks.callAll("padCreated", this); + hooks.callAll("padCreate", {'pad':this}); } else { - hooks.callAll("padUpdated", this); + hooks.callAll("padUpdate", {'pad':this}); } }; @@ -375,7 +375,7 @@ Pad.prototype.init = function init(text, callback) { _this.appendRevision(firstChangeset, ''); } - hooks.callAll("padLoaded", _this); + hooks.callAll("padLoad", {'pad':_this}); callback(null); }); }; @@ -475,7 +475,7 @@ Pad.prototype.remove = function remove(callback) { { db.remove("pad:"+padID); padManager.unloadPad(padID); - hooks.callAll("padRemoved", padID ); + hooks.callAll("padRemove", {'pad_id':padID}); callback(); } ], function(err) From 0fd8490ca6e3f2218c9ab16bf722725d173caa34 Mon Sep 17 00:00:00 2001 From: d-a-n Date: Wed, 3 Oct 2012 15:49:28 +0300 Subject: [PATCH 7/8] Changed pad_id to padID to follow projct standards. --- doc/api/hooks_server-side.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/hooks_server-side.md b/doc/api/hooks_server-side.md index bc56f19bb..49eb6cc5f 100644 --- a/doc/api/hooks_server-side.md +++ b/doc/api/hooks_server-side.md @@ -96,7 +96,7 @@ Called from: src/node/db/Pad.js Things in context: -1. pad id +1. padID This hook gets called when an existing pad was removed/deleted. From a521a125830a18213d71991d55c5d04269c5ee94 Mon Sep 17 00:00:00 2001 From: d-a-n Date: Wed, 3 Oct 2012 15:50:43 +0300 Subject: [PATCH 8/8] Changed pad_id to padID to follow projct standards. --- src/node/db/Pad.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/node/db/Pad.js b/src/node/db/Pad.js index d6ea8277d..dba791fd2 100644 --- a/src/node/db/Pad.js +++ b/src/node/db/Pad.js @@ -475,7 +475,7 @@ Pad.prototype.remove = function remove(callback) { { db.remove("pad:"+padID); padManager.unloadPad(padID); - hooks.callAll("padRemove", {'pad_id':padID}); + hooks.callAll("padRemove", {'padID':padID}); callback(); } ], function(err)