Merge branch 'staging' of github.com:xwiki-labs/cryptpad into staging

This commit is contained in:
yflory 2017-07-05 12:27:08 +02:00
commit 35e8c1a63b
8 changed files with 74 additions and 84 deletions

View File

@ -38,6 +38,7 @@
"scrypt-async": "1.2.0", "scrypt-async": "1.2.0",
"require-css": "0.1.10", "require-css": "0.1.10",
"less": "^2.7.2", "less": "^2.7.2",
"bootstrap": "#v4.0.0-alpha.6" "bootstrap": "#v4.0.0-alpha.6",
"diff-dom": "2.1.1"
} }
} }

11
rpc.js
View File

@ -583,9 +583,10 @@ var resetUserPins = function (Env, publicKey, channelList, cb) {
if (e) { return void cb(e); } if (e) { return void cb(e); }
var pinSize = sumChannelSizes(sizes); var pinSize = sumChannelSizes(sizes);
getFreeSpace(Env, publicKey, function (e, free) {
getLimit(Env, publicKey, function (e, limit) {
if (e) { if (e) {
WARN('getFreeSpace', e); WARN('[RESET_ERR]', e);
return void cb(e); return void cb(e);
} }
@ -597,7 +598,7 @@ var resetUserPins = function (Env, publicKey, channelList, cb) {
They will not be able to pin additional pads until they upgrade They will not be able to pin additional pads until they upgrade
or delete enough files to go back under their limit. */ or delete enough files to go back under their limit. */
if (pinSize > free && session.hasPinned) { return void(cb('E_OVER_LIMIT')); } if (pinSize > limit && session.hasPinned) { return void(cb('E_OVER_LIMIT')); }
pinStore.message(publicKey, JSON.stringify(['RESET', channelList]), pinStore.message(publicKey, JSON.stringify(['RESET', channelList]),
function (e) { function (e) {
if (e) { return void cb(e); } if (e) { return void cb(e); }
@ -1087,8 +1088,8 @@ RPC.create = function (config /*:typeof(ConfigType)*/, cb /*:(?Error, ?Function)
return void handleMessage(false); return void handleMessage(false);
} }
// restrict upload capability unless explicitly disabled // allow unrestricted uploads unless restrictUploads is true
if (config.restrictUploads === false) { if (config.restrictUploads !== true) {
return void handleMessage(true); return void handleMessage(true);
} }

View File

@ -9,7 +9,6 @@ define([
'/common/cryptpad-common.js', '/common/cryptpad-common.js',
'/common/cryptget.js', '/common/cryptget.js',
'/common/diffMarked.js', '/common/diffMarked.js',
'/bower_components/tweetnacl/nacl-fast.min.js', // needed for media-tag
'css!/bower_components/components-font-awesome/css/font-awesome.min.css', 'css!/bower_components/components-font-awesome/css/font-awesome.min.css',
'less!/customize/src/less/cryptpad.less' 'less!/customize/src/less/cryptpad.less'

View File

@ -16,9 +16,10 @@ define([
'/common/clipboard.js', '/common/clipboard.js',
'/common/pinpad.js', '/common/pinpad.js',
'/customize/application_config.js' '/customize/application_config.js',
'/common/media-tag.js',
], function ($, Config, Messages, Store, Util, Hash, UI, History, UserList, Title, Metadata, ], function ($, Config, Messages, Store, Util, Hash, UI, History, UserList, Title, Metadata,
CodeMirror, Files, FileCrypto, Clipboard, Pinpad, AppConfig) { CodeMirror, Files, FileCrypto, Clipboard, Pinpad, AppConfig, MediaTag) {
/* This file exposes functionality which is specific to Cryptpad, but not to /* This file exposes functionality which is specific to Cryptpad, but not to
any particular pad type. This includes functions for committing metadata any particular pad type. This includes functions for committing metadata
@ -830,7 +831,9 @@ define([
if (!pinsReady()) { return void cb('RPC_NOT_READY'); } if (!pinsReady()) { return void cb('RPC_NOT_READY'); }
var account = common.account; var account = common.account;
if (typeof(account.limit) !== 'number' ||
var ALWAYS_REVALIDATE = true;
if (ALWAYS_REVALIDATE || typeof(account.limit) !== 'number' ||
typeof(account.plan) !== 'string' || typeof(account.plan) !== 'string' ||
typeof(account.note) !== 'string') { typeof(account.note) !== 'string') {
return void rpc.getLimit(function (e, limit, plan, note) { return void rpc.getLimit(function (e, limit, plan, note) {
@ -893,7 +896,6 @@ define([
var $container = $('<span>', {'class':'limit-container'}); var $container = $('<span>', {'class':'limit-container'});
var todo; var todo;
var updateUsage = window.updateUsage = common.notAgainForAnother(function () { var updateUsage = window.updateUsage = common.notAgainForAnother(function () {
console.log("updating usage bar");
common.getPinnedUsage(todo); common.getPinnedUsage(todo);
}, LIMIT_REFRESH_RATE); }, LIMIT_REFRESH_RATE);
@ -963,21 +965,12 @@ define([
}; };
setInterval(function () { setInterval(function () {
var t = updateUsage(); updateUsage();
if (t) {
console.log("usage already updated. eligible for refresh in %sms", t);
}
}, LIMIT_REFRESH_RATE * 3); }, LIMIT_REFRESH_RATE * 3);
updateUsage(); updateUsage();
getProxy().on('change', ['drive'], function () { getProxy().on('change', ['drive'], function () {
var t = updateUsage(); updateUsage();
if (t) {
console.log("usage bar update throttled due to overuse." +
" Eligible for update in %sms", t);
} else {
console.log("usage bar updated");
}
}); });
cb(null, $container); cb(null, $container);
}; };
@ -1231,18 +1224,18 @@ define([
} }
if (decrypted.blob) { if (decrypted.blob) {
size = decrypted.blob.size size = decrypted.blob.size;
} }
var sizeMb = Cryptpad.bytesToMegabytes(size); var sizeMb = common.bytesToMegabytes(size);
var $btn = $(root).find('button'); var $btn = $(root).find('button');
$btn.addClass('btn btn-success') $btn.addClass('btn btn-success')
.attr('type', 'download') .attr('type', 'download')
.html(function (i, html) { .html(function () {
var text = Messages.download_mt_button + '<br>'; var text = Messages.download_mt_button + '<br>';
if (title) { if (title) {
text += '<b>' + Cryptpad.fixHTML(title) + '</b><br>'; text += '<b>' + common.fixHTML(title) + '</b><br>';
} }
if (size) { if (size) {
text += '<em>' + Messages._getKey('formattedMB', [sizeMb]) + '</em>'; text += '<em>' + Messages._getKey('formattedMB', [sizeMb]) + '</em>';
@ -1284,35 +1277,32 @@ define([
var $img = $('<media-tag>').appendTo($container); var $img = $('<media-tag>').appendTo($container);
$img.attr('src', src); $img.attr('src', src);
$img.attr('data-crypto-key', 'cryptpad:' + cryptKey); $img.attr('data-crypto-key', 'cryptpad:' + cryptKey);
require(['/common/media-tag.js'], function (MediaTag) { MediaTag($img[0]);
MediaTag($img[0]); var observer = new MutationObserver(function(mutations) {
var observer = new MutationObserver(function(mutations) { mutations.forEach(function(mutation) {
mutations.forEach(function(mutation) { if (mutation.type === 'childList' && mutation.addedNodes.length) {
if (mutation.type === 'childList' && mutation.addedNodes.length) { if (mutation.addedNodes.length > 1 ||
console.log(mutation); mutation.addedNodes[0].nodeName !== 'IMG') {
if (mutation.addedNodes.length > 1 || $img.remove();
mutation.addedNodes[0].nodeName !== 'IMG') { return void displayDefault();
$img.remove();
return void displayDefault();
}
var $image = $img.find('img');
var onLoad = function () {
var w = $image.width();
var h = $image.height();
if (w>h) {
$image.css('max-height', '100%');
$img.css('flex-direction', 'row');
if (cb) { cb($img); }
return;
}
$image.css('max-width', '100%');
$img.css('flex-direction', 'column');
if (cb) { cb($img); }
};
if ($image[0].complete) { onLoad(); }
$image.on('load', onLoad);
} }
}); var $image = $img.find('img');
var onLoad = function () {
var w = $image.width();
var h = $image.height();
if (w>h) {
$image.css('max-height', '100%');
$img.css('flex-direction', 'row');
if (cb) { cb($img); }
return;
}
$image.css('max-width', '100%');
$img.css('flex-direction', 'column');
if (cb) { cb($img); }
};
if ($image[0].complete) { onLoad(); }
$image.on('load', onLoad);
}
}); });
observer.observe($img[0], { observer.observe($img[0], {
attributes: false, attributes: false,

File diff suppressed because one or more lines are too long

View File

@ -7,12 +7,14 @@ define([
'/common/visible.js', '/common/visible.js',
'/common/notify.js', '/common/notify.js',
'/file/file-crypto.js', '/file/file-crypto.js',
'/common/media-tag.js',
'/bower_components/file-saver/FileSaver.min.js', '/bower_components/file-saver/FileSaver.min.js',
'/bower_components/tweetnacl/nacl-fast.min.js',
'css!/bower_components/components-font-awesome/css/font-awesome.min.css', 'css!/bower_components/components-font-awesome/css/font-awesome.min.css',
'less!/customize/src/less/cryptpad.less', 'less!/customize/src/less/cryptpad.less',
], function ($, Crypto, realtimeInput, Toolbar, Cryptpad, Visible, Notify, FileCrypto) { ], function ($, Crypto, realtimeInput, Toolbar, Cryptpad, Visible, Notify, FileCrypto, MediaTag) {
var Messages = Cryptpad.Messages; var Messages = Cryptpad.Messages;
var saveAs = window.saveAs; var saveAs = window.saveAs;
var Nacl = window.nacl; var Nacl = window.nacl;
@ -133,32 +135,30 @@ define([
console.log(progress.percent); console.log(progress.percent);
}); });
require(['/common/media-tag.js'], function (MediaTag) { /**
/** * Allowed mime types that have to be set for a rendering after a decryption.
* Allowed mime types that have to be set for a rendering after a decryption. *
* * @type {Array}
* @type {Array} */
*/ var allowedMediaTypes = [
var allowedMediaTypes = [ 'image/png',
'image/png', 'image/jpeg',
'image/jpeg', 'image/jpg',
'image/jpg', 'image/gif',
'image/gif', 'audio/mp3',
'audio/mp3', 'audio/ogg',
'audio/ogg', 'audio/wav',
'audio/wav', 'audio/webm',
'audio/webm', 'video/mp4',
'video/mp4', 'video/ogg',
'video/ogg', 'video/webm',
'video/webm', 'application/pdf',
'application/pdf', 'application/dash+xml',
'application/dash+xml', 'download'
'download' ];
]; MediaTag.CryptoFilter.setAllowedMediaTypes(allowedMediaTypes);
MediaTag.CryptoFilter.setAllowedMediaTypes(allowedMediaTypes);
MediaTag($mt[0]); MediaTag($mt[0]);
});
}; };
var todoBigFile = function (sizeMb) { var todoBigFile = function (sizeMb) {

View File

@ -11,7 +11,6 @@ define([
'/bower_components/marked/marked.min.js', '/bower_components/marked/marked.min.js',
'cm/lib/codemirror', 'cm/lib/codemirror',
'cm/mode/markdown/markdown', 'cm/mode/markdown/markdown',
'/bower_components/tweetnacl/nacl-fast.min.js',
'less!/profile/main.less', 'less!/profile/main.less',
], function ($, Cryptpad, Listmap, Crypto, Marked, CodeMirror) { ], function ($, Cryptpad, Listmap, Crypto, Marked, CodeMirror) {

View File

@ -9,7 +9,6 @@ define([
'/common/cryptpad-common.js', '/common/cryptpad-common.js',
'/common/cryptget.js', '/common/cryptget.js',
'/slide/slide.js', '/slide/slide.js',
'/bower_components/tweetnacl/nacl-fast.min.js', // needed for media-tag
'css!/bower_components/components-font-awesome/css/font-awesome.min.css', 'css!/bower_components/components-font-awesome/css/font-awesome.min.css',
'less!/customize/src/less/cryptpad.less', 'less!/customize/src/less/cryptpad.less',
@ -470,6 +469,7 @@ define([
}).append($('<span>', {'class': 'drawer'}).text(Messages.printText)); }).append($('<span>', {'class': 'drawer'}).text(Messages.printText));
// TODO reenable this when it is working again // TODO reenable this when it is working again
$printButton = $printButton;
//$drawer.append($printButton); //$drawer.append($printButton);
var $slideOptions = $('<button>', { var $slideOptions = $('<button>', {