Merge branch 'develop' of github.com:Pita/etherpad-lite into feature/frontend-tests

This commit is contained in:
Peter 'Pita' Martischka 2012-10-27 16:32:37 +01:00
commit f59b643aa6
25 changed files with 378 additions and 83 deletions

View file

@ -141,22 +141,6 @@ exports.getAuthor = function (author, callback)
db.get("globalAuthor:" + author, callback);
}
/**
* Returns the Author Name of the author
* @param {String} author The id of the author
* @param {Function} callback callback(err, name)
*/
exports.getAuthorName = function (authorID, callback)
{
db.getSub("globalAuthor:" + author, ["name"], callback);
console.log(authorID);
db.getSub("globalAuthor:" + authorID, ["name"], function(err, authorName){
if(ERR(err, callback)) return;
callback(null, {authorName: authorName});
});
}
/**

View file

@ -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("padCreate", {'pad':this});
} else {
hooks.callAll("padUpdate", {'pad':this});
}
};
//save all attributes to the database
@ -368,6 +375,7 @@ Pad.prototype.init = function init(text, callback) {
_this.appendRevision(firstChangeset, '');
}
hooks.callAll("padLoad", {'pad':_this});
callback(null);
});
};
@ -467,6 +475,7 @@ Pad.prototype.remove = function remove(callback) {
{
db.remove("pad:"+padID);
padManager.unloadPad(padID);
hooks.callAll("padRemove", {'padID':padID});
callback();
}
], function(err)

View file

@ -176,9 +176,11 @@ exports.handleMessage = function(client, message)
// Call handleMessage hook. If a plugin returns null, the message will be dropped. Note that for all messages
// handleMessage will be called, even if the client is not authorized
hooks.aCallAll("handleMessage", { client: client, message: message }, function ( messages ) {
hooks.aCallAll("handleMessage", { client: client, message: message }, function ( err, messages ) {
if(ERR(err, callback)) return;
_.each(messages, function(newMessage){
if ( newmessage === null ) {
if ( newMessage === null ) {
dropMessage = true;
}
});
@ -415,22 +417,34 @@ function handleUserInfoUpdate(client, message)
authorManager.setAuthorName(author, message.data.userInfo.name);
var padId = sessioninfos[client.id].padId;
var infoMsg = {
type: "COLLABROOM",
data: {
// The Client doesn't know about USERINFO_UPDATE, use USER_NEWINFO
type: "USER_NEWINFO",
userInfo: {
userId: author,
name: message.data.userInfo.name,
colorId: message.data.userInfo.colorId,
userAgent: "Anonymous",
ip: "127.0.0.1",
}
}
};
//set a null name, when there is no name set. cause the client wants it null
if(message.data.userInfo.name == null)
if(infoMsg.data.userInfo.name == null)
{
message.data.userInfo.name = null;
infoMsg.data.userInfo.name = null;
}
//The Client don't know about a USERINFO_UPDATE, it can handle only new user_newinfo, so change the message type
message.data.type = "USER_NEWINFO";
//Send the other clients on the pad the update message
for(var i in pad2sessions[padId])
{
if(pad2sessions[padId][i] != client.id)
{
socketio.sockets.sockets[pad2sessions[padId][i]].json.send(message);
socketio.sockets.sockets[pad2sessions[padId][i]].json.send(infoMsg);
}
}
}

View file

@ -37,7 +37,7 @@ exports.ip = "0.0.0.0";
/**
* The Port ep-lite should listen to
*/
exports.port = 9001;
exports.port = process.env.PORT || 9001;
/*
* The Type of the database
*/

View file

@ -48,7 +48,7 @@ CachingMiddleware.prototype = new function () {
var old_res = {};
var supportsGzip =
req.header('Accept-Encoding', '').indexOf('gzip') != -1;
(req.get('Accept-Encoding') || '').indexOf('gzip') != -1;
var path = require('url').parse(req.url).path;
var cacheKey = (new Buffer(path)).toString('base64').replace(/[\/\+=]/g, '');