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/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/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%; } } 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."; 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. 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) { diff --git a/www/common/LessLoader.js b/www/common/LessLoader.js index b25db9418..61cacfbeb 100644 --- a/www/common/LessLoader.js +++ b/www/common/LessLoader.js @@ -10,7 +10,13 @@ define([ var module = { exports: {} }; var key = Config.requireConf.urlArgs; - var localStorage = window.localStorage || {}; + var localStorage; + try { + localStorage = window.localStorage || {}; + } catch (e) { + console.error(e); + localStorage = {}; + } var fixURL = function (url) { var mark = (url.indexOf('?') !== -1) ? '&' : '?'; diff --git a/www/common/common-userlist.js b/www/common/common-userlist.js index e7f2449fa..1d80e792c 100644 --- a/www/common/common-userlist.js +++ b/www/common/common-userlist.js @@ -1,4 +1,4 @@ -define(function () { +define(['json.sortify'], function (Sortify) { var module = {}; module.create = function (info, onLocal, Cryptget, Cryptpad) { @@ -15,6 +15,7 @@ define(function () { var parsed = Cryptpad.parsePadUrl(window.location.href); var appType = parsed ? parsed.type : undefined; + var oldUserData = {}; var addToUserData = exp.addToUserData = function(data) { var users = userList.users; for (var attrname in data) { userData[attrname] = data[attrname]; } @@ -28,6 +29,10 @@ define(function () { } if(userList && typeof userList.onChange === "function") { + // Make sure we don't update the userlist everytime someone makes a change to the pad + if (Sortify(oldUserData) === Sortify(userData)) { return; } + oldUserData = JSON.parse(JSON.stringify(userData)); + userList.onChange(userData); } }; diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index 3855f6c09..c71fdd715 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -1794,12 +1794,15 @@ define([ }; var $userAdmin = createDropdown(dropdownConfigUser); + var oldUrl; if (account && !config.static && store) { var $avatar = $userAdmin.find('.buttonTitle'); var updateButton = function (newName) { var profile = store.getProfile(); var url = profile && profile.avatar; + if (oldUrl === url) { return; } + oldUrl = url; $avatar.html(''); common.displayAvatar($avatar, url, newName, function ($img) { if ($img) { 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 +}); diff --git a/www/common/metadata-manager.js b/www/common/metadata-manager.js index c7fc85924..1c8994d00 100644 --- a/www/common/metadata-manager.js +++ b/www/common/metadata-manager.js @@ -1,4 +1,4 @@ -define([], function () { +define(['json.sortify'], function (Sortify) { var UNINIT = 'uninitialized'; var create = function (sframeChan) { var meta = UNINIT; @@ -102,7 +102,9 @@ define([], function () { return Object.freeze({ updateMetadata: function (m) { - if (JSON.stringify(metadataObj) === JSON.stringify(m)) { return; } + // JSON.parse(JSON.stringify()) reorders the json, so we have to use sortify even + // if it's on our own computer + if (Sortify(metadataLazyObj) === Sortify(m)) { return; } metadataObj = JSON.parse(JSON.stringify(m)); metadataLazyObj = JSON.parse(JSON.stringify(m)); change(false); diff --git a/www/common/sframe-boot.js b/www/common/sframe-boot.js index 19fca4823..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); + +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/common/sframe-common-interface.js b/www/common/sframe-common-interface.js index eb4bc35a5..f0f3a7da0 100644 --- a/www/common/sframe-common-interface.js +++ b/www/common/sframe-common-interface.js @@ -208,15 +208,17 @@ define([ var $displayName = $userAdmin.find('.'+displayNameCls); var $avatar = $userAdmin.find('.buttonTitle'); + var oldUrl; var updateButton = function () { var myData = metadataMgr.getUserData(); if (!myData) { return; } var newName = myData.name; var url = myData.avatar; $displayName.text(newName || Messages.anonymous); - if (accountName) { + if (accountName && oldUrl !== url) { $avatar.html(''); UI.displayAvatar(Common, $avatar, url, newName, function ($img) { + oldUrl = url; if ($img) { $userAdmin.find('button').addClass('avatar'); } diff --git a/www/common/toolbar3.js b/www/common/toolbar3.js index 316f4849a..fbd1dd1e0 100644 --- a/www/common/toolbar3.js +++ b/www/common/toolbar3.js @@ -188,7 +188,6 @@ define([ var $editUsersList = $('