From 2897a14869dd73152e784e938b66bf430f41372c Mon Sep 17 00:00:00 2001 From: Caleb James DeLisle Date: Fri, 13 Apr 2018 17:49:17 +0200 Subject: [PATCH 1/8] Expose the datastore as an http endpoint --- server.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/server.js b/server.js index 1ff289f64..aac8d7513 100644 --- a/server.js +++ b/server.js @@ -123,6 +123,9 @@ app.get(mainPagePattern, Express.static(__dirname + '/customize.dist')); app.use("/blob", Express.static(Path.join(__dirname, (config.blobPath || './blob')), { maxAge: DEV_MODE? "0d": "365d" })); +app.use("/datastore", Express.static(Path.join(__dirname, (config.filePath || './datastore')), { + maxAge: "0d" +})); app.use("/customize", Express.static(__dirname + '/customize')); app.use("/customize", Express.static(__dirname + '/customize.dist')); From 3c2d61ff4276b0743108ebcc539cb5217b10bd89 Mon Sep 17 00:00:00 2001 From: Caleb James DeLisle Date: Fri, 13 Apr 2018 18:14:01 +0200 Subject: [PATCH 2/8] Add to the nginx documentation the location datastore block --- docs/example.nginx.conf | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/example.nginx.conf b/docs/example.nginx.conf index d56920bf5..44b12ade8 100644 --- a/docs/example.nginx.conf +++ b/docs/example.nginx.conf @@ -75,6 +75,12 @@ server { } location ^~ /blob/ { + add_header Cache-Control max-age=31536000; + try_files $uri =404; + } + + location ^~ /datastore/ { + add_header Cache-Control max-age=0; try_files $uri =404; } From d6504e4610a2bf7cd7c2adb6710724adcbd8b853 Mon Sep 17 00:00:00 2001 From: Caleb James DeLisle Date: Wed, 18 Apr 2018 14:02:49 +0200 Subject: [PATCH 3/8] Upgrade chainpad --- bower.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bower.json b/bower.json index e2763ccfd..809fd5323 100644 --- a/bower.json +++ b/bower.json @@ -31,7 +31,7 @@ "hyperjson": "~1.4.0", "chainpad-crypto": "^0.1.8", "chainpad-listmap": "^0.5.0", - "chainpad": "^5.0.0", + "chainpad": "^5.1.0", "chainpad-netflux": "^0.7.0", "file-saver": "1.3.1", "alertifyjs": "1.0.11", From 5c2ee778adab8c11d2991f26810d690cebeac823 Mon Sep 17 00:00:00 2001 From: yflory Date: Wed, 18 Apr 2018 18:50:46 +0200 Subject: [PATCH 4/8] Initialize new users' drive to the latest version --- customize.dist/login.js | 1 + 1 file changed, 1 insertion(+) diff --git a/customize.dist/login.js b/customize.dist/login.js index 1f8cebab5..dd40ad831 100644 --- a/customize.dist/login.js +++ b/customize.dist/login.js @@ -154,6 +154,7 @@ define([ proxy.login_name = uname; proxy[Constants.displayNameKey] = uname; sessionStorage.createReadme = 1; + if (!shouldImport) { proxy.version = 5; } Feedback.send('REGISTRATION', true); } else { Feedback.send('LOGIN', true); From caf86dd9b7eb4ac48a8095c49a4c1b99681d061a Mon Sep 17 00:00:00 2001 From: yflory Date: Wed, 18 Apr 2018 18:51:49 +0200 Subject: [PATCH 5/8] Improve static pages UI --- customize.dist/src/less2/include/infopages.less | 17 ++++++++++++++--- .../src/less2/pages/page-register.less | 6 +----- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/customize.dist/src/less2/include/infopages.less b/customize.dist/src/less2/include/infopages.less index b07b90aa8..4282b3499 100644 --- a/customize.dist/src/less2/include/infopages.less +++ b/customize.dist/src/less2/include/infopages.less @@ -161,6 +161,7 @@ background-size: contain; height: 50px; width: 250px; + margin-right: 0; } a { border: 2px solid transparent; @@ -169,7 +170,8 @@ .nav-link { padding: 0.5em 0.7em; &:hover { - transform: scale(1.05); + font-size: 1.05em; + //transform: scale(1.05); }; } .cp-register-btn { @@ -184,9 +186,18 @@ color: #4591C4; } } -@media (max-width: 991px) { +@media (max-width: 1000px) { #menuCollapse { text-align: right; +/* @media (min-width: 576px) { + top: 100%; + background: rgba(255,255,255,0.8); + position: absolute; + right: 0px; + padding: 0 20px; + z-index: 1; + } +*/ } .navbar-nav a { text-align: right !important; @@ -194,7 +205,7 @@ .cp-register-btn { margin-right: 13px; text-align: center; - } + } } //footer general styles diff --git a/customize.dist/src/less2/pages/page-register.less b/customize.dist/src/less2/pages/page-register.less index 6336c6aa3..e8f49a850 100644 --- a/customize.dist/src/less2/pages/page-register.less +++ b/customize.dist/src/less2/pages/page-register.less @@ -23,11 +23,7 @@ } margin-top: 16px; font-size: 1.25em; - min-width: 30%; // conflict? - width: 30%; - @media (max-width: 500px) { - width: 45%; - } + min-width: 30%; } } padding-bottom: 3em; From 1f3f4941b5c407faabded279457275cd4ac6f2b2 Mon Sep 17 00:00:00 2001 From: yflory Date: Wed, 18 Apr 2018 18:53:36 +0200 Subject: [PATCH 6/8] Redirect to drive anonymous users trying to create a profile --- www/profile/main.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/www/profile/main.js b/www/profile/main.js index 2449ea96b..c4b3847a4 100644 --- a/www/profile/main.js +++ b/www/profile/main.js @@ -53,7 +53,11 @@ define([ return void cb(null, Hash.getSecrets('profile', editHash)); } // 3rd case: profile creation (create a new random hash, store it later if needed) - if (!Utils.LocalStore.isLoggedIn()) { return void cb(); } + if (!Utils.LocalStore.isLoggedIn()) { + // Unregistered users can't create a profile + window.location.href = '/drive'; + return void cb(); + } var hash = Hash.createRandomHash(); var secret = Hash.getSecrets('profile', hash); Cryptpad.pinPads([secret.channel], function (e) { From a0d452bbd9091d9d5292bac36ff8e2fb4d8a8c8d Mon Sep 17 00:00:00 2001 From: yflory Date: Wed, 18 Apr 2018 18:54:05 +0200 Subject: [PATCH 7/8] Use correct icons for the search results in the drive --- www/drive/inner.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/drive/inner.js b/www/drive/inner.js index ae0328491..df9708d97 100644 --- a/www/drive/inner.js +++ b/www/drive/inner.js @@ -2096,7 +2096,7 @@ define([ var parsed = Hash.parsePadUrl(href); var $table = $(''); var $icon = $('
', {'rowspan': '3', 'class': 'cp-app-drive-search-icon'}) - .append(getFileIcon(href)); + .append(getFileIcon(r.id)); var $title = $('', { 'class': 'cp-app-drive-search-col1 cp-app-drive-search-title' }).text(r.data.title) From 206ac144380bea625463760d5a3261ef3c6e4cdc Mon Sep 17 00:00:00 2001 From: yflory Date: Wed, 18 Apr 2018 18:54:46 +0200 Subject: [PATCH 8/8] Prevent users from creating a pad when visiting a deleted profile (read-only mode) --- customize.dist/translations/messages.fr.js | 1 + customize.dist/translations/messages.js | 1 + www/common/sframe-common-outer.js | 6 ++++++ www/common/sframe-common.js | 9 +++++++++ www/common/sframe-protocol.js | 3 +++ 5 files changed, 20 insertions(+) diff --git a/customize.dist/translations/messages.fr.js b/customize.dist/translations/messages.fr.js index 05845a83c..86f960bcb 100644 --- a/customize.dist/translations/messages.fr.js +++ b/customize.dist/translations/messages.fr.js @@ -37,6 +37,7 @@ define(function () { out.chainpadError = 'Une erreur critique est survenue lors de la mise à jour du contenu. Le pad est désormais en mode lecture seule afin de s\'assurer que vous ne perdiez pas davantage de données.
' + 'Appuyez sur Échap pour voir le pad ou rechargez la page pour pouvoir le modifier à nouveau.'; out.errorCopy = ' Vous pouvez toujours copier son contenu ailleurs en appuyant sur Échap.
Dés que vous aurez quitté la page, il sera impossible de le récupérer.'; + out.errorRedirectToHome = 'Appuyez sur Échap pour retourner vers votre CryptDrive.'; out.loading = "Chargement..."; out.error = "Erreur"; diff --git a/customize.dist/translations/messages.js b/customize.dist/translations/messages.js index ce2868783..ddaa1158f 100644 --- a/customize.dist/translations/messages.js +++ b/customize.dist/translations/messages.js @@ -38,6 +38,7 @@ define(function () { out.chainpadError = 'A critical error occurred when updating your content. This page is in read-only mode to make sure you won\'t lose your work.
' + 'Hit Esc to continue to view this pad, or reload to try editing again.'; out.errorCopy = ' You can still copy the content to another location by pressing Esc.
Once you leave this page, it will disappear forever!'; + out.errorRedirectToHome = 'Press Esc to be redirected to your CryptDrive.'; out.loading = "Loading..."; out.error = "Error"; diff --git a/www/common/sframe-common-outer.js b/www/common/sframe-common-outer.js index fab9dfcfd..11d20ce56 100644 --- a/www/common/sframe-common-outer.js +++ b/www/common/sframe-common-outer.js @@ -650,6 +650,12 @@ define([ Cryptpad.getMetadata(waitFor(function (err, m) { cpNfCfg.owners = [m.priv.edPublic]; })); + } else if (isNewFile && !cfg.useCreationScreen && window.location.hash) { + console.log("new file with hash in the address bar in an app without pcs and which requires owners"); + sframeChan.onReady(function () { + sframeChan.query("EV_LOADING_ERROR", "DELETED"); + }); + waitFor.abort(); } }).nThen(function () { Object.keys(rtConfig).forEach(function (k) { diff --git a/www/common/sframe-common.js b/www/common/sframe-common.js index c909c01f2..ab3c2389d 100644 --- a/www/common/sframe-common.js +++ b/www/common/sframe-common.js @@ -435,6 +435,15 @@ define([ Feedback.init(feedback); } catch (e) { Feedback.init(false); } + ctx.sframeChan.on('EV_LOADING_ERROR', function (err) { + if (err === 'DELETED') { + var msg = Messages.deletedError + '
' + Messages.errorRedirectToHome; + UI.errorLoadingScreen(msg, false, function () { + funcs.gotoURL('/drive/'); + }); + } + }); + ctx.sframeChan.on('EV_LOGOUT', function () { $(window).on('keyup', function (e) { if (e.keyCode === 27) { diff --git a/www/common/sframe-protocol.js b/www/common/sframe-protocol.js index 4c3046ad9..8142694ce 100644 --- a/www/common/sframe-protocol.js +++ b/www/common/sframe-protocol.js @@ -227,4 +227,7 @@ define({ // This is for sending data out of the iframe when we are in testing mode // The exact protocol is defined in common/test.js 'EV_TESTDATA': true, + + // Critical error outside the iframe during loading screen + 'EV_LOADING_ERROR': true, });