From 405526cfa56542ed5919890bd94a503626519962 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Gl=C3=A4=C3=9Fle?= Date: Thu, 10 Aug 2017 01:15:10 +0200 Subject: [PATCH 01/12] Properly escape sed replace expressions This fixes an error during container startup due to interpolating a $STORAGE value that may contain slashes or other "active" characters: ... Using secure websockets: false Using storage adapter: ./storage/file sed: bad option in substitution expression Also add a trailing ',' in the search expression to avoid substituting in the comment above the actual definition: /* If Cryptpad is proxied without using https, the server needs to know. * Specify 'useSecureWebsockets: true' so that it can send ... --- container-start.sh | 11 ++++++++--- docs/cryptpad-docker.md | 9 --------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/container-start.sh b/container-start.sh index 2aa4ae10f..990a83cd2 100755 --- a/container-start.sh +++ b/container-start.sh @@ -9,15 +9,20 @@ mkdir -p customize # Linking config.js [ ! -h config.js ] && echo "Linking config.js" && ln -s customize/config.js config.js +# Thanks to http://stackoverflow.com/a/10467453 +sedeasy() { + sed -i "s/$1/$(echo $2 | sed -e 's/[\/&]/\\&/g')/g" $3 +} + # Configure [ -n "$USE_SSL" ] && echo "Using secure websockets: $USE_SSL" \ - && sed -i "s/useSecureWebsockets: .*/useSecureWebsockets: ${USE_SSL},/g" customize/config.js + && sedeasy "useSecureWebsockets: [^,]*," "useSecureWebsockets: ${USE_SSL}," customize/config.js [ -n "$STORAGE" ] && echo "Using storage adapter: $STORAGE" \ - && sed -i "s/storage: .*/storage: ${STORAGE},/g" customize/config.js + && sedeasy "storage: [^,]*," "storage: ${STORAGE}," customize/config.js [ -n "$LOG_TO_STDOUT" ] && echo "Logging to stdout: $LOG_TO_STDOUT" \ - && sed -i "s/logToStdout: .*/logToStdout: ${LOG_TO_STDOUT},/g" customize/config.js + && sedeasy "logToStdout: [^,]*," "logToStdout: ${LOG_TO_STDOUT}," customize/config.js exec node ./server.js diff --git a/docs/cryptpad-docker.md b/docs/cryptpad-docker.md index d329f0354..027792c2e 100644 --- a/docs/cryptpad-docker.md +++ b/docs/cryptpad-docker.md @@ -22,15 +22,6 @@ Or, using docker-compose docker-compose up -d ``` -## TODO - -``` -cryptpad_1 | Linking config.js -cryptpad_1 | Using secure websockets: true -cryptpad_1 | Using storage adapter: './storage/file' -cryptpad_1 | sed: -e expression #1, char 27: unknown option to `s' -``` - ## Configuration Set configurations Dockerfile or in .env (using docker-compose) file. From 5b7d1cccd7b148a7d2684dc52b08c38347d06e65 Mon Sep 17 00:00:00 2001 From: ansuz Date: Wed, 16 Aug 2017 15:32:42 +0200 Subject: [PATCH 02/12] fix display and logic for tab setting checkbox --- www/settings/main.js | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/www/settings/main.js b/www/settings/main.js index c36e6cf0c..bc65e10fa 100644 --- a/www/settings/main.js +++ b/www/settings/main.js @@ -176,7 +176,8 @@ define([ var $inputBlock = $('
', { 'class': 'inputBlock', - }).appendTo($div); + }).css('flex-flow', 'column') + .appendTo($div); var $input = $('', { type: 'checkbox', @@ -186,16 +187,9 @@ define([ proxy[key] = val; }).appendTo($inputBlock); - proxy.on('change', [key], function (o, n) { $input.val(n); }); + $input[0].checked = !!proxy[key]; + proxy.on('change', [key], function (o, n) { $input[0].checked = !!n; }); - Cryptpad.getAttribute('indentUnit', function (e, val) { - if (e) { return void console.error(e); } - if (typeof(val) !== 'number') { - $input.val(2); - } else { - $input.val(val); - } - }); return $div; }; From 3b1342247a5345902e62415b540596db33cf6634 Mon Sep 17 00:00:00 2001 From: CatalinScr Date: Fri, 18 Aug 2017 16:23:09 +0300 Subject: [PATCH 03/12] Changed the social media links for Pierre --- customize.dist/pages.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/customize.dist/pages.js b/customize.dist/pages.js index 9e2759786..82e122ab4 100644 --- a/customize.dist/pages.js +++ b/customize.dist/pages.js @@ -188,10 +188,10 @@ define([ h('h3', "Pierre Bondoerffer"), h('hr'), setHTML(h('div#bioPierre'), '

