mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-02-01 03:12:42 +01:00
Merge branch 'develop' into timeslider_authors
This commit is contained in:
commit
35c0a38a01
13 changed files with 128 additions and 149 deletions
|
@ -6,7 +6,7 @@ var mysql = require("mysql");
|
|||
var async = require("async");
|
||||
var Changeset = require("ep_etherpad-lite/static/js/Changeset");
|
||||
var randomString = require('ep_etherpad-lite/static/js/pad_utils').randomString;
|
||||
var AttributePoolFactory = require("ep_etherpad-lite/static/js/AttributePoolFactory");
|
||||
var AttributePool = require("ep_etherpad-lite/static/js/AttributePool");
|
||||
|
||||
var settingsFile = process.argv[2];
|
||||
var sqlOutputFile = process.argv[3];
|
||||
|
@ -384,7 +384,7 @@ function convertPad(padId, callback)
|
|||
}
|
||||
|
||||
//generate the latest atext
|
||||
var fullAPool = AttributePoolFactory.createAttributePool().fromJsonable(apool);
|
||||
var fullAPool = (new AttributePool()).fromJsonable(apool);
|
||||
var keyRev = Math.floor(padmeta.head / padmeta.keyRevInterval) * padmeta.keyRevInterval;
|
||||
var atext = changesetsMeta[keyRev].atext;
|
||||
var curRev = keyRev;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
var ERR = require("async-stacktrace");
|
||||
var Changeset = require("ep_etherpad-lite/static/js/Changeset");
|
||||
var AttributePoolFactory = require("ep_etherpad-lite/static/js/AttributePoolFactory");
|
||||
var AttributePool = require("ep_etherpad-lite/static/js/AttributePool");
|
||||
var randomString = require('ep_etherpad-lite/static/js/pad_utils').randomString;
|
||||
var db = require("./DB").db;
|
||||
var async = require("async");
|
||||
|
@ -28,7 +28,7 @@ exports.cleanText = function (txt) {
|
|||
var Pad = function Pad(id) {
|
||||
|
||||
this.atext = Changeset.makeAText("\n");
|
||||
this.pool = AttributePoolFactory.createAttributePool();
|
||||
this.pool = new AttributePool();
|
||||
this.head = -1;
|
||||
this.chatHead = -1;
|
||||
this.publicStatus = false;
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
var Changeset = require("ep_etherpad-lite/static/js/Changeset");
|
||||
var AttributePoolFactory = require("ep_etherpad-lite/static/js/AttributePoolFactory");
|
||||
var AttributePool = require("ep_etherpad-lite/static/js/AttributePool");
|
||||
|
||||
function random() {
|
||||
this.nextInt = function (maxValue) {
|
||||
|
@ -227,7 +227,7 @@ function runTests() {
|
|||
return attribs; // it's already an attrib pool
|
||||
} else {
|
||||
// assume it's an array of attrib strings to be split and added
|
||||
var p = AttributePoolFactory.createAttributePool();
|
||||
var p = new AttributePool();
|
||||
attribs.forEach(function (kv) {
|
||||
p.putAttrib(kv.split(','));
|
||||
});
|
||||
|
@ -325,7 +325,7 @@ function runTests() {
|
|||
runMutateAttributionTest(4, ['foo,bar', 'line,1', 'line,2', 'line,3', 'line,4', 'line,5'], "Z:5>1|2=2+1$x", ["?*1|1+1", "?*2|1+1", "*3|1+1", "?*4|1+1", "?*5|1+1"], ["?*1|1+1", "?*2|1+1", "+1*3|1+1", "?*4|1+1", "?*5|1+1"]);
|
||||
|
||||
var testPoolWithChars = (function () {
|
||||
var p = AttributePoolFactory.createAttributePool();
|
||||
var p = new AttributePool();
|
||||
p.putAttrib(['char', 'newline']);
|
||||
for (var i = 1; i < 36; i++) {
|
||||
p.putAttrib(['char', Changeset.numToString(i)]);
|
||||
|
@ -560,7 +560,7 @@ function runTests() {
|
|||
var rand = new random();
|
||||
print("> testCompose#" + randomSeed);
|
||||
|
||||
var p = AttributePoolFactory.createAttributePool();
|
||||
var p = new AttributePool();
|
||||
|
||||
var startText = randomMultiline(10, 20, rand) + '\n';
|
||||
|
||||
|
@ -594,7 +594,7 @@ function runTests() {
|
|||
|
||||
(function simpleComposeAttributesTest() {
|
||||
print("> simpleComposeAttributesTest");
|
||||
var p = AttributePoolFactory.createAttributePool();
|
||||
var p = new AttributePool();
|
||||
p.putAttrib(['bold', '']);
|
||||
p.putAttrib(['bold', 'true']);
|
||||
var cs1 = Changeset.checkRep("Z:2>1*1+1*1=1$x");
|
||||
|
@ -604,7 +604,7 @@ function runTests() {
|
|||
})();
|
||||
|
||||
(function followAttributesTest() {
|
||||
var p = AttributePoolFactory.createAttributePool();
|
||||
var p = new AttributePool();
|
||||
p.putAttrib(['x', '']);
|
||||
p.putAttrib(['x', 'abc']);
|
||||
p.putAttrib(['x', 'def']);
|
||||
|
@ -633,7 +633,7 @@ function runTests() {
|
|||
var rand = new random();
|
||||
print("> testFollow#" + randomSeed);
|
||||
|
||||
var p = AttributePoolFactory.createAttributePool();
|
||||
var p = new AttributePool();
|
||||
|
||||
var startText = randomMultiline(10, 20, rand) + '\n';
|
||||
|
||||
|
@ -682,8 +682,8 @@ function runTests() {
|
|||
(function testMoveOpsToNewPool() {
|
||||
print("> testMoveOpsToNewPool");
|
||||
|
||||
var pool1 = AttributePoolFactory.createAttributePool();
|
||||
var pool2 = AttributePoolFactory.createAttributePool();
|
||||
var pool1 = new AttributePool();
|
||||
var pool2 = new AttributePool();
|
||||
|
||||
pool1.putAttrib(['baz', 'qux']);
|
||||
pool1.putAttrib(['foo', 'bar']);
|
||||
|
@ -738,7 +738,7 @@ function runTests() {
|
|||
(function testOpAttributeValue() {
|
||||
print("> testOpAttributeValue");
|
||||
|
||||
var p = AttributePoolFactory.createAttributePool();
|
||||
var p = new AttributePool();
|
||||
p.putAttrib(['name', 'david']);
|
||||
p.putAttrib(['color', 'green']);
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ var ERR = require("async-stacktrace");
|
|||
var async = require("async");
|
||||
var padManager = require("../db/PadManager");
|
||||
var Changeset = require("ep_etherpad-lite/static/js/Changeset");
|
||||
var AttributePoolFactory = require("ep_etherpad-lite/static/js/AttributePoolFactory");
|
||||
var AttributePool = require("ep_etherpad-lite/static/js/AttributePool");
|
||||
var authorManager = require("../db/AuthorManager");
|
||||
var readOnlyManager = require("../db/ReadOnlyManager");
|
||||
var settings = require('../utils/Settings');
|
||||
|
@ -372,7 +372,7 @@ function handleUserChanges(client, message)
|
|||
|
||||
//get all Vars we need
|
||||
var baseRev = message.data.baseRev;
|
||||
var wireApool = (AttributePoolFactory.createAttributePool()).fromJsonable(message.data.apool);
|
||||
var wireApool = (new AttributePool()).fromJsonable(message.data.apool);
|
||||
var changeset = message.data.changeset;
|
||||
|
||||
var r, apool, pad;
|
||||
|
|
|
@ -23,7 +23,7 @@ var ERR = require("async-stacktrace");
|
|||
var async = require("async");
|
||||
var padManager = require("../db/PadManager");
|
||||
var Changeset = require("ep_etherpad-lite/static/js/Changeset");
|
||||
var AttributePoolFactory = require("ep_etherpad-lite/static/js/AttributePoolFactory");
|
||||
var AttributePool = require("ep_etherpad-lite/static/js/AttributePool");
|
||||
var settings = require('../utils/Settings');
|
||||
var authorManager = require("../db/AuthorManager");
|
||||
var log4js = require('log4js');
|
||||
|
@ -265,7 +265,7 @@ function getChangesetInfo(padId, startNum, endNum, granularity, callback)
|
|||
var forwardsChangesets = [];
|
||||
var backwardsChangesets = [];
|
||||
var timeDeltas = [];
|
||||
var apool = AttributePoolFactory.createAttributePool();
|
||||
var apool = new AttributePool();
|
||||
var pad;
|
||||
var composedChangesets = {};
|
||||
var revisionDate = [];
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
, "pad_modals.js"
|
||||
, "pad_savedrevs.js"
|
||||
, "pad_impexp.js"
|
||||
, "AttributePoolFactory.js"
|
||||
, "AttributePool.js"
|
||||
, "Changeset.js"
|
||||
, "domline.js"
|
||||
, "linestylefilter.js"
|
||||
|
@ -55,7 +55,7 @@
|
|||
"ace2_common.js"
|
||||
, "underscore.js"
|
||||
, "rjquery.js"
|
||||
, "AttributePoolFactory.js"
|
||||
, "AttributePool.js"
|
||||
, "Changeset.js"
|
||||
, "security.js"
|
||||
, "skiplist.js"
|
||||
|
|
90
src/static/js/AttributePool.js
Normal file
90
src/static/js/AttributePool.js
Normal file
|
@ -0,0 +1,90 @@
|
|||
/**
|
||||
* This code represents the Attribute Pool Object of the original Etherpad.
|
||||
* 90% of the code is still like in the original Etherpad
|
||||
* Look at https://github.com/ether/pad/blob/master/infrastructure/ace/www/easysync2.js
|
||||
* You can find a explanation what a attribute pool is here:
|
||||
* https://github.com/Pita/etherpad-lite/blob/master/doc/easysync/easysync-notes.txt
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright 2009 Google Inc., 2011 Peter 'Pita' Martischka (Primary Technology Ltd)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS-IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
var AttributePool = function () {
|
||||
this.numToAttrib = {}; // e.g. {0: ['foo','bar']}
|
||||
this.attribToNum = {}; // e.g. {'foo,bar': 0}
|
||||
this.nextNum = 0;
|
||||
};
|
||||
|
||||
AttributePool.prototype.putAttrib = function (attrib, dontAddIfAbsent) {
|
||||
var str = String(attrib);
|
||||
if (str in this.attribToNum) {
|
||||
return this.attribToNum[str];
|
||||
}
|
||||
if (dontAddIfAbsent) {
|
||||
return -1;
|
||||
}
|
||||
var num = this.nextNum++;
|
||||
this.attribToNum[str] = num;
|
||||
this.numToAttrib[num] = [String(attrib[0] || ''), String(attrib[1] || '')];
|
||||
return num;
|
||||
};
|
||||
|
||||
AttributePool.prototype.getAttrib = function (num) {
|
||||
var pair = this.numToAttrib[num];
|
||||
if (!pair) {
|
||||
return pair;
|
||||
}
|
||||
return [pair[0], pair[1]]; // return a mutable copy
|
||||
};
|
||||
|
||||
AttributePool.prototype.getAttribKey = function (num) {
|
||||
var pair = this.numToAttrib[num];
|
||||
if (!pair) return '';
|
||||
return pair[0];
|
||||
};
|
||||
|
||||
AttributePool.prototype.getAttribValue = function (num) {
|
||||
var pair = this.numToAttrib[num];
|
||||
if (!pair) return '';
|
||||
return pair[1];
|
||||
};
|
||||
|
||||
AttributePool.prototype.eachAttrib = function (func) {
|
||||
for (var n in this.numToAttrib) {
|
||||
var pair = this.numToAttrib[n];
|
||||
func(pair[0], pair[1]);
|
||||
}
|
||||
};
|
||||
|
||||
AttributePool.prototype.toJsonable = function () {
|
||||
return {
|
||||
numToAttrib: this.numToAttrib,
|
||||
nextNum: this.nextNum
|
||||
};
|
||||
};
|
||||
|
||||
AttributePool.prototype.fromJsonable = function (obj) {
|
||||
this.numToAttrib = obj.numToAttrib;
|
||||
this.nextNum = obj.nextNum;
|
||||
this.attribToNum = {};
|
||||
for (var n in this.numToAttrib) {
|
||||
this.attribToNum[String(this.numToAttrib[n])] = Number(n);
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
|
||||
module.exports = AttributePool;
|
|
@ -1,90 +0,0 @@
|
|||
/**
|
||||
* This code represents the Attribute Pool Object of the original Etherpad.
|
||||
* 90% of the code is still like in the original Etherpad
|
||||
* Look at https://github.com/ether/pad/blob/master/infrastructure/ace/www/easysync2.js
|
||||
* You can find a explanation what a attribute pool is here:
|
||||
* https://github.com/Pita/etherpad-lite/blob/master/doc/easysync/easysync-notes.txt
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright 2009 Google Inc., 2011 Peter 'Pita' Martischka (Primary Technology Ltd)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS-IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
exports.createAttributePool = function () {
|
||||
var p = {};
|
||||
p.numToAttrib = {}; // e.g. {0: ['foo','bar']}
|
||||
p.attribToNum = {}; // e.g. {'foo,bar': 0}
|
||||
p.nextNum = 0;
|
||||
|
||||
p.putAttrib = function (attrib, dontAddIfAbsent) {
|
||||
var str = String(attrib);
|
||||
if (str in p.attribToNum) {
|
||||
return p.attribToNum[str];
|
||||
}
|
||||
if (dontAddIfAbsent) {
|
||||
return -1;
|
||||
}
|
||||
var num = p.nextNum++;
|
||||
p.attribToNum[str] = num;
|
||||
p.numToAttrib[num] = [String(attrib[0] || ''), String(attrib[1] || '')];
|
||||
return num;
|
||||
};
|
||||
|
||||
p.getAttrib = function (num) {
|
||||
var pair = p.numToAttrib[num];
|
||||
if (!pair) {
|
||||
return pair;
|
||||
}
|
||||
return [pair[0], pair[1]]; // return a mutable copy
|
||||
};
|
||||
|
||||
p.getAttribKey = function (num) {
|
||||
var pair = p.numToAttrib[num];
|
||||
if (!pair) return '';
|
||||
return pair[0];
|
||||
};
|
||||
|
||||
p.getAttribValue = function (num) {
|
||||
var pair = p.numToAttrib[num];
|
||||
if (!pair) return '';
|
||||
return pair[1];
|
||||
};
|
||||
|
||||
p.eachAttrib = function (func) {
|
||||
for (var n in p.numToAttrib) {
|
||||
var pair = p.numToAttrib[n];
|
||||
func(pair[0], pair[1]);
|
||||
}
|
||||
};
|
||||
|
||||
p.toJsonable = function () {
|
||||
return {
|
||||
numToAttrib: p.numToAttrib,
|
||||
nextNum: p.nextNum
|
||||
};
|
||||
};
|
||||
|
||||
p.fromJsonable = function (obj) {
|
||||
p.numToAttrib = obj.numToAttrib;
|
||||
p.nextNum = obj.nextNum;
|
||||
p.attribToNum = {};
|
||||
for (var n in p.numToAttrib) {
|
||||
p.attribToNum[String(p.numToAttrib[n])] = Number(n);
|
||||
}
|
||||
return p;
|
||||
};
|
||||
|
||||
return p;
|
||||
}
|
|
@ -25,7 +25,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
var AttributePoolFactory = require("./AttributePoolFactory");
|
||||
var AttributePool = require("./AttributePool");
|
||||
|
||||
var _opt = null;
|
||||
|
||||
|
@ -1731,7 +1731,7 @@ exports.appendATextToAssembler = function (atext, assem) {
|
|||
* @param pool {AtributePool}
|
||||
*/
|
||||
exports.prepareForWire = function (cs, pool) {
|
||||
var newPool = AttributePoolFactory.createAttributePool();;
|
||||
var newPool = new AttributePool();
|
||||
var newCs = exports.moveOpsToNewPool(cs, pool, newPool);
|
||||
return {
|
||||
translated: newCs,
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
*/
|
||||
var editor, _, $, jQuery, plugins, Ace2Common;
|
||||
|
||||
|
||||
Ace2Common = require('./ace2_common');
|
||||
|
||||
plugins = require('ep_etherpad-lite/static/js/pluginfw/plugins');
|
||||
|
@ -44,10 +43,10 @@ function Ace2Inner(){
|
|||
var makeContentCollector = require('./contentcollector').makeContentCollector;
|
||||
var makeCSSManager = require('./cssmanager').makeCSSManager;
|
||||
var domline = require('./domline').domline;
|
||||
var AttribPool = require('./AttributePoolFactory').createAttributePool;
|
||||
var AttribPool = require('./AttributePool');
|
||||
var Changeset = require('./Changeset');
|
||||
var linestylefilter = require('./linestylefilter').linestylefilter;
|
||||
var newSkipList = require('./skiplist').newSkipList;
|
||||
var SkipList = require('./skiplist');
|
||||
var undoModule = require('./undomodule').undoModule;
|
||||
var makeVirtualLineView = require('./virtual_lines').makeVirtualLineView;
|
||||
|
||||
|
@ -93,7 +92,7 @@ function Ace2Inner(){
|
|||
// native IE selections have that behavior (which we try not to interfere with).
|
||||
// Must be false if selection is collapsed!
|
||||
var rep = {
|
||||
lines: newSkipList(),
|
||||
lines: new SkipList(),
|
||||
selStart: null,
|
||||
selEnd: null,
|
||||
selFocusAtStart: false,
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
var makeCSSManager = require('./cssmanager').makeCSSManager;
|
||||
var domline = require('./domline').domline;
|
||||
var AttribPool = require('./AttributePoolFactory').createAttributePool;
|
||||
var AttribPool = require('./AttributePool');
|
||||
var Changeset = require('./Changeset');
|
||||
var linestylefilter = require('./linestylefilter').linestylefilter;
|
||||
var colorutils = require('./colorutils').colorutils;
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
var AttribPool = require('./AttributePoolFactory').createAttributePool;
|
||||
var AttributePool = require('./AttributePool');
|
||||
var Changeset = require('./Changeset');
|
||||
|
||||
function makeChangesetTracker(scheduler, apool, aceCallbacksProvider)
|
||||
|
@ -83,7 +83,7 @@ function makeChangesetTracker(scheduler, apool, aceCallbacksProvider)
|
|||
baseAText = Changeset.cloneAText(atext);
|
||||
if (apoolJsonObj)
|
||||
{
|
||||
var wireApool = (new AttribPool()).fromJsonable(apoolJsonObj);
|
||||
var wireApool = (new AttributePool()).fromJsonable(apoolJsonObj);
|
||||
baseAText.attribs = Changeset.moveOpsToNewPool(baseAText.attribs, wireApool, apool);
|
||||
}
|
||||
submittedChangeset = null;
|
||||
|
@ -117,7 +117,7 @@ function makeChangesetTracker(scheduler, apool, aceCallbacksProvider)
|
|||
|
||||
if (apoolJsonObj)
|
||||
{
|
||||
var wireApool = (new AttribPool()).fromJsonable(apoolJsonObj);
|
||||
var wireApool = (new AttributePool()).fromJsonable(apoolJsonObj);
|
||||
c = Changeset.moveOpsToNewPool(c, wireApool, apool);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,11 +20,12 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
var Ace2Common = require('./ace2_common'),
|
||||
_ = require('./underscore');
|
||||
|
||||
var noop = require('./ace2_common').noop;
|
||||
var noop = Ace2Common.noop;
|
||||
|
||||
|
||||
function newSkipList()
|
||||
function SkipList()
|
||||
{
|
||||
var PROFILER = window.PROFILER;
|
||||
if (!PROFILER)
|
||||
|
@ -284,27 +285,6 @@ function newSkipList()
|
|||
}
|
||||
return dist;
|
||||
}
|
||||
/*function _debugToString() {
|
||||
var array = [start];
|
||||
while (array[array.length-1] !== end) {
|
||||
array[array.length] = array[array.length-1].downPtrs[0];
|
||||
}
|
||||
function getIndex(node) {
|
||||
if (!node) return null;
|
||||
for(var i=0;i<array.length;i++) {
|
||||
if (array[i] === node)
|
||||
return i-1;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
var processedArray = map(array, function(node) {
|
||||
var x = {key:node.key, levels: node.levels, downSkips: node.downSkips,
|
||||
upPtrs: map(node.upPtrs, getIndex), downPtrs: map(node.downPtrs, getIndex),
|
||||
downSkipWidths: node.downSkipWidths};
|
||||
return x;
|
||||
});
|
||||
return map(processedArray, function (x) { return x.toSource(); }).join("\n");
|
||||
}*/
|
||||
|
||||
function _getNodeByKey(key)
|
||||
{
|
||||
|
@ -345,8 +325,9 @@ function newSkipList()
|
|||
/*
|
||||
The skip-list contains "entries", JavaScript objects that each must have a unique "key" property
|
||||
that is a string.
|
||||
*/
|
||||
var self = {
|
||||
*/
|
||||
var self = this;
|
||||
_.extend(this, {
|
||||
length: function()
|
||||
{
|
||||
return numNodes;
|
||||
|
@ -482,8 +463,7 @@ that is a string.
|
|||
{
|
||||
return start.levels;
|
||||
}
|
||||
}
|
||||
return self;
|
||||
});
|
||||
}
|
||||
|
||||
exports.newSkipList = newSkipList;
|
||||
module.exports = SkipList;
|
||||
|
|
Loading…
Reference in a new issue