From a08cf8faa8416595c4b69308243318d2e3cca183 Mon Sep 17 00:00:00 2001 From: yflory <yann.flory@xwiki.com> Date: Thu, 14 Dec 2017 09:44:20 +0100 Subject: [PATCH 1/7] Allow drive to receive updates after leaving history mode --- www/drive/inner.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/www/drive/inner.js b/www/drive/inner.js index 2197ba563..d403c61ad 100644 --- a/www/drive/inner.js +++ b/www/drive/inner.js @@ -2233,6 +2233,9 @@ define([ appStatus.ready(true); }; var displayDirectory = APP.displayDirectory = function (path, force) { + if (history.isHistoryMode) { + return void _displayDirectory(path, force); + } updateObject(sframeChan, proxy, function () { copyObjectValue(files, proxy.drive); _displayDirectory(path, force); @@ -2902,14 +2905,12 @@ define([ }); history.onEnterHistory = function (obj) { - var files = obj.drive; - filesOp = FO.init(files, config); + copyObjectValue(files, obj.drive); appStatus.isReady = true; refresh(); }; history.onLeaveHistory = function () { - var files = proxy.drive; - filesOp = FO.init(files, config); + copyObjectValue(files, proxy.drive); refresh(); }; From 92a8e107d7cab9d85ff26e67cf60e010dd036688 Mon Sep 17 00:00:00 2001 From: yflory <yann.flory@xwiki.com> Date: Fri, 15 Dec 2017 15:33:11 +0100 Subject: [PATCH 2/7] Use the correct hash when opening the todo app for the first time --- www/todo/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/todo/main.js b/www/todo/main.js index 2898434fd..322e2363b 100644 --- a/www/todo/main.js +++ b/www/todo/main.js @@ -40,7 +40,7 @@ define([ Cryptpad.getTodoHash(function (hash) { var nHash = hash || Utils.Hash.createRandomHash(); if (!hash) { Cryptpad.setTodoHash(nHash); } - cb(null, Utils.Hash.getSecrets('todo', hash)); + cb(null, Utils.Hash.getSecrets('todo', nHash)); }); }; SFCommonO.start({ From 50ddad5e41670d43d02b9799de39ea6fcd831f16 Mon Sep 17 00:00:00 2001 From: yflory <yann.flory@xwiki.com> Date: Fri, 15 Dec 2017 15:33:53 +0100 Subject: [PATCH 3/7] Fix an issue with the tag prompt removing all keyup listeners --- www/common/common-interface.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/www/common/common-interface.js b/www/common/common-interface.js index cb3e5b16a..ad6434441 100644 --- a/www/common/common-interface.js +++ b/www/common/common-interface.js @@ -55,6 +55,7 @@ define([ }; var stopListening = UI.stopListening = function (handler) { + if (!handler) { return; } // we don't want to stop all the 'keyup' listeners $(window).off('keyup', handler); }; @@ -210,7 +211,7 @@ define([ var $cancel = findCancelButton(tagger).click(function (e) { close(null, e); }); - listenForKeys(function () { + listener = listenForKeys(function () { $ok.click(); }, function () { $cancel.click(); From f292407c6ed53e0e7675ac07319de6c4e6ecf475 Mon Sep 17 00:00:00 2001 From: yflory <yann.flory@xwiki.com> Date: Fri, 15 Dec 2017 15:40:52 +0100 Subject: [PATCH 4/7] Fix present mode in the code app --- www/code/app-code.less | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/code/app-code.less b/www/code/app-code.less index 4758bc182..463bb07a3 100644 --- a/www/code/app-code.less +++ b/www/code/app-code.less @@ -50,7 +50,7 @@ height: 100%; overflow: hidden; &.cp-app-code-present { - .CodeMirror { display: none; } + #cp-app-code-container { display: none; } #cp-app-code-preview { border: 0; } } } From c18d4297e17f0a76eb5204b0b9e3d909b4c90226 Mon Sep 17 00:00:00 2001 From: yflory <yann.flory@xwiki.com> Date: Fri, 15 Dec 2017 16:19:22 +0100 Subject: [PATCH 5/7] Fix friend requests from the userlist --- www/common/cryptpad-common.js | 11 +++++++---- www/common/outer/async-store.js | 8 ++++---- www/common/sframe-common-outer.js | 11 +++++------ 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index 2ff827ee7..883538607 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -464,6 +464,11 @@ define([ common.onNetworkDisconnect = Util.mkEvent(); common.onNetworkReconnect = Util.mkEvent(); + // Messaging + var messaging = common.messaging = {}; + messaging.onFriendRequest = Util.mkEvent(); + messaging.onFriendComplete = Util.mkEvent(); + // Messenger var messenger = common.messenger = {}; messenger.getFriendList = function (cb) { @@ -600,13 +605,11 @@ define([ break; } case 'Q_FRIEND_REQUEST': { - if (!common.onFriendRequest) { break; } - common.onFriendRequest(data, cb); + common.messaging.onFriendRequest.fire(data, cb); break; } case 'EV_FRIEND_COMPLETE': { - if (!common.onFriendComplete) { break; } - common.onFriendComplete(data); + common.messaging.onFriendComplete.fire(data); break; } // Network diff --git a/www/common/outer/async-store.js b/www/common/outer/async-store.js index 8e6c91f70..9ae0bd330 100644 --- a/www/common/outer/async-store.js +++ b/www/common/outer/async-store.js @@ -616,11 +616,11 @@ define([ postMessage("UPDATE_METADATA"); }, pinPads: Store.pinPads, - friendComplete: function (data, cb) { - postMessage("Q_FRIEND_COMPLETE", data, cb); + friendComplete: function (data) { + postMessage("EV_FRIEND_COMPLETE", data); }, - friendRequest: function (data) { - postMessage("EV_FRIEND_REQUEST", data); + friendRequest: function (data, cb) { + postMessage("Q_FRIEND_REQUEST", data, cb); }, }; }; diff --git a/www/common/sframe-common-outer.js b/www/common/sframe-common-outer.js index fc132b8cb..2dc46a592 100644 --- a/www/common/sframe-common-outer.js +++ b/www/common/sframe-common-outer.js @@ -307,17 +307,16 @@ define([ }); sframeChan.on('Q_SEND_FRIEND_REQUEST', function (netfluxId, cb) { - Messaging.inviteFromUserlist(Cryptpad, netfluxId); - cb(); + Cryptpad.inviteFromUserlist(netfluxId, cb); }); - Cryptpad.onFriendRequest = function (confirmText, cb) { + Cryptpad.messaging.onFriendRequest.reg(function (confirmText, cb) { sframeChan.query('Q_INCOMING_FRIEND_REQUEST', confirmText, function (err, data) { cb(data); }); - }; - Cryptpad.onFriendComplete = function (data) { + }); + Cryptpad.messaging.onFriendComplete.reg(function (data) { sframeChan.event('EV_FRIEND_REQUEST', data); - }; + }); sframeChan.on('Q_GET_FULL_HISTORY', function (data, cb) { var crypto = Crypto.createEncryptor(secret.keys); From d666e9e7ee0a2437f756bb2d3ada808da29bc7b5 Mon Sep 17 00:00:00 2001 From: yflory <yann.flory@xwiki.com> Date: Fri, 15 Dec 2017 18:16:01 +0100 Subject: [PATCH 6/7] Remove tag and filepicker buttons for anon users --- customize.dist/translations/messages.fr.js | 2 +- www/common/sframe-app-framework.js | 2 + www/drive/inner.js | 4 ++ www/poll/inner.js | 40 +++++++-------- www/whiteboard/inner.js | 57 ++++++++++++---------- 5 files changed, 58 insertions(+), 47 deletions(-) diff --git a/customize.dist/translations/messages.fr.js b/customize.dist/translations/messages.fr.js index 0ba3413a3..e490cd040 100644 --- a/customize.dist/translations/messages.fr.js +++ b/customize.dist/translations/messages.fr.js @@ -156,7 +156,7 @@ define(function () { out.filePickerButton = "Intégrer un fichier stocké dans CryptDrive"; out.filePicker_close = "Fermer"; - out.filePicker_description = "Choisissez un fichier de votre CryptDrive pour l'intégrer ou uploadez-en un nouveau"; + out.filePicker_description = "Choisissez un fichier de votre CryptDrive pour l'intégrer ou importez-en un nouveau"; out.filePicker_filter = "Filtrez les fichiers par leur nom"; out.or = 'ou'; diff --git a/www/common/sframe-app-framework.js b/www/common/sframe-app-framework.js index 526e45678..fbe872d76 100644 --- a/www/common/sframe-app-framework.js +++ b/www/common/sframe-app-framework.js @@ -342,6 +342,7 @@ define([ }; var createFilePicker = function () { + if (!common.isLoggedIn()) { return; } common.initFilePicker({ onSelect: function (data) { if (data.type !== 'file') { @@ -369,6 +370,7 @@ define([ }).appendTo(toolbar.$rightside).hide(); }; var setMediaTagEmbedder = function (mte) { + if (!common.isLoggedIn()) { return; } if (!mte || readOnly) { $embedButton.hide(); return; diff --git a/www/drive/inner.js b/www/drive/inner.js index d403c61ad..aa8034f23 100644 --- a/www/drive/inner.js +++ b/www/drive/inner.js @@ -2638,6 +2638,10 @@ define([ APP.hideMenu(); }); + if (!APP.loggedIn) { + $defaultContextMenu.find('.cp-app-drive-context-delete').text(Messages.fc_remove) + .attr('data-icon', 'fa-eraser'); + } $defaultContextMenu.on("click", "a", function(e) { e.stopPropagation(); var paths = $(this).data('paths'); diff --git a/www/poll/inner.js b/www/poll/inner.js index df193985e..aa1c62a57 100644 --- a/www/poll/inner.js +++ b/www/poll/inner.js @@ -1142,27 +1142,29 @@ define([ APP.$publishButton = $publish; updatePublishButton(); - var fileDialogCfg = { - onSelect: function (data) { - if (data.type === 'file' && APP.editor) { - var mt = '<media-tag src="' + data.src + '" data-crypto-key="cryptpad:' + data.key + '"></media-tag>'; - APP.editor.replaceSelection(mt); - return; + if (common.isLoggedIn()) { + var fileDialogCfg = { + onSelect: function (data) { + if (data.type === 'file' && APP.editor) { + var mt = '<media-tag src="' + data.src + '" data-crypto-key="cryptpad:' + data.key + '"></media-tag>'; + APP.editor.replaceSelection(mt); + return; + } } - } - }; - common.initFilePicker(fileDialogCfg); - APP.$mediaTagButton = $('<button>', { - title: Messages.filePickerButton, - 'class': 'cp-toolbar-rightside-button fa fa-picture-o', - style: 'font-size: 17px' - }).click(function () { - var pickerCfg = { - types: ['file'], - where: ['root'] }; - common.openFilePicker(pickerCfg); - }).appendTo($rightside); + common.initFilePicker(fileDialogCfg); + APP.$mediaTagButton = $('<button>', { + title: Messages.filePickerButton, + 'class': 'cp-toolbar-rightside-button fa fa-picture-o', + style: 'font-size: 17px' + }).click(function () { + var pickerCfg = { + types: ['file'], + where: ['root'] + }; + common.openFilePicker(pickerCfg); + }).appendTo($rightside); + } var $tags = common.createButton('hashtag', true); $rightside.append($tags); diff --git a/www/whiteboard/inner.js b/www/whiteboard/inner.js index d19514b02..4b9528cb7 100644 --- a/www/whiteboard/inner.js +++ b/www/whiteboard/inner.js @@ -470,36 +470,39 @@ define([ .click(function () { $('<input>', {type:'file'}).on('change', onUpload).click(); }).appendTo($rightside); - var fileDialogCfg = { - onSelect: function (data) { - if (data.type === 'file') { - var mt = '<media-tag src="' + data.src + '" data-crypto-key="cryptpad:' + data.key + '"></media-tag>'; - common.displayMediatagImage($(mt), function (err, $image) { - Util.blobURLToImage($image.attr('src'), function (imgSrc) { - var img = new Image(); - img.onload = function () { addImageToCanvas(img); }; - img.src = imgSrc; + + if (common.isLoggedIn()) { + var fileDialogCfg = { + onSelect: function (data) { + if (data.type === 'file') { + var mt = '<media-tag src="' + data.src + '" data-crypto-key="cryptpad:' + data.key + '"></media-tag>'; + common.displayMediatagImage($(mt), function (err, $image) { + Util.blobURLToImage($image.attr('src'), function (imgSrc) { + var img = new Image(); + img.onload = function () { addImageToCanvas(img); }; + img.src = imgSrc; + }); }); - }); - return; - } - } - }; - common.initFilePicker(fileDialogCfg); - APP.$mediaTagButton = $('<button>', { - title: Messages.filePickerButton, - 'class': 'cp-toolbar-rightside-button fa fa-picture-o', - style: 'font-size: 17px' - }).click(function () { - var pickerCfg = { - types: ['file'], - where: ['root'], - filter: { - fileType: ['image/'] + return; + } } }; - common.openFilePicker(pickerCfg); - }).appendTo($rightside); + common.initFilePicker(fileDialogCfg); + APP.$mediaTagButton = $('<button>', { + title: Messages.filePickerButton, + 'class': 'cp-toolbar-rightside-button fa fa-picture-o', + style: 'font-size: 17px' + }).click(function () { + var pickerCfg = { + types: ['file'], + where: ['root'], + filter: { + fileType: ['image/'] + } + }; + common.openFilePicker(pickerCfg); + }).appendTo($rightside); + } } metadataMgr.onChange(function () { From 47e4ce623a62b2ac5eaa0be7461175e8b401a841 Mon Sep 17 00:00:00 2001 From: yflory <yann.flory@xwiki.com> Date: Fri, 15 Dec 2017 18:27:13 +0100 Subject: [PATCH 7/7] Fix import pads from anon drive at registration --- www/common/mergeDrive.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/www/common/mergeDrive.js b/www/common/mergeDrive.js index ba831ab56..c51428b2a 100644 --- a/www/common/mergeDrive.js +++ b/www/common/mergeDrive.js @@ -105,7 +105,8 @@ define([ if (parsed) { var proxy = proxyData.proxy; var oldFo = FO.init(parsed.drive, { - loggedIn: proxyData.loggedIn + loggedIn: proxyData.loggedIn, + pinPads: function () {} // without pinPads /outer/userObject.js won't be loaded }); var onMigrated = function () { oldFo.fixFiles();