mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-24 01:16:15 -04:00
Merge branch 'develop' of git://github.com/Pita/etherpad-lite
This commit is contained in:
commit
251ab842dd
6 changed files with 76 additions and 16 deletions
|
@ -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
|
||||||
|
|
||||||
|
|
|
@ -141,22 +141,6 @@ exports.getAuthor = function (author, callback)
|
||||||
db.get("globalAuthor:" + 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});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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)
|
||||||
|
|
|
@ -359,6 +359,14 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad)
|
||||||
var userInfo = msg.userInfo;
|
var userInfo = msg.userInfo;
|
||||||
var id = userInfo.userId;
|
var id = userInfo.userId;
|
||||||
|
|
||||||
|
// Avoid a race condition when setting colors. If our color was set by a
|
||||||
|
// query param, ignore our own "new user" message's color value.
|
||||||
|
if (id === initialUserInfo.userId && initialUserInfo.globalUserColor)
|
||||||
|
{
|
||||||
|
msg.userInfo.colorId = initialUserInfo.globalUserColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (userSet[id])
|
if (userSet[id])
|
||||||
{
|
{
|
||||||
userSet[id] = userInfo;
|
userSet[id] = userInfo;
|
||||||
|
|
|
@ -24,6 +24,13 @@
|
||||||
|
|
||||||
var colorutils = {};
|
var colorutils = {};
|
||||||
|
|
||||||
|
// Check that a given value is a css hex color value, e.g.
|
||||||
|
// "#ffffff" or "#fff"
|
||||||
|
colorutils.isCssHex = function(cssColor)
|
||||||
|
{
|
||||||
|
return /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.test(cssColor);
|
||||||
|
}
|
||||||
|
|
||||||
// "#ffffff" or "#fff" or "ffffff" or "fff" to [1.0, 1.0, 1.0]
|
// "#ffffff" or "#fff" or "ffffff" or "fff" to [1.0, 1.0, 1.0]
|
||||||
colorutils.css2triple = function(cssColor)
|
colorutils.css2triple = function(cssColor)
|
||||||
{
|
{
|
||||||
|
|
|
@ -43,6 +43,7 @@ var padmodals = require('./pad_modals').padmodals;
|
||||||
var padsavedrevs = require('./pad_savedrevs');
|
var padsavedrevs = require('./pad_savedrevs');
|
||||||
var paduserlist = require('./pad_userlist').paduserlist;
|
var paduserlist = require('./pad_userlist').paduserlist;
|
||||||
var padutils = require('./pad_utils').padutils;
|
var padutils = require('./pad_utils').padutils;
|
||||||
|
var colorutils = require('./colorutils').colorutils;
|
||||||
|
|
||||||
var createCookie = require('./pad_utils').createCookie;
|
var createCookie = require('./pad_utils').createCookie;
|
||||||
var readCookie = require('./pad_utils').readCookie;
|
var readCookie = require('./pad_utils').readCookie;
|
||||||
|
@ -114,6 +115,7 @@ function getParams()
|
||||||
var showControls = params["showControls"];
|
var showControls = params["showControls"];
|
||||||
var showChat = params["showChat"];
|
var showChat = params["showChat"];
|
||||||
var userName = params["userName"];
|
var userName = params["userName"];
|
||||||
|
var userColor = params["userColor"];
|
||||||
var showLineNumbers = params["showLineNumbers"];
|
var showLineNumbers = params["showLineNumbers"];
|
||||||
var useMonospaceFont = params["useMonospaceFont"];
|
var useMonospaceFont = params["useMonospaceFont"];
|
||||||
var IsnoColors = params["noColors"];
|
var IsnoColors = params["noColors"];
|
||||||
|
@ -162,6 +164,11 @@ function getParams()
|
||||||
// If the username is set as a parameter we should set a global value that we can call once we have initiated the pad.
|
// If the username is set as a parameter we should set a global value that we can call once we have initiated the pad.
|
||||||
settings.globalUserName = decodeURIComponent(userName);
|
settings.globalUserName = decodeURIComponent(userName);
|
||||||
}
|
}
|
||||||
|
if(userColor)
|
||||||
|
// If the userColor is set as a parameter, set a global value to use once we have initiated the pad.
|
||||||
|
{
|
||||||
|
settings.globalUserColor = decodeURIComponent(userColor);
|
||||||
|
}
|
||||||
if(rtl)
|
if(rtl)
|
||||||
{
|
{
|
||||||
if(rtl == "true")
|
if(rtl == "true")
|
||||||
|
@ -363,6 +370,14 @@ function handshake()
|
||||||
pad.myUserInfo.name = settings.globalUserName;
|
pad.myUserInfo.name = settings.globalUserName;
|
||||||
$('#myusernameedit').attr({"value":settings.globalUserName}); // Updates the current users UI
|
$('#myusernameedit').attr({"value":settings.globalUserName}); // Updates the current users UI
|
||||||
}
|
}
|
||||||
|
if (settings.globalUserColor !== false && colorutils.isCssHex(settings.globalUserColor))
|
||||||
|
{
|
||||||
|
|
||||||
|
// Add a 'globalUserColor' property to myUserInfo, so collabClient knows we have a query parameter.
|
||||||
|
pad.myUserInfo.globalUserColor = settings.globalUserColor;
|
||||||
|
pad.notifyChangeColor(settings.globalUserColor); // Updates pad.myUserInfo.colorId
|
||||||
|
paduserlist.setMyUserInfo(pad.myUserInfo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//This handles every Message after the clientVars
|
//This handles every Message after the clientVars
|
||||||
else
|
else
|
||||||
|
@ -1029,6 +1044,7 @@ var settings = {
|
||||||
, noColors: false
|
, noColors: false
|
||||||
, useMonospaceFontGlobal: false
|
, useMonospaceFontGlobal: false
|
||||||
, globalUserName: false
|
, globalUserName: false
|
||||||
|
, globalUserColor: false
|
||||||
, rtlIsTrue: false
|
, rtlIsTrue: false
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue