Merge pull request #1034 from d-a-n/develop
Added hooks for pad events create/edit/load/remove
This commit is contained in:
commit
db1a1a0e3e
|
@ -65,6 +65,42 @@ 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.
|
Have a look at `src/templates/pad.html` and `src/templates/timeslider.html` to see which blocks are available.
|
||||||
|
|
||||||
|
## padCreate
|
||||||
|
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.
|
||||||
|
|
||||||
|
## 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. If a new pad was created and loaded this event will be emitted too.
|
||||||
|
|
||||||
|
## padUpdate
|
||||||
|
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.
|
||||||
|
|
||||||
|
## padRemove
|
||||||
|
Called from: src/node/db/Pad.js
|
||||||
|
|
||||||
|
Things in context:
|
||||||
|
|
||||||
|
1. padID
|
||||||
|
|
||||||
|
This hook gets called when an existing pad was removed/deleted.
|
||||||
|
|
||||||
## socketio
|
## socketio
|
||||||
Called from: src/node/hooks/express/socketio.js
|
Called from: src/node/hooks/express/socketio.js
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ var padMessageHandler = require("../handler/PadMessageHandler");
|
||||||
var readOnlyManager = require("./ReadOnlyManager");
|
var readOnlyManager = require("./ReadOnlyManager");
|
||||||
var crypto = require("crypto");
|
var crypto = require("crypto");
|
||||||
var randomString = require("../utils/randomstring");
|
var randomString = require("../utils/randomstring");
|
||||||
|
var hooks = require('ep_etherpad-lite/static/js/pluginfw/hooks');
|
||||||
|
|
||||||
//serialization/deserialization attributes
|
//serialization/deserialization attributes
|
||||||
var attributeBlackList = ["id"];
|
var attributeBlackList = ["id"];
|
||||||
|
@ -86,6 +87,12 @@ Pad.prototype.appendRevision = function appendRevision(aChangeset, author) {
|
||||||
// set the author to pad
|
// set the author to pad
|
||||||
if(author)
|
if(author)
|
||||||
authorManager.addPad(author, this.id);
|
authorManager.addPad(author, this.id);
|
||||||
|
|
||||||
|
if (this.head == 0) {
|
||||||
|
hooks.callAll("padCreate", {'pad':this});
|
||||||
|
} else {
|
||||||
|
hooks.callAll("padUpdate", {'pad':this});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//save all attributes to the database
|
//save all attributes to the database
|
||||||
|
@ -368,6 +375,7 @@ Pad.prototype.init = function init(text, callback) {
|
||||||
_this.appendRevision(firstChangeset, '');
|
_this.appendRevision(firstChangeset, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hooks.callAll("padLoad", {'pad':_this});
|
||||||
callback(null);
|
callback(null);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -467,6 +475,7 @@ Pad.prototype.remove = function remove(callback) {
|
||||||
{
|
{
|
||||||
db.remove("pad:"+padID);
|
db.remove("pad:"+padID);
|
||||||
padManager.unloadPad(padID);
|
padManager.unloadPad(padID);
|
||||||
|
hooks.callAll("padRemove", {'padID':padID});
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
], function(err)
|
], function(err)
|
||||||
|
|
Loading…
Reference in New Issue