Merge branch 'soon' into staging

This commit is contained in:
yflory
2020-03-25 16:33:47 +01:00
21 changed files with 95 additions and 42 deletions

View File

@@ -547,8 +547,9 @@ const deferResponse = function (Env, channel, cb) {
}; };
*/ */
// FIXME this will be removed from the client
Pinning.isChannelPinned = function (Env, channel, cb) { Pinning.isChannelPinned = function (Env, channel, cb) {
return void cb(void 0, true); // XXX return void cb(void 0, true);
/* /*
// if the pins are fully loaded then you can answer yes/no definitively // if the pins are fully loaded then you can answer yes/no definitively
if (Env.pinsLoaded) { if (Env.pinsLoaded) {

View File

@@ -15,18 +15,15 @@ const init = function (config, cb) {
return void cb('E_INVALID_CONFIG'); return void cb('E_INVALID_CONFIG');
} }
Store.create(config, function (_store) { Store.create(config, function (err, _store) {
if (err) { return void cb(err); }
store = _store; store = _store;
cb(); cb();
}); });
}; };
const tryParse = function (Env, str) { const tryParse = function (Env, str) {
try { try { return JSON.parse(str); } catch (err) { }
return JSON.parse(str);
} catch (err) {
// XXX
}
}; };
/* computeIndex /* computeIndex

View File

@@ -215,12 +215,14 @@ module.exports.create = function (config, cb) {
// create a pin store // create a pin store
Store.create({ Store.create({
filePath: pinPath, filePath: pinPath,
}, w(function (s) { }, w(function (err, s) {
if (err) { throw err; }
Env.pinStore = s; Env.pinStore = s;
})); }));
// create a channel store // create a channel store
Store.create(config, w(function (_store) { Store.create(config, w(function (err, _store) {
if (err) { throw err; }
config.store = _store; config.store = _store;
Env.msgStore = _store; // API used by rpc Env.msgStore = _store; // API used by rpc
Env.store = _store; // API used by historyKeeper Env.store = _store; // API used by historyKeeper

View File

@@ -835,7 +835,14 @@ HK.initializeIndexWorkers = function (Env, config, _cb) {
worker.on('message', function (res) { worker.on('message', function (res) {
if (!res || !res.txid) { return; } if (!res || !res.txid) { return; }
//console.log(res); //console.log(res);
response.handle(res.txid, [res.error, res.value]); try {
response.handle(res.txid, [res.error, res.value]);
} catch (err) {
Env.Log.error("INDEX_WORKER", {
error: err,
response: res,
});
}
}); });
worker.on('exit', function () { worker.on('exit', function () {
var idx = workers.indexOf(worker); var idx = workers.indexOf(worker);

View File

@@ -38,7 +38,7 @@ if (!isPositiveNumber(config.defaultStorageLimit)) {
// premiumUploadSize is worthless if it isn't a valid positive number // premiumUploadSize is worthless if it isn't a valid positive number
// or if it's less than the default upload size // or if it's less than the default upload size
if (!isPositiveNumber(config.premiumUploadSize) || config.premiumUploadSize < config.defaultStorageLimit) { if (!isPositiveNumber(config.premiumUploadSize) || config.premiumUploadSize < config.maxUploadSize) {
delete config.premiumUploadSize; delete config.premiumUploadSize;
} }

View File

@@ -96,12 +96,17 @@ Logger.create = function (config, cb) {
if (!config.logPath) { if (!config.logPath) {
console.log("No logPath configured. Logging to file disabled"); console.log("No logPath configured. Logging to file disabled");
return void cb(Object.freeze(createMethods(ctx))); var logger = createMethods(ctx);
logger.shutdown = noop;
return void cb(Object.freeze(logger));
} }
Store.create({ Store.create({
filePath: config.logPath, filePath: config.logPath,
}, function (store) { }, function (err, store) {
if (err) {
throw err;
}
ctx.store = store; ctx.store = store;
var logger = createMethods(ctx); var logger = createMethods(ctx);
logger.shutdown = function () { logger.shutdown = function () {

View File

@@ -17,7 +17,7 @@ const UNAUTHENTICATED_CALLS = {
GET_FILE_SIZE: Pinning.getFileSize, GET_FILE_SIZE: Pinning.getFileSize,
GET_MULTIPLE_FILE_SIZE: Pinning.getMultipleFileSize, GET_MULTIPLE_FILE_SIZE: Pinning.getMultipleFileSize,
GET_DELETED_PADS: Pinning.getDeletedPads, GET_DELETED_PADS: Pinning.getDeletedPads,
IS_CHANNEL_PINNED: Pinning.isChannelPinned, IS_CHANNEL_PINNED: Pinning.isChannelPinned, // FIXME drop this RPC
IS_NEW_CHANNEL: Channel.isNewChannel, IS_NEW_CHANNEL: Channel.isNewChannel,
WRITE_PRIVATE_MESSAGE: Channel.writePrivateMessage, WRITE_PRIVATE_MESSAGE: Channel.writePrivateMessage,
GET_METADATA: Metadata.getMetadata, GET_METADATA: Metadata.getMetadata,
@@ -198,8 +198,6 @@ RPC.create = function (Env, cb) {
updateLimitDaily(); updateLimitDaily();
Env.intervals.dailyLimitUpdate = setInterval(updateLimitDaily, 24*3600*1000); Env.intervals.dailyLimitUpdate = setInterval(updateLimitDaily, 24*3600*1000);
//Pinning.loadChannelPins(Env); // XXX
// expire old sessions once per minute // expire old sessions once per minute
Env.intervals.sessionExpirationInterval = setInterval(function () { Env.intervals.sessionExpirationInterval = setInterval(function () {
Core.expireSessions(Sessions); Core.expireSessions(Sessions);

View File

@@ -951,7 +951,9 @@ var trimChannel = function (env, channelName, hash, _cb) {
}); });
}; };
module.exports.create = function (conf, cb) { module.exports.create = function (conf, _cb) {
var cb = Util.once(Util.mkAsync(_cb));
var env = { var env = {
root: conf.filePath || './datastore', root: conf.filePath || './datastore',
archiveRoot: conf.archivePath || './data/archive', archiveRoot: conf.archivePath || './data/archive',
@@ -984,18 +986,19 @@ module.exports.create = function (conf, cb) {
// make sure the store's directory exists // make sure the store's directory exists
Fse.mkdirp(env.root, PERMISSIVE, w(function (err) { Fse.mkdirp(env.root, PERMISSIVE, w(function (err) {
if (err && err.code !== 'EEXIST') { if (err && err.code !== 'EEXIST') {
throw err; // XXX w.abort();
return void cb(err);
} }
})); }));
// make sure the cold storage directory exists // make sure the cold storage directory exists
Fse.mkdirp(env.archiveRoot, PERMISSIVE, w(function (err) { Fse.mkdirp(env.archiveRoot, PERMISSIVE, w(function (err) {
if (err && err.code !== 'EEXIST') { if (err && err.code !== 'EEXIST') {
throw err; // XXX w.abort();
return void cb(err);
} }
})); }));
}).nThen(function () { }).nThen(function () {
// XXX leave a place for an error cb(void 0, {
cb({
// OLDER METHODS // OLDER METHODS
// write a new message to a log // write a new message to a log
message: function (channelName, content, cb) { message: function (channelName, content, cb) {

6
package-lock.json generated
View File

@@ -190,9 +190,9 @@
} }
}, },
"chainpad-server": { "chainpad-server": {
"version": "4.0.7", "version": "4.0.8",
"resolved": "https://registry.npmjs.org/chainpad-server/-/chainpad-server-4.0.7.tgz", "resolved": "https://registry.npmjs.org/chainpad-server/-/chainpad-server-4.0.8.tgz",
"integrity": "sha512-79BTtbFI/nP3HCzPcth8VyeGPYZXGxQRJ8Vm5gE1/hIXWP5ktqBVyabiTiJwsA0tXCAznSa+jnY1DmOLcvCKvA==", "integrity": "sha512-QlmomAMQN4msdYnRqGEjL12FAeOPIJ5yoxIzROohWt/31SwF1UlyV+zFp1M1dhtV8PoS7JXvLyBBLCEEVN73Cg==",
"requires": { "requires": {
"nthen": "0.1.8", "nthen": "0.1.8",
"pull-stream": "^3.6.9", "pull-stream": "^3.6.9",

View File

@@ -13,7 +13,7 @@
}, },
"dependencies": { "dependencies": {
"chainpad-crypto": "^0.2.2", "chainpad-crypto": "^0.2.2",
"chainpad-server": "^4.0.7", "chainpad-server": "^4.0.8",
"express": "~4.16.0", "express": "~4.16.0",
"fs-extra": "^7.0.0", "fs-extra": "^7.0.0",
"get-folder-size": "^2.0.1", "get-folder-size": "^2.0.1",

View File

@@ -8,7 +8,11 @@ var Log;
nThen(function (w) { nThen(function (w) {
// load the store which will be used for iterating over channels // load the store which will be used for iterating over channels
// and performing operations like archival and deletion // and performing operations like archival and deletion
Store.create(config, w(function (_) { Store.create(config, w(function (err, _) {
if (err) {
w.abort();
throw err;
}
store = _; store = _;
})); }));

View File

@@ -34,7 +34,11 @@ var msSinceStart = function () {
nThen(function (w) { nThen(function (w) {
// load the store which will be used for iterating over channels // load the store which will be used for iterating over channels
// and performing operations like archival and deletion // and performing operations like archival and deletion
Store.create(config, w(function (_) { Store.create(config, w(function (err, _) {
if (err) {
w.abort();
throw err;
}
store = _; store = _;
})); // load the list of pinned files so you know which files })); // load the list of pinned files so you know which files
// should not be archived or deleted // should not be archived or deleted

View File

@@ -8,7 +8,8 @@ var Log;
nThen(function (w) { nThen(function (w) {
// load the store which will be used for iterating over channels // load the store which will be used for iterating over channels
// and performing operations like archival and deletion // and performing operations like archival and deletion
Store.create(config, w(function (_) { Store.create(config, w(function (err, _) {
if (err) { throw err; }
store = _; store = _;
})); }));

View File

@@ -66,7 +66,7 @@ define([
}), { }), {
network: network network: network
}); });
}).nThen(function (waitFor) { }).nThen(function () {
var origin = ApiConfig.fileHost || window.location.origin; var origin = ApiConfig.fileHost || window.location.origin;
// Get contacts and extract their avatar channel and key // Get contacts and extract their avatar channel and key
var getData = function (obj, href) { var getData = function (obj, href) {

View File

@@ -15913,7 +15913,7 @@ CParagraphContentWithContentBase.prototype.protected_GetRangesCount=function(Lin
CParagraphContentWithContentBase.prototype.protected_AddRange=function(LineIndex,RangeIndex){if(this.Lines[0]>=LineIndex+1){var RangeOffset=this.protected_GetRangeOffset(LineIndex,0)+RangeIndex*2;this.Lines.splice(RangeOffset,this.Lines.length-RangeOffset);if(this.Lines[0]!==LineIndex+1&&0===RangeIndex)this.Lines.splice(LineIndex+1,this.Lines[0]-LineIndex);else if(this.Lines[0]!==LineIndex+1&&0!==RangeIndex){this.Lines.splice(LineIndex+2,this.Lines[0]-LineIndex-1);this.Lines[0]=LineIndex+1}}if(0=== CParagraphContentWithContentBase.prototype.protected_AddRange=function(LineIndex,RangeIndex){if(this.Lines[0]>=LineIndex+1){var RangeOffset=this.protected_GetRangeOffset(LineIndex,0)+RangeIndex*2;this.Lines.splice(RangeOffset,this.Lines.length-RangeOffset);if(this.Lines[0]!==LineIndex+1&&0===RangeIndex)this.Lines.splice(LineIndex+1,this.Lines[0]-LineIndex);else if(this.Lines[0]!==LineIndex+1&&0!==RangeIndex){this.Lines.splice(LineIndex+2,this.Lines[0]-LineIndex-1);this.Lines[0]=LineIndex+1}}if(0===
RangeIndex)if(this.Lines[0]!==LineIndex+1){var OffsetValue=this.Lines.length-LineIndex-1;this.Lines.splice(LineIndex+1,0,OffsetValue);this.Lines[0]=LineIndex+1}var RangeOffset=1+this.Lines[0]+this.Lines[LineIndex+1]+RangeIndex*2;this.Lines[RangeOffset+0]=0;this.Lines[RangeOffset+1]=0;if(0!==LineIndex||0!==RangeIndex)return this.Lines[RangeOffset-1];else return 0}; RangeIndex)if(this.Lines[0]!==LineIndex+1){var OffsetValue=this.Lines.length-LineIndex-1;this.Lines.splice(LineIndex+1,0,OffsetValue);this.Lines[0]=LineIndex+1}var RangeOffset=1+this.Lines[0]+this.Lines[LineIndex+1]+RangeIndex*2;this.Lines[RangeOffset+0]=0;this.Lines[RangeOffset+1]=0;if(0!==LineIndex||0!==RangeIndex)return this.Lines[RangeOffset-1];else return 0};
CParagraphContentWithContentBase.prototype.protected_FillRange=function(LineIndex,RangeIndex,StartPos,EndPos){var RangeOffset=this.protected_GetRangeOffset(LineIndex,RangeIndex);this.Lines[RangeOffset+0]=StartPos;this.Lines[RangeOffset+1]=EndPos};CParagraphContentWithContentBase.prototype.protected_FillRangeEndPos=function(LineIndex,RangeIndex,EndPos){var RangeOffset=this.protected_GetRangeOffset(LineIndex,RangeIndex);this.Lines[RangeOffset+1]=EndPos}; CParagraphContentWithContentBase.prototype.protected_FillRange=function(LineIndex,RangeIndex,StartPos,EndPos){var RangeOffset=this.protected_GetRangeOffset(LineIndex,RangeIndex);this.Lines[RangeOffset+0]=StartPos;this.Lines[RangeOffset+1]=EndPos};CParagraphContentWithContentBase.prototype.protected_FillRangeEndPos=function(LineIndex,RangeIndex,EndPos){var RangeOffset=this.protected_GetRangeOffset(LineIndex,RangeIndex);this.Lines[RangeOffset+1]=EndPos};
CParagraphContentWithContentBase.prototype.private_UpdateSpellChecking=function(){if(this.Paragraph){this.Paragraph.SpellChecker.ClearPausedEngine();this.Paragraph.RecalcInfo.Set_Type_0_Spell(pararecalc_0_Spell_All)}};CParagraphContentWithContentBase.prototype.Is_UseInDocument=function(Id){if(this.Paragraph){for(var i=0;i<this.Content.length;++i)if(this.Content[i].Get_Id&&this.Content[i].Get_Id()===Id)break;if(i<this.Content.length)return this.Paragraph.Is_UseInDocument(this.Get_Id())}return false}; CParagraphContentWithContentBase.prototype.private_UpdateSpellChecking=function(){if(this.Paragraph&&this.Paragraph.SpellChecker){this.Paragraph.SpellChecker.ClearPausedEngine();this.Paragraph.RecalcInfo.Set_Type_0_Spell(pararecalc_0_Spell_All)}};CParagraphContentWithContentBase.prototype.Is_UseInDocument=function(Id){if(this.Paragraph){for(var i=0;i<this.Content.length;++i)if(this.Content[i].Get_Id&&this.Content[i].Get_Id()===Id)break;if(i<this.Content.length)return this.Paragraph.Is_UseInDocument(this.Get_Id())}return false};
CParagraphContentWithContentBase.prototype.protected_GetPrevRangeEndPos=function(LineIndex,RangeIndex){var RangeCount=this.protected_GetRangesCount(LineIndex-1);var RangeOffset=this.protected_GetRangeOffset(LineIndex-1,RangeCount-1);return LineIndex==0&&RangeIndex==0?0:this.Lines[RangeOffset+1]}; CParagraphContentWithContentBase.prototype.protected_GetPrevRangeEndPos=function(LineIndex,RangeIndex){var RangeCount=this.protected_GetRangesCount(LineIndex-1);var RangeOffset=this.protected_GetRangeOffset(LineIndex-1,RangeCount-1);return LineIndex==0&&RangeIndex==0?0:this.Lines[RangeOffset+1]};
CParagraphContentWithContentBase.prototype.private_UpdateTrackRevisions=function(){if(this.Paragraph&&this.Paragraph.LogicDocument&&this.Paragraph.LogicDocument.GetTrackRevisionsManager){var RevisionsManager=this.Paragraph.LogicDocument.GetTrackRevisionsManager();RevisionsManager.CheckElement(this.Paragraph)}};CParagraphContentWithContentBase.prototype.CanSplit=function(){return true};CParagraphContentWithContentBase.prototype.PreDelete=function(){}; CParagraphContentWithContentBase.prototype.private_UpdateTrackRevisions=function(){if(this.Paragraph&&this.Paragraph.LogicDocument&&this.Paragraph.LogicDocument.GetTrackRevisionsManager){var RevisionsManager=this.Paragraph.LogicDocument.GetTrackRevisionsManager();RevisionsManager.CheckElement(this.Paragraph)}};CParagraphContentWithContentBase.prototype.CanSplit=function(){return true};CParagraphContentWithContentBase.prototype.PreDelete=function(){};
CParagraphContentWithContentBase.prototype.private_UpdateDocumentOutline=function(){if(this.Paragraph)this.Paragraph.UpdateDocumentOutline()};CParagraphContentWithContentBase.prototype.IsSolid=function(){return false}; CParagraphContentWithContentBase.prototype.private_UpdateDocumentOutline=function(){if(this.Paragraph)this.Paragraph.UpdateDocumentOutline()};CParagraphContentWithContentBase.prototype.IsSolid=function(){return false};

View File

@@ -15729,7 +15729,7 @@ CParagraphContentWithContentBase.prototype.protected_GetRangesCount=function(Lin
CParagraphContentWithContentBase.prototype.protected_AddRange=function(LineIndex,RangeIndex){if(this.Lines[0]>=LineIndex+1){var RangeOffset=this.protected_GetRangeOffset(LineIndex,0)+RangeIndex*2;this.Lines.splice(RangeOffset,this.Lines.length-RangeOffset);if(this.Lines[0]!==LineIndex+1&&0===RangeIndex)this.Lines.splice(LineIndex+1,this.Lines[0]-LineIndex);else if(this.Lines[0]!==LineIndex+1&&0!==RangeIndex){this.Lines.splice(LineIndex+2,this.Lines[0]-LineIndex-1);this.Lines[0]=LineIndex+1}}if(0=== CParagraphContentWithContentBase.prototype.protected_AddRange=function(LineIndex,RangeIndex){if(this.Lines[0]>=LineIndex+1){var RangeOffset=this.protected_GetRangeOffset(LineIndex,0)+RangeIndex*2;this.Lines.splice(RangeOffset,this.Lines.length-RangeOffset);if(this.Lines[0]!==LineIndex+1&&0===RangeIndex)this.Lines.splice(LineIndex+1,this.Lines[0]-LineIndex);else if(this.Lines[0]!==LineIndex+1&&0!==RangeIndex){this.Lines.splice(LineIndex+2,this.Lines[0]-LineIndex-1);this.Lines[0]=LineIndex+1}}if(0===
RangeIndex)if(this.Lines[0]!==LineIndex+1){var OffsetValue=this.Lines.length-LineIndex-1;this.Lines.splice(LineIndex+1,0,OffsetValue);this.Lines[0]=LineIndex+1}var RangeOffset=1+this.Lines[0]+this.Lines[LineIndex+1]+RangeIndex*2;this.Lines[RangeOffset+0]=0;this.Lines[RangeOffset+1]=0;if(0!==LineIndex||0!==RangeIndex)return this.Lines[RangeOffset-1];else return 0}; RangeIndex)if(this.Lines[0]!==LineIndex+1){var OffsetValue=this.Lines.length-LineIndex-1;this.Lines.splice(LineIndex+1,0,OffsetValue);this.Lines[0]=LineIndex+1}var RangeOffset=1+this.Lines[0]+this.Lines[LineIndex+1]+RangeIndex*2;this.Lines[RangeOffset+0]=0;this.Lines[RangeOffset+1]=0;if(0!==LineIndex||0!==RangeIndex)return this.Lines[RangeOffset-1];else return 0};
CParagraphContentWithContentBase.prototype.protected_FillRange=function(LineIndex,RangeIndex,StartPos,EndPos){var RangeOffset=this.protected_GetRangeOffset(LineIndex,RangeIndex);this.Lines[RangeOffset+0]=StartPos;this.Lines[RangeOffset+1]=EndPos};CParagraphContentWithContentBase.prototype.protected_FillRangeEndPos=function(LineIndex,RangeIndex,EndPos){var RangeOffset=this.protected_GetRangeOffset(LineIndex,RangeIndex);this.Lines[RangeOffset+1]=EndPos}; CParagraphContentWithContentBase.prototype.protected_FillRange=function(LineIndex,RangeIndex,StartPos,EndPos){var RangeOffset=this.protected_GetRangeOffset(LineIndex,RangeIndex);this.Lines[RangeOffset+0]=StartPos;this.Lines[RangeOffset+1]=EndPos};CParagraphContentWithContentBase.prototype.protected_FillRangeEndPos=function(LineIndex,RangeIndex,EndPos){var RangeOffset=this.protected_GetRangeOffset(LineIndex,RangeIndex);this.Lines[RangeOffset+1]=EndPos};
CParagraphContentWithContentBase.prototype.private_UpdateSpellChecking=function(){if(this.Paragraph){this.Paragraph.SpellChecker.ClearPausedEngine();this.Paragraph.RecalcInfo.Set_Type_0_Spell(pararecalc_0_Spell_All)}};CParagraphContentWithContentBase.prototype.Is_UseInDocument=function(Id){if(this.Paragraph){for(var i=0;i<this.Content.length;++i)if(this.Content[i].Get_Id&&this.Content[i].Get_Id()===Id)break;if(i<this.Content.length)return this.Paragraph.Is_UseInDocument(this.Get_Id())}return false}; CParagraphContentWithContentBase.prototype.private_UpdateSpellChecking=function(){if(this.Paragraph&&this.Paragraph.SpellChecker){this.Paragraph.SpellChecker.ClearPausedEngine();this.Paragraph.RecalcInfo.Set_Type_0_Spell(pararecalc_0_Spell_All)}};CParagraphContentWithContentBase.prototype.Is_UseInDocument=function(Id){if(this.Paragraph){for(var i=0;i<this.Content.length;++i)if(this.Content[i].Get_Id&&this.Content[i].Get_Id()===Id)break;if(i<this.Content.length)return this.Paragraph.Is_UseInDocument(this.Get_Id())}return false};
CParagraphContentWithContentBase.prototype.protected_GetPrevRangeEndPos=function(LineIndex,RangeIndex){var RangeCount=this.protected_GetRangesCount(LineIndex-1);var RangeOffset=this.protected_GetRangeOffset(LineIndex-1,RangeCount-1);return LineIndex==0&&RangeIndex==0?0:this.Lines[RangeOffset+1]}; CParagraphContentWithContentBase.prototype.protected_GetPrevRangeEndPos=function(LineIndex,RangeIndex){var RangeCount=this.protected_GetRangesCount(LineIndex-1);var RangeOffset=this.protected_GetRangeOffset(LineIndex-1,RangeCount-1);return LineIndex==0&&RangeIndex==0?0:this.Lines[RangeOffset+1]};
CParagraphContentWithContentBase.prototype.private_UpdateTrackRevisions=function(){if(this.Paragraph&&this.Paragraph.LogicDocument&&this.Paragraph.LogicDocument.GetTrackRevisionsManager){var RevisionsManager=this.Paragraph.LogicDocument.GetTrackRevisionsManager();RevisionsManager.CheckElement(this.Paragraph)}};CParagraphContentWithContentBase.prototype.CanSplit=function(){return true};CParagraphContentWithContentBase.prototype.PreDelete=function(){}; CParagraphContentWithContentBase.prototype.private_UpdateTrackRevisions=function(){if(this.Paragraph&&this.Paragraph.LogicDocument&&this.Paragraph.LogicDocument.GetTrackRevisionsManager){var RevisionsManager=this.Paragraph.LogicDocument.GetTrackRevisionsManager();RevisionsManager.CheckElement(this.Paragraph)}};CParagraphContentWithContentBase.prototype.CanSplit=function(){return true};CParagraphContentWithContentBase.prototype.PreDelete=function(){};
CParagraphContentWithContentBase.prototype.private_UpdateDocumentOutline=function(){if(this.Paragraph)this.Paragraph.UpdateDocumentOutline()};CParagraphContentWithContentBase.prototype.IsSolid=function(){return false}; CParagraphContentWithContentBase.prototype.private_UpdateDocumentOutline=function(){if(this.Paragraph)this.Paragraph.UpdateDocumentOutline()};CParagraphContentWithContentBase.prototype.IsSolid=function(){return false};

View File

@@ -11268,7 +11268,7 @@ CParagraphContentWithContentBase.prototype.protected_GetRangesCount=function(Lin
CParagraphContentWithContentBase.prototype.protected_AddRange=function(LineIndex,RangeIndex){if(this.Lines[0]>=LineIndex+1){var RangeOffset=this.protected_GetRangeOffset(LineIndex,0)+RangeIndex*2;this.Lines.splice(RangeOffset,this.Lines.length-RangeOffset);if(this.Lines[0]!==LineIndex+1&&0===RangeIndex)this.Lines.splice(LineIndex+1,this.Lines[0]-LineIndex);else if(this.Lines[0]!==LineIndex+1&&0!==RangeIndex){this.Lines.splice(LineIndex+2,this.Lines[0]-LineIndex-1);this.Lines[0]=LineIndex+1}}if(0=== CParagraphContentWithContentBase.prototype.protected_AddRange=function(LineIndex,RangeIndex){if(this.Lines[0]>=LineIndex+1){var RangeOffset=this.protected_GetRangeOffset(LineIndex,0)+RangeIndex*2;this.Lines.splice(RangeOffset,this.Lines.length-RangeOffset);if(this.Lines[0]!==LineIndex+1&&0===RangeIndex)this.Lines.splice(LineIndex+1,this.Lines[0]-LineIndex);else if(this.Lines[0]!==LineIndex+1&&0!==RangeIndex){this.Lines.splice(LineIndex+2,this.Lines[0]-LineIndex-1);this.Lines[0]=LineIndex+1}}if(0===
RangeIndex)if(this.Lines[0]!==LineIndex+1){var OffsetValue=this.Lines.length-LineIndex-1;this.Lines.splice(LineIndex+1,0,OffsetValue);this.Lines[0]=LineIndex+1}var RangeOffset=1+this.Lines[0]+this.Lines[LineIndex+1]+RangeIndex*2;this.Lines[RangeOffset+0]=0;this.Lines[RangeOffset+1]=0;if(0!==LineIndex||0!==RangeIndex)return this.Lines[RangeOffset-1];else return 0}; RangeIndex)if(this.Lines[0]!==LineIndex+1){var OffsetValue=this.Lines.length-LineIndex-1;this.Lines.splice(LineIndex+1,0,OffsetValue);this.Lines[0]=LineIndex+1}var RangeOffset=1+this.Lines[0]+this.Lines[LineIndex+1]+RangeIndex*2;this.Lines[RangeOffset+0]=0;this.Lines[RangeOffset+1]=0;if(0!==LineIndex||0!==RangeIndex)return this.Lines[RangeOffset-1];else return 0};
CParagraphContentWithContentBase.prototype.protected_FillRange=function(LineIndex,RangeIndex,StartPos,EndPos){var RangeOffset=this.protected_GetRangeOffset(LineIndex,RangeIndex);this.Lines[RangeOffset+0]=StartPos;this.Lines[RangeOffset+1]=EndPos};CParagraphContentWithContentBase.prototype.protected_FillRangeEndPos=function(LineIndex,RangeIndex,EndPos){var RangeOffset=this.protected_GetRangeOffset(LineIndex,RangeIndex);this.Lines[RangeOffset+1]=EndPos}; CParagraphContentWithContentBase.prototype.protected_FillRange=function(LineIndex,RangeIndex,StartPos,EndPos){var RangeOffset=this.protected_GetRangeOffset(LineIndex,RangeIndex);this.Lines[RangeOffset+0]=StartPos;this.Lines[RangeOffset+1]=EndPos};CParagraphContentWithContentBase.prototype.protected_FillRangeEndPos=function(LineIndex,RangeIndex,EndPos){var RangeOffset=this.protected_GetRangeOffset(LineIndex,RangeIndex);this.Lines[RangeOffset+1]=EndPos};
CParagraphContentWithContentBase.prototype.private_UpdateSpellChecking=function(){if(this.Paragraph){this.Paragraph.SpellChecker.ClearPausedEngine();this.Paragraph.RecalcInfo.Set_Type_0_Spell(pararecalc_0_Spell_All)}};CParagraphContentWithContentBase.prototype.Is_UseInDocument=function(Id){if(this.Paragraph){for(var i=0;i<this.Content.length;++i)if(this.Content[i].Get_Id&&this.Content[i].Get_Id()===Id)break;if(i<this.Content.length)return this.Paragraph.Is_UseInDocument(this.Get_Id())}return false}; CParagraphContentWithContentBase.prototype.private_UpdateSpellChecking=function(){if(this.Paragraph&&this.Paragraph.SpellChecker){this.Paragraph.SpellChecker.ClearPausedEngine();this.Paragraph.RecalcInfo.Set_Type_0_Spell(pararecalc_0_Spell_All)}};CParagraphContentWithContentBase.prototype.Is_UseInDocument=function(Id){if(this.Paragraph){for(var i=0;i<this.Content.length;++i)if(this.Content[i].Get_Id&&this.Content[i].Get_Id()===Id)break;if(i<this.Content.length)return this.Paragraph.Is_UseInDocument(this.Get_Id())}return false};
CParagraphContentWithContentBase.prototype.protected_GetPrevRangeEndPos=function(LineIndex,RangeIndex){var RangeCount=this.protected_GetRangesCount(LineIndex-1);var RangeOffset=this.protected_GetRangeOffset(LineIndex-1,RangeCount-1);return LineIndex==0&&RangeIndex==0?0:this.Lines[RangeOffset+1]}; CParagraphContentWithContentBase.prototype.protected_GetPrevRangeEndPos=function(LineIndex,RangeIndex){var RangeCount=this.protected_GetRangesCount(LineIndex-1);var RangeOffset=this.protected_GetRangeOffset(LineIndex-1,RangeCount-1);return LineIndex==0&&RangeIndex==0?0:this.Lines[RangeOffset+1]};
CParagraphContentWithContentBase.prototype.private_UpdateTrackRevisions=function(){if(this.Paragraph&&this.Paragraph.LogicDocument&&this.Paragraph.LogicDocument.GetTrackRevisionsManager){var RevisionsManager=this.Paragraph.LogicDocument.GetTrackRevisionsManager();RevisionsManager.CheckElement(this.Paragraph)}};CParagraphContentWithContentBase.prototype.CanSplit=function(){return true};CParagraphContentWithContentBase.prototype.PreDelete=function(){}; CParagraphContentWithContentBase.prototype.private_UpdateTrackRevisions=function(){if(this.Paragraph&&this.Paragraph.LogicDocument&&this.Paragraph.LogicDocument.GetTrackRevisionsManager){var RevisionsManager=this.Paragraph.LogicDocument.GetTrackRevisionsManager();RevisionsManager.CheckElement(this.Paragraph)}};CParagraphContentWithContentBase.prototype.CanSplit=function(){return true};CParagraphContentWithContentBase.prototype.PreDelete=function(){};
CParagraphContentWithContentBase.prototype.private_UpdateDocumentOutline=function(){if(this.Paragraph)this.Paragraph.UpdateDocumentOutline()};CParagraphContentWithContentBase.prototype.IsSolid=function(){return false}; CParagraphContentWithContentBase.prototype.private_UpdateDocumentOutline=function(){if(this.Paragraph)this.Paragraph.UpdateDocumentOutline()};CParagraphContentWithContentBase.prototype.IsSolid=function(){return false};

View File

@@ -582,7 +582,8 @@
"a": "<em>Pad</em> è un termine popolare per <a href='http://etherpad.org/' target='_blank'>Etherpad</a>, un editor collaborativo in tempo reale.\nSi riferisce ad un documento che puoi modificare nel tuo browser, generalmente con le modifiche di altri utenti visibili in modo quasi istantaneo." "a": "<em>Pad</em> è un termine popolare per <a href='http://etherpad.org/' target='_blank'>Etherpad</a>, un editor collaborativo in tempo reale.\nSi riferisce ad un documento che puoi modificare nel tuo browser, generalmente con le modifiche di altri utenti visibili in modo quasi istantaneo."
}, },
"expiring": { "expiring": {
"q": "Cos'è un pad effimero?" "q": "Cos'è un pad effimero?",
"a": "Un <em>expiring pad</em> è un pad creato con una scadenza, raggiunta il pad verrà automaticamente cancellato dal server. Gli expiring pad possono essere configurati per durare da un minimo di un'ora ad un massimo di 100 mesi. Il pad e tutta la sua cronologia diventeranno permanentemente non disponibili anche se vengono modificati nel momento in cui scadono.<br><br>Se un pad è impostato con una scadenza, puoi controllare il suo tempo di durata visualizzando le sue <em> proprietà </em>, sia facendo clic con il tasto destro del mouse sul pad in CryptDrive, sia usando la <em> proprietà </em> -menu dalla barra degli strumenti di un'applicazione."
}, },
"owned": { "owned": {
"a": "Un <em>pad di proprietà</em> è un pad creato da un esplicito <em>proprietario</em>, identificato dal server dalla sua <em>chiave di crittografia pubblica</em>. Il proprietario di un pad può scegliere di cancellare i suoi pad dal server, rendendoli invalidi per gli altri collaboratori nel futuro, sia che essi li avessero oppure no nei loro Cryptdrive.", "a": "Un <em>pad di proprietà</em> è un pad creato da un esplicito <em>proprietario</em>, identificato dal server dalla sua <em>chiave di crittografia pubblica</em>. Il proprietario di un pad può scegliere di cancellare i suoi pad dal server, rendendoli invalidi per gli altri collaboratori nel futuro, sia che essi li avessero oppure no nei loro Cryptdrive.",

View File

@@ -457,9 +457,9 @@ define([
APP.editor.save(); APP.editor.save();
}; };
Messages.profile_copyKey = "Copy edPublic key"; // XXX
var addPublicKey = function ($container) { var addPublicKey = function ($container) {
if (!APP.readOnly) { return; } if (!APP.readOnly) { return; }
if (!Messages.profile_copyKey) { return; } // XXX
var $div = $(h('div.cp-sidebarlayout-element')).appendTo($container); var $div = $(h('div.cp-sidebarlayout-element')).appendTo($container);
APP.$edPublic = $('<button>', { APP.$edPublic = $('<button>', {
@@ -473,6 +473,7 @@ define([
}; };
var setPublicKeyButton = function (data) { var setPublicKeyButton = function (data) {
if (!data.edPublic || APP.getEdPublic || !APP.readOnly) { return; } if (!data.edPublic || APP.getEdPublic || !APP.readOnly) { return; }
if (!Messages.profile_copyKey) { return; } // XXX
APP.$edPublic.show(); APP.$edPublic.show();
APP.getEdPublic = function () { APP.getEdPublic = function () {
var metadataMgr = APP.common.getMetadataMgr(); var metadataMgr = APP.common.getMetadataMgr();

View File

@@ -35,7 +35,6 @@
#cp-app-whiteboard-container { #cp-app-whiteboard-container {
flex: 1; flex: 1;
display: flex; display: flex;
flex-flow: column;
overflow: auto; overflow: auto;
} }
@@ -43,14 +42,17 @@
#cp-app-whiteboard-canvas-area { #cp-app-whiteboard-canvas-area {
flex: 1; flex: 1;
display: flex; display: flex;
min-height: 0;
} }
// created by fabricjs. styled so defaults don't break anything // created by fabricjs. styled so defaults don't break anything
.cp-app-whiteboard-canvas-container { .cp-app-whiteboard-canvas-container {
width: 100%;
margin: auto; margin: auto;
background: white; background: white;
flex: 1; flex: 1;
min-height: 0; min-height: 0;
& > canvas { & > canvas {
width: 100%;
border: 1px solid black; border: 1px solid black;
} }
} }

View File

@@ -137,7 +137,7 @@ define([
canvas.discardActiveGroup(); canvas.discardActiveGroup();
} }
canvas.renderAll(); canvas.renderAll();
framework.localChange(); APP.onLocal();
}; };
$deleteButton.click(deleteSelection); $deleteButton.click(deleteSelection);
$(window).on('keyup', function (e) { $(window).on('keyup', function (e) {
@@ -220,7 +220,7 @@ define([
var metadata = JSON.parse(JSON.stringify(metadataMgr.getMetadata())); var metadata = JSON.parse(JSON.stringify(metadataMgr.getMetadata()));
metadata.palette = newPalette; metadata.palette = newPalette;
metadataMgr.updateMetadata(metadata); metadataMgr.updateMetadata(metadata);
framework.localChange(); APP.onLocal();
}; };
var makeColorButton = function ($container) { var makeColorButton = function ($container) {
@@ -284,6 +284,34 @@ define([
}); });
var $canvas = $('canvas'); var $canvas = $('canvas');
var $canvasContainer = $('canvas').parents('.cp-app-whiteboard-canvas-container'); var $canvasContainer = $('canvas').parents('.cp-app-whiteboard-canvas-container');
var $container = $('#cp-app-whiteboard-container');
// Max for old macs: 2048×1464
// Max for IE: 8192x8192
var MAX = 8192;
var onResize = APP.onResize = function () {
var w = $container.width();
var h = $container.height();
canvas.forEachObject(function (obj) {
var c = obj.getCoords();
Object.keys(c).forEach(function (k) {
if (c[k].x > w) { w = c[k].x + 1; }
if (c[k].y > h) { h = c[k].y + 1; }
});
});
w = Math.min(w, MAX);
h = Math.min(h, MAX);
canvas.setWidth(w);
canvas.setHeight(h);
canvas.calcOffset();
};
$(window).on('resize', onResize);
var onLocal = APP.onLocal = function () {
framework.localChange();
APP.onResize();
};
var $controls = $('#cp-app-whiteboard-controls'); var $controls = $('#cp-app-whiteboard-controls');
var metadataMgr = framework._.cpNfInner.metadataMgr; var metadataMgr = framework._.cpNfInner.metadataMgr;
@@ -333,7 +361,7 @@ define([
} }
var cImg = new Fabric.Image(img, { left:0, top:0, angle:0, }); var cImg = new Fabric.Image(img, { left:0, top:0, angle:0, });
APP.canvas.add(cImg); APP.canvas.add(cImg);
framework.localChange(); onLocal();
}; };
// Embed image // Embed image
@@ -403,7 +431,7 @@ define([
$('#cp-app-whiteboard-clear').on('click', function () { $('#cp-app-whiteboard-clear').on('click', function () {
canvas.clear(); canvas.clear();
framework.localChange(); onLocal();
}); });
// --------------------------------------------- // ---------------------------------------------
@@ -432,6 +460,7 @@ define([
var content = newContent.content; var content = newContent.content;
canvas.loadFromJSON(content, waitFor(function () { canvas.loadFromJSON(content, waitFor(function () {
canvas.renderAll(); canvas.renderAll();
onResize();
})); }));
}); });
@@ -461,7 +490,7 @@ define([
window.setTimeout(mkThumbnail, Thumb.UPDATE_FIRST); window.setTimeout(mkThumbnail, Thumb.UPDATE_FIRST);
}); });
canvas.on('mouse:up', framework.localChange); canvas.on('mouse:up', onLocal);
framework.start(); framework.start();
}; };
@@ -471,8 +500,6 @@ define([
h('div#cp-app-whiteboard-canvas-area', h('div#cp-app-whiteboard-canvas-area',
h('div#cp-app-whiteboard-container', h('div#cp-app-whiteboard-container',
h('canvas#cp-app-whiteboard-canvas', { h('canvas#cp-app-whiteboard-canvas', {
width: 600,
height: 600
}) })
) )
), ),