From 538aec6ef5639f583a7ed9ce9b5cbf085c846537 Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 22 May 2017 10:41:47 +0200 Subject: [PATCH 1/3] Display a message when pinPads returns an error --- customize.dist/translations/messages.fr.js | 1 + customize.dist/translations/messages.js | 1 + www/common/userObject.js | 5 ++++- www/drive/main.js | 9 ++++++--- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/customize.dist/translations/messages.fr.js b/customize.dist/translations/messages.fr.js index 5db44bf2d..2302a1d62 100644 --- a/customize.dist/translations/messages.fr.js +++ b/customize.dist/translations/messages.fr.js @@ -247,6 +247,7 @@ define(function () { 'nos raisons pour ces changements et pourquoi vous devriez vraiment vous enregistrer et vous connecter.'; out.fm_backup_title = 'Lien de secours'; out.fm_nameFile = 'Comment souhaitez-vous nommer ce fichier ?'; + out.fm_error_cantPin = "Erreur interne du serveur. Veuillez recharger la page et essayer de nouveau."; // File - Context menu out.fc_newfolder = "Nouveau dossier"; out.fc_rename = "Renommer"; diff --git a/customize.dist/translations/messages.js b/customize.dist/translations/messages.js index 8a1de05a5..69e9cc3c2 100644 --- a/customize.dist/translations/messages.js +++ b/customize.dist/translations/messages.js @@ -249,6 +249,7 @@ define(function () { 'why we are doing this and why you really should Sign up and Log in.'; out.fm_backup_title = 'Backup link'; out.fm_nameFile = 'How would you like to name that file?'; + out.fm_error_cantPin = "Internal server error. Please reload the page and try again."; // File - Context menu out.fc_newfolder = "New folder"; out.fc_rename = "Rename"; diff --git a/www/common/userObject.js b/www/common/userObject.js index 51840dca5..1559397d0 100644 --- a/www/common/userObject.js +++ b/www/common/userObject.js @@ -575,7 +575,10 @@ define([ atime: +new Date(), ctime: +new Date() }, function (err) { - if (err) { return void cb(err); } + if (err) { + logError(err); + return void cb(err); + } parentEl[fileName] = href; var newPath = filePath.slice(); newPath.push(fileName); diff --git a/www/drive/main.js b/www/drive/main.js index a85c86e47..861136454 100644 --- a/www/drive/main.js +++ b/www/drive/main.js @@ -1397,8 +1397,11 @@ define([ // Handlers if (isInRoot) { var onCreated = function (err, info) { - if (err && err === E_OVER_LIMIT) { - return void Cryptpad.alert(Messages.pinLimitDrive, null, true); + if (err) { + if (err === E_OVER_LIMIT) { + return void Cryptpad.alert(Messages.pinLimitDrive, null, true); + } + return void Cryptpad.alert(Messages.fm_error_cantPin); } module.newFolder = info.newPath; refresh(); @@ -2361,7 +2364,7 @@ define([ return void Cryptpad.alert(Messages.pinLimitDrive, null, true); } if (err) { - return void console.error("Unable to create the file", err); + return void Cryptpad.alert(Messages.fm_error_cantPin); } module.newFolder = info.newPath; refresh(); From 0c2f84058b1c857a593d159c951eb86fe42dfeef Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 22 May 2017 11:16:01 +0200 Subject: [PATCH 2/3] Improve css for the file app --- customize.dist/src/less/cryptpad.less | 9 +++++++++ rpc.js | 2 +- www/file/file.css | 17 ++++++++++------- www/file/file.less | 19 +++++++++++-------- www/file/inner.html | 4 +++- www/file/main.js | 9 ++++----- 6 files changed, 38 insertions(+), 22 deletions(-) diff --git a/customize.dist/src/less/cryptpad.less b/customize.dist/src/less/cryptpad.less index 883e62ce4..0ee8785e6 100644 --- a/customize.dist/src/less/cryptpad.less +++ b/customize.dist/src/less/cryptpad.less @@ -43,6 +43,15 @@ a.github-corner > svg { font-size: 1.02em; } +.unselectable { + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + h1,h2,h3,h4,h5,h6 { color: @fore; diff --git a/rpc.js b/rpc.js index a155c8272..e7d3c1627 100644 --- a/rpc.js +++ b/rpc.js @@ -13,7 +13,7 @@ var RPC = module.exports; var Store = require("./storage/file"); -var DEFAULT_LIMIT = 150 * 1024 * 1024; +var DEFAULT_LIMIT = 50 * 1024 * 1024; var isValidId = function (chan) { return /^[a-fA-F0-9]/.test(chan) || diff --git a/www/file/file.css b/www/file/file.css index 375a356cc..f2fd8e6d5 100644 --- a/www/file/file.css +++ b/www/file/file.css @@ -9,10 +9,9 @@ body { } #file { display: block; - height: 300px; - width: 300px; + height: 100%; + width: 100%; border: 2px solid black; - margin: 50px; } .inputfile { width: 0.1px; @@ -29,18 +28,23 @@ body { width: 50vh; height: 50vh; display: block; - margin: auto; + margin: 50px auto; + max-width: 80vw; } #upload-form label { + line-height: 50vh; + text-align: center; position: relative; + padding: 10px; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; } .hovering { background-color: rgba(255, 0, 115, 0.5) !important; } .block { display: block; - height: 50vh; - width: 50vh; } .hidden { display: none; @@ -48,7 +52,6 @@ body { .inputfile + label { border: 2px solid black; background-color: rgba(50, 50, 50, 0.1); - margin: 50px; display: block; } .inputfile:focus + label, diff --git a/www/file/file.less b/www/file/file.less index b3074e33c..db6942596 100644 --- a/www/file/file.less +++ b/www/file/file.less @@ -11,10 +11,9 @@ html, body { } #file { display: block; - height: 300px; - width: 300px; + height: 100%; + width: 100%; border: 2px solid black; - margin: 50px; } .inputfile { @@ -34,10 +33,17 @@ html, body { width: 50vh; height: 50vh; display: block; - margin: auto; + margin: 50px auto; + max-width: 80vw; } -#upload-form label{ +#upload-form label { + line-height: 50vh; + text-align: center; position: relative; + padding: 10px; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; } .hovering { @@ -46,8 +52,6 @@ html, body { .block { display: block; - height: 50vh; - width: 50vh; } .hidden { display: none; @@ -55,7 +59,6 @@ html, body { .inputfile + label { border: 2px solid black; background-color: rgba(50, 50, 50, .10); - margin: 50px; display: block; } diff --git a/www/file/inner.html b/www/file/inner.html index c6fe5fb32..548ac6a47 100644 --- a/www/file/inner.html +++ b/www/file/inner.html @@ -6,12 +6,14 @@ +
diff --git a/www/file/main.js b/www/file/main.js index ada0b50d2..56b46b1dd 100644 --- a/www/file/main.js +++ b/www/file/main.js @@ -181,11 +181,10 @@ define([ $tr.find('.progressValue').text(Messages.upload_cancelled); }); - var $tr2 = $('', {id: id}).appendTo($table); - $('
').text(obj.metadata.name).appendTo($tr2); - $('').text(prettySize(estimate)).appendTo($tr2); - $('', {'class': 'upProgress'}).append($progressBar).append($progressValue).appendTo($tr2); - $('', {'class': 'upCancel'}).append($cancel).appendTo($tr2); + $('').text(obj.metadata.name).appendTo($tr); + $('').text(prettySize(estimate)).appendTo($tr); + $('', {'class': 'upProgress'}).append($progressBar).append($progressValue).appendTo($tr); + $('', {'class': 'upCancel'}).append($cancel).appendTo($tr); queue.next(); }; From c45f08f14755ba3ec79e4c87c129f1d5c001b746 Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 22 May 2017 11:43:45 +0200 Subject: [PATCH 3/3] Use a download button instead of downloading a file automatically --- customize.dist/main.css | 8 ++++ customize.dist/translations/messages.fr.js | 1 + customize.dist/translations/messages.js | 1 + www/file/file.css | 9 ++-- www/file/file.less | 23 +++++----- www/file/inner.html | 9 +++- www/file/main.js | 53 ++++++++++++---------- 7 files changed, 64 insertions(+), 40 deletions(-) diff --git a/customize.dist/main.css b/customize.dist/main.css index 6ec0172ea..063324504 100644 --- a/customize.dist/main.css +++ b/customize.dist/main.css @@ -603,6 +603,14 @@ html.cp, font-family: lato, Helvetica, sans-serif; font-size: 1.02em; } +.cp .unselectable { + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} .cp h1, .cp h2, .cp h3, diff --git a/customize.dist/translations/messages.fr.js b/customize.dist/translations/messages.fr.js index a475dba00..6499258e0 100644 --- a/customize.dist/translations/messages.fr.js +++ b/customize.dist/translations/messages.fr.js @@ -366,6 +366,7 @@ define(function () { out.upload_name = "Nom du fichier"; out.upload_size = "Taille"; out.upload_progress = "État"; + out.download_button = "Déchiffrer et télécharger"; // general warnings out.warn_notPinned = "Ce pad n'est stocké dans aucun CryptDrive. Il va expirer après 3 mois d'inactivité. En savoir plus..."; diff --git a/customize.dist/translations/messages.js b/customize.dist/translations/messages.js index fd99ba7b7..737b271c9 100644 --- a/customize.dist/translations/messages.js +++ b/customize.dist/translations/messages.js @@ -371,6 +371,7 @@ define(function () { out.upload_name = "File name"; out.upload_size = "Size"; out.upload_progress = "Progress"; + out.download_button = "Decrypt & Download"; // general warnings out.warn_notPinned = "This pad is not in anyone's CryptDrive. It will expire after 3 months. Learn more..."; diff --git a/www/file/file.css b/www/file/file.css index f2fd8e6d5..6554a77f0 100644 --- a/www/file/file.css +++ b/www/file/file.css @@ -7,7 +7,8 @@ body { padding: 0px; display: inline-block; } -#file { +#file, +#dl { display: block; height: 100%; width: 100%; @@ -21,7 +22,8 @@ body { position: absolute; z-index: -1; } -#upload-form { +#upload-form, +#download-form { padding: 0px; margin: 0px; position: relative; @@ -31,7 +33,8 @@ body { margin: 50px auto; max-width: 80vw; } -#upload-form label { +#upload-form label, +#download-form label { line-height: 50vh; text-align: center; position: relative; diff --git a/www/file/file.less b/www/file/file.less index db6942596..a7da1bb3e 100644 --- a/www/file/file.less +++ b/www/file/file.less @@ -9,7 +9,7 @@ html, body { padding: 0px; display: inline-block; } -#file { +#file, #dl { display: block; height: 100%; width: 100%; @@ -25,7 +25,7 @@ html, body { z-index: -1; } -#upload-form { +#upload-form, #download-form { padding: 0px; margin: 0px; @@ -35,17 +35,16 @@ html, body { display: block; margin: 50px auto; max-width: 80vw; + label { + line-height: 50vh; + text-align: center; + position: relative; + padding: 10px; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + } } -#upload-form label { - line-height: 50vh; - text-align: center; - position: relative; - padding: 10px; - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; -} - .hovering { background-color: rgba(255, 0, 115, 0.5) !important; } diff --git a/www/file/inner.html b/www/file/inner.html index 548ac6a47..a9660b2d3 100644 --- a/www/file/inner.html +++ b/www/file/inner.html @@ -13,9 +13,14 @@ - + +
diff --git a/www/file/main.js b/www/file/main.js index 56b46b1dd..3c25ec070 100644 --- a/www/file/main.js +++ b/www/file/main.js @@ -21,8 +21,9 @@ define([ var ifrw = $('#pad-iframe')[0].contentWindow; var $iframe = $('#pad-iframe').contents(); var $form = $iframe.find('#upload-form'); - //var $progress = $form.find('#progress'); + var $dlform = $iframe.find('#download-form'); var $label = $form.find('label'); + var $dllabel = $dlform.find('label'); var $table = $iframe.find('#status'); Cryptpad.addLoadingScreen(); @@ -100,8 +101,6 @@ define([ var b64Key = Nacl.util.encodeBase64(key); Cryptpad.replaceHash(Cryptpad.getFileHashFromKeys(id, b64Key)); - //$form.hide(); - APP.toolbar.addElement(['fileshare'], {}); var title = document.title = metadata.name; @@ -250,30 +249,38 @@ define([ Title.updateTitle(Cryptpad.initialName || getTitle() || Title.defaultTitle); if (!uploadMode) { - var src = Cryptpad.getBlobPathFromHex(hexFileName); - return Cryptpad.fetch(src, function (e, u8) { - if (e) { return void Cryptpad.alert(e); } - // now decrypt the u8 - var cryptKey = secret.keys && secret.keys.fileKeyStr; - var key = Nacl.util.decodeBase64(cryptKey); - - if (!u8 || !u8.length) { - return void Cryptpad.errorLoadingScreen(e); - } + $dlform.show(); + Cryptpad.removeLoadingScreen(); + $dlform.find('#dl').click(function (e) { + + if (myFile) { exportFile(); } - FileCrypto.decrypt(u8, key, function (e, data) { - if (e) { - Cryptpad.removeLoadingScreen(); - return console.error(e); + var src = Cryptpad.getBlobPathFromHex(hexFileName); + return Cryptpad.fetch(src, function (e, u8) { + if (e) { return void Cryptpad.alert(e); } + // now decrypt the u8 + var cryptKey = secret.keys && secret.keys.fileKeyStr; + var key = Nacl.util.decodeBase64(cryptKey); + + if (!u8 || !u8.length) { + return void Cryptpad.errorLoadingScreen(e); } - console.log(data); - var title = document.title = data.metadata.name; - myFile = data.content; - myDataType = data.metadata.type; - Title.updateTitle(title || Title.defaultTitle); - Cryptpad.removeLoadingScreen(); + + FileCrypto.decrypt(u8, key, function (e, data) { + if (e) { + return console.error(e); + } + console.log(data); + var title = document.title = data.metadata.name; + myFile = data.content; + myDataType = data.metadata.type; + Title.updateTitle(title || Title.defaultTitle); + exportFile(); + }); }); + }); + return; } if (!Cryptpad.isLoggedIn()) {