Resident CSS wizard and emoji extraordinaire, Pierre is passionate about anything related to technology. He loves to hack around computers and put parts together.
He is currently studying at 42, where he learns about algorithms, networking, kernel programming and graphics.
As a part of an internship, he joined XWiki SAS and worked on CryptPad to improve user experience. He also maintains the Spanish translation.

'), - h('a.cp-soc-media', { href : 'https://twitter.com/cjdelisle'}, [ + h('a.cp-soc-media', { href : 'https://twitter.com/pbondoer'}, [ h('i.fa.fa-twitter') ]), - h('a.cp-soc-media', { href : 'https://github.com/cjdelisle'}, [ + h('a.cp-soc-media', { href : 'https://github.com/pbondoer'}, [ h('i.fa.fa-github') ]) ]), From a99eb9365e108941a21d13b4c89da56b25cec089 Mon Sep 17 00:00:00 2001 From: ansuz Date: Thu, 24 Aug 2017 17:31:04 +0200 Subject: [PATCH 04/12] correctly set indentation preferences when changing languages --- www/code/main.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/www/code/main.js b/www/code/main.js index a7e6f1447..07f02e6a1 100644 --- a/www/code/main.js +++ b/www/code/main.js @@ -73,7 +73,7 @@ define([ var proxy = Cryptpad.getProxy(); - var updateIndentSettings = function () { + var updateIndentSettings = APP.updateIndentSettings = function () { var indentUnit = proxy[indentKey]; var useTabs = proxy[useTabsKey]; setIndentation( @@ -208,6 +208,9 @@ define([ $previewContainer.hide(); APP.$previewButton.removeClass('active'); $codeMirror.addClass('fullPage'); + if (typeof(APP.updateIndentSettings) === 'function') { + APP.updateIndentSettings(); + } }; config.onInit = function (info) { From 2ef4ebc6ef46d354303fad77261797506939bbb2 Mon Sep 17 00:00:00 2001 From: ansuz Date: Tue, 29 Aug 2017 17:56:34 +0200 Subject: [PATCH 05/12] two new tips for the loading screen --- customize.dist/translations/messages.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/customize.dist/translations/messages.js b/customize.dist/translations/messages.js index 661254f5d..43cbc9b22 100644 --- a/customize.dist/translations/messages.js +++ b/customize.dist/translations/messages.js @@ -695,6 +695,8 @@ define(function () { out.tips.driveUpload = "Registered users can upload encrypted files by dragging and dropping them into their CryptDrive."; out.tips.filenames = "You can rename files in your CryptDrive, this name is just for you."; out.tips.drive = "Logged in users can organize their files in their CryptDrive, accessible from the CryptPad icon at the top left of all pads."; + out.tips.profile = "Registered users can create a profile from the user menu in the top right."; + out.tips.avatars = "You can upload an avatar in your profile. People will see it when you collaborate in a pad."; out.feedback_about = "If you're reading this, you were probably curious why CryptPad is requesting web pages when you perform certain actions"; out.feedback_privacy = "We care about your privacy, and at the same time we want CryptPad to be very easy to use. We use this file to figure out which UI features matter to our users, by requesting it along with a parameter specifying which action was taken."; From a34d1793e0d0f392981b3eb1bb8dd5138f677a45 Mon Sep 17 00:00:00 2001 From: ansuz Date: Tue, 29 Aug 2017 18:15:40 +0200 Subject: [PATCH 06/12] drop 'loading' text from loading screen --- customize.dist/pages.js | 2 +- www/common/loading.js | 9 +-------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/customize.dist/pages.js b/customize.dist/pages.js index 0261c839f..bc50ac22d 100644 --- a/customize.dist/pages.js +++ b/customize.dist/pages.js @@ -410,7 +410,7 @@ define([ }), h('div.spinnerContainer', h('span.fa.fa-circle-o-notch.fa-spin.fa-4x.fa-fw')), - h('p', Msg.loading) + h('p'), ]) ); }; diff --git a/www/common/loading.js b/www/common/loading.js index 41c9365ff..d9c3b8df9 100644 --- a/www/common/loading.js +++ b/www/common/loading.js @@ -18,14 +18,7 @@ define([ if (!document.body) { return; } clearInterval(intr); document.body.appendChild(elem); - require([ - '/customize/messages.js', - - 'css!/bower_components/components-font-awesome/css/font-awesome.min.css', - ], function (Messages) { - document.getElementById('cp-loading-message').innerText = Messages.loading; - }); }; intr = setInterval(append, 100); append(); -}); \ No newline at end of file +}); From 1044531806173a1a0ce39f41af6734196b7d966e Mon Sep 17 00:00:00 2001 From: Caleb James DeLisle Date: Wed, 30 Aug 2017 11:04:52 +0200 Subject: [PATCH 07/12] Fix Safari iframe size issue --- www/pad/inner.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/www/pad/inner.js b/www/pad/inner.js index 48c901d69..28bfd6fa0 100644 --- a/www/pad/inner.js +++ b/www/pad/inner.js @@ -773,11 +773,18 @@ define([ } // Used in ckeditor-config.js Ckeditor.CRYPTPAD_URLARGS = ApiConfig.requireConf.urlArgs; - editor = Ckeditor.replace('editor1', { + module.ckeditor = editor = Ckeditor.replace('editor1', { customConfig: '/customize/ckeditor-config.js', }); editor.on('instanceReady', waitFor()); }).nThen(function (/*waitFor*/) { + if (Ckeditor.env.safari) { + var fixIframe = function () { + $('iframe.cke_wysiwyg_frame').height($('#cke_1_contents').height()); + }; + $(window).resize(fixIframe); + fixIframe(); + } Links.addSupportForOpeningLinksInNewTab(Ckeditor)({editor: editor}); Cryptpad.onError(function (info) { if (info && info.type === "store") { From 7498057c8998c29fdd3b903c4e45ac2dc42b73e6 Mon Sep 17 00:00:00 2001 From: yflory Date: Wed, 30 Aug 2017 11:11:43 +0200 Subject: [PATCH 08/12] Fix Safari iframe size --- customize.dist/src/less/toolbar.less | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/customize.dist/src/less/toolbar.less b/customize.dist/src/less/toolbar.less index cbbbd9dd2..7e28c08d3 100644 --- a/customize.dist/src/less/toolbar.less +++ b/customize.dist/src/less/toolbar.less @@ -43,8 +43,6 @@ right: 0; display: flex; flex-flow: column; - height: 100vh; - width: 100vw; } .cke_toolbox_main { display: inline-block; @@ -56,7 +54,7 @@ display: flex; overflow: visible; iframe { - height: 100%; + min-height: 100%; width: 100%; } } From 4db4f667866da6dee53944e1d3d29589d60e0144 Mon Sep 17 00:00:00 2001 From: yflory Date: Wed, 30 Aug 2017 11:14:58 +0200 Subject: [PATCH 09/12] Remove an unnecessary fix for Safari --- www/pad/inner.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/www/pad/inner.js b/www/pad/inner.js index 28bfd6fa0..badb215fa 100644 --- a/www/pad/inner.js +++ b/www/pad/inner.js @@ -778,13 +778,13 @@ define([ }); editor.on('instanceReady', waitFor()); }).nThen(function (/*waitFor*/) { - if (Ckeditor.env.safari) { + /*if (Ckeditor.env.safari) { var fixIframe = function () { $('iframe.cke_wysiwyg_frame').height($('#cke_1_contents').height()); }; $(window).resize(fixIframe); fixIframe(); - } + }*/ Links.addSupportForOpeningLinksInNewTab(Ckeditor)({editor: editor}); Cryptpad.onError(function (info) { if (info && info.type === "store") { From be8ea4102e910da15146f23878cc7e7fb75a4ee8 Mon Sep 17 00:00:00 2001 From: ansuz Date: Wed, 30 Aug 2017 11:26:51 +0200 Subject: [PATCH 10/12] keep trying to parse the hash until it works --- www/common/sframe-boot.js | 60 +++++++++++++++++++++++---------------- www/pad/inner.html | 2 +- 2 files changed, 36 insertions(+), 26 deletions(-) diff --git a/www/common/sframe-boot.js b/www/common/sframe-boot.js index 6ed56cfea..2ff9762b6 100644 --- a/www/common/sframe-boot.js +++ b/www/common/sframe-boot.js @@ -1,30 +1,40 @@ // Stage 0, this gets cached which means we can't change it. boot2-sframe.js is changable. // Note that this file is meant to be executed only inside of a sandbox iframe. ;(function () { -var req = JSON.parse(decodeURIComponent(window.location.hash.substring(1))); -req.cfg = req.cfg || {}; -if (req.pfx) { - req.cfg.onNodeCreated = function (node /*, config, module, path*/) { - node.setAttribute('src', req.pfx + node.getAttribute('src')); +var afterLoaded = function (req) { + req.cfg = req.cfg || {}; + if (req.pfx) { + req.cfg.onNodeCreated = function (node /*, config, module, path*/) { + node.setAttribute('src', req.pfx + node.getAttribute('src')); + }; + } + require.config(req.cfg); + var txid = Math.random().toString(16).replace('0.', ''); + var intr; + var ready = function () { + intr = setInterval(function () { + if (typeof(txid) !== 'string') { return; } + window.parent.postMessage(JSON.stringify({ q: 'READY', txid: txid }), '*'); + }, 1); }; -} -require.config(req.cfg); -var txid = Math.random().toString(16).replace('0.', ''); -var intr; -var ready = function () { - intr = setInterval(function () { - if (typeof(txid) !== 'string') { return; } - window.parent.postMessage(JSON.stringify({ q: 'READY', txid: txid }), '*'); - }, 1); -}; -if (req.req) { require(req.req, ready); } else { ready(); } -var onReply = function (msg) { - var data = JSON.parse(msg.data); - if (data.txid !== txid) { return; } - clearInterval(intr); - txid = {}; - window.removeEventListener('message', onReply); - require(['/common/sframe-boot2.js'], function () { }); + if (req.req) { require(req.req, ready); } else { ready(); } + var onReply = function (msg) { + var data = JSON.parse(msg.data); + if (data.txid !== txid) { return; } + clearInterval(intr); + txid = {}; + window.removeEventListener('message', onReply); + require(['/common/sframe-boot2.js'], function () { }); + }; + window.addEventListener('message', onReply); }; -window.addEventListener('message', onReply); -}()); \ No newline at end of file + +var intr = setInterval(function () { + try { + var req = JSON.parse(decodeURIComponent(window.location.hash.substring(1))); + clearInterval(intr); + afterLoaded(req); + } catch (e) { console.error(e); } +}, 100); + +}()); diff --git a/www/pad/inner.html b/www/pad/inner.html index b9d3645a5..aa487deac 100644 --- a/www/pad/inner.html +++ b/www/pad/inner.html @@ -2,7 +2,7 @@ - +