From f990200996b11cf5453b6bbf0912d49ce7ce99d7 Mon Sep 17 00:00:00 2001 From: ansuz Date: Tue, 19 Sep 2017 18:21:33 +0200 Subject: [PATCH 01/18] drop any notion of crypto from sframe-listmap --- www/common/sframe-chainpad-listmap.js | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/www/common/sframe-chainpad-listmap.js b/www/common/sframe-chainpad-listmap.js index 8e0aa8810..22b7e6216 100644 --- a/www/common/sframe-chainpad-listmap.js +++ b/www/common/sframe-chainpad-listmap.js @@ -623,19 +623,6 @@ define([ throw new Error('unsupported datatype: '+ DeepProxy.type(cfg.data)); } - if (!cfg.crypto) { - // complain and stub - console.log("[chainpad-listmap] no crypto module provided. messages will not be encrypted"); - cfg.crypto = { - encrypt: function (msg) { - return msg; - }, - decrypt: function (msg) { - return msg; - } - }; - } - var realtimeOptions = { userName: cfg.userName, initialState: Sortify(cfg.data), From 53b98c12c97cf44bea46b3a09eeba45387e2c82f Mon Sep 17 00:00:00 2001 From: ansuz Date: Wed, 20 Sep 2017 11:33:30 +0200 Subject: [PATCH 02/18] ignore broken stylesheet --- customize.dist/src/less2/main.less | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/customize.dist/src/less2/main.less b/customize.dist/src/less2/main.less index 5e0479deb..b2f32baec 100644 --- a/customize.dist/src/less2/main.less +++ b/customize.dist/src/less2/main.less @@ -27,6 +27,6 @@ body.cp-app-code { @import "../../../code/app-code.less"; } body.cp-app-slide { @import "../../../slide/app-slide.less"; } body.cp-app-file { @import "../../../file/app-file.less"; } body.cp-app-filepicker { @import "../../../filepicker/app-filepicker.less"; } -body.cp-app-poll { @import "../../../poll/app-poll.less"; } +//body.cp-app-poll { @import "../../../poll/app-poll.less"; } body.cp-app-whiteboard { @import "../../../whiteboard/app-whiteboard.less"; } From b5b84f540e02a826aa4eb0d5724aa825df1bbb54 Mon Sep 17 00:00:00 2001 From: ansuz Date: Wed, 20 Sep 2017 12:02:46 +0200 Subject: [PATCH 03/18] fix preview mode class --- www/code/inner.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/www/code/inner.js b/www/code/inner.js index 53d852ebd..6da2b00aa 100644 --- a/www/code/inner.js +++ b/www/code/inner.js @@ -238,7 +238,7 @@ define([ if (data !== false) { $previewContainer.show(); APP.$previewButton.addClass('active'); - $codeMirror.removeClass('fullPage'); + $codeMirror.removeClass('cp-app-code-fullpage'); } }); return; @@ -246,7 +246,7 @@ define([ APP.$previewButton.hide(); $previewContainer.hide(); APP.$previewButton.removeClass('active'); - $codeMirror.addClass('fullPage'); + $codeMirror.addClass('cp-app-code-fullpage'); }; config.onInit = function (info) { @@ -615,7 +615,7 @@ define([ SFCommon.create(waitFor(function (c) { APP.common = common = c; })); }).nThen(function (/*waitFor*/) { CodeMirror = common.initCodeMirrorApp(null, CM); - $('.CodeMirror').addClass('fullPage'); + $('.CodeMirror').addClass('cp-app-code-fullpage'); editor = CodeMirror.editor; Cryptpad.onError(function (info) { if (info && info.type === "store") { From 68f7d4bc0a522fc06003fa69566096cfd80f9ace Mon Sep 17 00:00:00 2001 From: ansuz Date: Wed, 20 Sep 2017 17:55:05 +0200 Subject: [PATCH 04/18] more conformant tagPrompt behaviour --- www/common/common-interface.js | 32 ++++++++++++++++++--------- www/common/sframe-common-interface.js | 3 +-- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/www/common/common-interface.js b/www/common/common-interface.js index 9f0746a90..ad5b51195 100644 --- a/www/common/common-interface.js +++ b/www/common/common-interface.js @@ -135,6 +135,11 @@ define([ }); }; + var $root = $t.parent(); + $t.on('tokenfield:removetoken', function (e) { + $root.find('.token-input').focus(); + }); + t.preventDuplicates = function (cb) { $t.on('tokenfield:createtoken', function (ev) { var val; @@ -185,22 +190,29 @@ define([ var $t = $(tagger).fadeOut(150, function () { $t.remove(); }); }); - var listener = listenForKeys(function () {}, function () { - close(); - stopListening(listener); + var listener; + var close = Util.once(function (result, ev) { + var $frame = $(tagger).fadeOut(150, function () { + stopListening(listener); + $frame.remove(); + cb(result, ev); + }); }); - var CB = Util.once(cb); - findOKButton(tagger).click(function () { + var $ok = findOKButton(tagger).click(function () { var tokens = field.getTokens(); - close(); - CB(tokens); + close(tokens); + }); + var $cancel = findCancelButton(tagger).click(function () { + close(null); }); - findCancelButton(tagger).click(function () { - close(); - CB(null); + listenForKeys(function () { + $ok.click(); + }, function () { + $cancel.click(); }); + document.body.appendChild(tagger); // :( setTimeout(function () { field.setTokens(tags); diff --git a/www/common/sframe-common-interface.js b/www/common/sframe-common-interface.js index c3a4757b4..73e09c603 100644 --- a/www/common/sframe-common-interface.js +++ b/www/common/sframe-common-interface.js @@ -203,12 +203,11 @@ define([ .click(function () { sframeChan.query('Q_TAGS_GET', null, function (err, res) { if (err || res.error) { return void console.error(err || res.error); } - var dialog = Cryptpad.dialog.tagPrompt(res.data, function (tags) { + Cryptpad.dialog.tagPrompt(res.data, function (tags) { if (!Array.isArray(tags)) { return; } console.error(tags); sframeChan.event('EV_TAGS_SET', tags); }); - document.body.appendChild(dialog); }); }); break; From 95302366d13fcc2aa0df142ec7dd10f080cafe57 Mon Sep 17 00:00:00 2001 From: ansuz Date: Thu, 21 Sep 2017 11:19:23 +0200 Subject: [PATCH 05/18] lint compliance --- customize.dist/pages.js | 7 +++---- www/common/common-interface.js | 6 +----- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/customize.dist/pages.js b/customize.dist/pages.js index 73e4daaf4..070788dc4 100644 --- a/customize.dist/pages.js +++ b/customize.dist/pages.js @@ -570,12 +570,12 @@ define([ }; var appToolbar = function () { - return h('div#toolbar.toolbar-container'); + return h('div#cp-toolbar.cp-toolbar-container'); }; Pages['/whiteboard/'] = Pages['/whiteboard/index.html'] = function () { return [ - h('div#cp-toolbar.cp-toolbar-container'), + appToolbar(), h('div#cp-app-whiteboard-canvas-area', h('canvas#cp-app-whiteboard-canvas', { width: 600, height: 600 @@ -680,8 +680,7 @@ define([ ]) ]) ]) - ]), - loadingScreen() + ]) ]; }; diff --git a/www/common/common-interface.js b/www/common/common-interface.js index ad5b51195..a02badebf 100644 --- a/www/common/common-interface.js +++ b/www/common/common-interface.js @@ -136,7 +136,7 @@ define([ }; var $root = $t.parent(); - $t.on('tokenfield:removetoken', function (e) { + $t.on('tokenfield:removetoken', function () { $root.find('.token-input').focus(); }); @@ -186,10 +186,6 @@ define([ UI.warn(Messages._getKey('tags_duplicate', [val])); }); - var close = Util.once(function () { - var $t = $(tagger).fadeOut(150, function () { $t.remove(); }); - }); - var listener; var close = Util.once(function (result, ev) { var $frame = $(tagger).fadeOut(150, function () { From dfdeb7b113b4574224eb1a894589c7d1ee393c77 Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 21 Sep 2017 18:00:11 +0200 Subject: [PATCH 06/18] Fix style and race condition for history mode --- .../src/less2/include/toolbar-history.less | 2 +- www/common/sframe-common-history.js | 15 ++++++++++++--- www/common/sframe-common-outer.js | 7 +++---- www/common/sframe-common.js | 10 +++++++--- 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/customize.dist/src/less2/include/toolbar-history.less b/customize.dist/src/less2/include/toolbar-history.less index 1a099bb76..0388f6401 100644 --- a/customize.dist/src/less2/include/toolbar-history.less +++ b/customize.dist/src/less2/include/toolbar-history.less @@ -1,7 +1,7 @@ @import (once) "./colortheme.less"; .history_main () { - body .cp-toolbar-history { + .cp-toolbar-history { display: none; text-align: center; * { diff --git a/www/common/sframe-common-history.js b/www/common/sframe-common-history.js index 3b95674bc..9167afc5f 100644 --- a/www/common/sframe-common-history.js +++ b/www/common/sframe-common-history.js @@ -21,6 +21,15 @@ define([ var createRealtime = function () { return ChainPad.create({ userName: 'history', + validateContent: function (content) { + try { + JSON.parse(content); + return true; + } catch (e) { + console.log('Failed to parse, rejecting patch'); + return false; + } + }, initialState: '', transformFunction: JsonOT.validate, logLevel: 0, @@ -69,9 +78,9 @@ define([ config.onLocal(); config.onRemote(); }; - var onReady = function () { - config.setHistory(true); - }; + + config.setHistory(true); + var onReady = function () { }; var Messages = common.Messages; var Cryptpad = common.getCryptpadCommon(); diff --git a/www/common/sframe-common-outer.js b/www/common/sframe-common-outer.js index 79ba73842..f5af1503f 100644 --- a/www/common/sframe-common-outer.js +++ b/www/common/sframe-common-outer.js @@ -228,23 +228,22 @@ define([ return null; } }; + var msgs = []; var onMsg = function (msg) { var parsed = parse(msg); if (parsed[0] === 'FULL_HISTORY_END') { - console.log('END'); - cb(); + cb(msgs); return; } if (parsed[0] !== 'FULL_HISTORY') { return; } if (parsed[1] && parsed[1].validateKey) { // First message - secret.keys.validateKey = parsed[1].validateKey; return; } msg = parsed[1][4]; if (msg) { msg = msg.replace(/^cp\|/, ''); var decryptedMsg = crypto.decrypt(msg, secret.keys.validateKey); - sframeChan.event('EV_RT_HIST_MESSAGE', decryptedMsg); + msgs.push(decryptedMsg) } }; network.on('message', onMsg); diff --git a/www/common/sframe-common.js b/www/common/sframe-common.js index 3df0e910e..62837a716 100644 --- a/www/common/sframe-common.js +++ b/www/common/sframe-common.js @@ -164,10 +164,14 @@ define([ }; funcs.getFullHistory = function (realtime, cb) { - ctx.sframeChan.on('EV_RT_HIST_MESSAGE', function (content) { - realtime.message(content); + ctx.sframeChan.query('Q_GET_FULL_HISTORY', null, function (err, messages) { + if (err) { return void console.error(err); } + if (!Array.isArray(messages)) { return; } + messages.forEach(function (m) { + realtime.message(m); + }); + cb(); }); - ctx.sframeChan.query('Q_GET_FULL_HISTORY', null, cb); }; funcs.getPadAttribute = function (key, cb) { From 4049931924bc7f248ee8af19f91cb9b57653b595 Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 25 Sep 2017 11:51:24 +0200 Subject: [PATCH 07/18] Lint --- www/common/sframe-common-outer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/common/sframe-common-outer.js b/www/common/sframe-common-outer.js index f5af1503f..8bb1fd3db 100644 --- a/www/common/sframe-common-outer.js +++ b/www/common/sframe-common-outer.js @@ -243,7 +243,7 @@ define([ if (msg) { msg = msg.replace(/^cp\|/, ''); var decryptedMsg = crypto.decrypt(msg, secret.keys.validateKey); - msgs.push(decryptedMsg) + msgs.push(decryptedMsg); } }; network.on('message', onMsg); From 92c808812ad0b1fa45e7cc7b09108b9b5fd4c0af Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 25 Sep 2017 11:59:05 +0200 Subject: [PATCH 08/18] Fix missing style in toolbar/less2 --- customize.dist/src/less2/include/toolbar.less | 8 ++++++++ www/common/sframe-common-interface.js | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/customize.dist/src/less2/include/toolbar.less b/customize.dist/src/less2/include/toolbar.less index 366d24be4..d4b6fcebf 100644 --- a/customize.dist/src/less2/include/toolbar.less +++ b/customize.dist/src/less2/include/toolbar.less @@ -658,6 +658,14 @@ } } } + p.cp-toolbar-account { + &> span { + font-weight: bold; + span { + font-weight: normal; + } + } + } .cp-toolbar-backup { margin: 0; border-radius: 0; diff --git a/www/common/sframe-common-interface.js b/www/common/sframe-common-interface.js index 73e09c603..eaf5fc40c 100644 --- a/www/common/sframe-common-interface.js +++ b/www/common/sframe-common-interface.js @@ -318,7 +318,7 @@ define([ $userAdminContent.append($userName); options.push({ tag: 'p', - attributes: {'class': 'accountData'}, + attributes: {'class': 'cp-toolbar-account'}, content: $userAdminContent.html() }); } From 1d7683503f88ee08efe683545e4405ee725b78e7 Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 25 Sep 2017 12:44:05 +0200 Subject: [PATCH 09/18] Fix link origin in sframe upload table --- customize.dist/src/less2/include/fileupload.less | 5 +++++ www/common/sframe-common-file.js | 7 ++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/customize.dist/src/less2/include/fileupload.less b/customize.dist/src/less2/include/fileupload.less index bd90ab5d3..a07d365bd 100644 --- a/customize.dist/src/less2/include/fileupload.less +++ b/customize.dist/src/less2/include/fileupload.less @@ -28,6 +28,11 @@ td { padding: @upload_pad_h @upload_pad_v; } + .cp-fileupload-table-link { + .fa { + margin-right: 5px; + } + } .cp-fileupload-table-progress { width: 200px; position: relative; diff --git a/www/common/sframe-common-file.js b/www/common/sframe-common-file.js index 8093db836..10bb8fbac 100644 --- a/www/common/sframe-common-file.js +++ b/www/common/sframe-common-file.js @@ -51,9 +51,7 @@ define([ $('').text(Messages.cancel).appendTo($thead); var createTableContainer = function ($body) { - console.log($body); File.$container = $('
', { id: 'cp-fileupload' }).append($table).appendTo($body); - console.log('done'); return File.$container; }; @@ -114,10 +112,13 @@ define([ }; onComplete = function (href) { + var mdMgr = common.getMetadataMgr(); + var origin = mdMgr.getPrivateData().origin; + $link.prepend($('', {'class': 'fa fa-external-link'})); $link.attr('href', href) .click(function (e) { e.preventDefault(); - window.open($link.attr('href'), '_blank'); + window.open(origin + $link.attr('href'), '_blank'); }); var title = metadata.name; Cryptpad.log(Messages._getKey('upload_success', [title])); From 0600ce59ecace14db4ffe3674854141e32889527 Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 25 Sep 2017 13:19:25 +0200 Subject: [PATCH 10/18] Display the 'spinner' when typing in sframe apps --- www/common/toolbar3.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/common/toolbar3.js b/www/common/toolbar3.js index 335888256..9d093c698 100644 --- a/www/common/toolbar3.js +++ b/www/common/toolbar3.js @@ -708,7 +708,7 @@ define([ window.clearInterval($spin.interval); typing = -1; $spin.text(Messages.saved); - }, local ? 0 : SPINNER_DISAPPEAR_TIME); + }, /*local ? 0 :*/ SPINNER_DISAPPEAR_TIME); }; config.sfCommon.whenRealtimeSyncs(onSynced); }; From 6aeb36676755a9a6b171aa0bb0b4926a0e5783be Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 25 Sep 2017 14:47:19 +0200 Subject: [PATCH 11/18] Lint --- www/common/toolbar3.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/common/toolbar3.js b/www/common/toolbar3.js index 9d093c698..3218f40f4 100644 --- a/www/common/toolbar3.js +++ b/www/common/toolbar3.js @@ -688,7 +688,7 @@ define([ }; var typing = -1; - var kickSpinner = function (toolbar, config, local) { + var kickSpinner = function (toolbar, config/*, local*/) { if (!toolbar.spinner) { return; } var $spin = toolbar.spinner; From b871faffc9fe770af36611b12dcb3a47a4917cfa Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 25 Sep 2017 14:47:31 +0200 Subject: [PATCH 12/18] Enable tags in code and slide --- www/code/app-code.less | 2 ++ www/code/inner.js | 3 +++ www/slide/app-slide.less | 2 ++ www/slide/inner.js | 3 +++ 4 files changed, 10 insertions(+) diff --git a/www/code/app-code.less b/www/code/app-code.less index 8772a2653..d625da0da 100644 --- a/www/code/app-code.less +++ b/www/code/app-code.less @@ -3,10 +3,12 @@ @import (once) "../../customize/src/less2/include/markdown.less"; @import (once) '../../customize/src/less2/include/fileupload.less'; @import (once) '../../customize/src/less2/include/alertify.less'; +@import (once) '../../customize/src/less2/include/tokenfield.less'; .toolbar_main(); .fileupload_main(); .alertify_main(); +.tokenfield_main(); // body &.cp-app-code { diff --git a/www/code/inner.js b/www/code/inner.js index 8a7dde080..c4917e6fc 100644 --- a/www/code/inner.js +++ b/www/code/inner.js @@ -374,6 +374,9 @@ define([ }; common.openFilePicker(pickerCfg); }).appendTo($rightside); + + var $tags = common.createButton('hashtag', true); + $rightside.append($tags); } }; diff --git a/www/slide/app-slide.less b/www/slide/app-slide.less index 0d54fa710..f6ebf8cf0 100644 --- a/www/slide/app-slide.less +++ b/www/slide/app-slide.less @@ -4,11 +4,13 @@ @import (once) '../../customize/src/less2/include/fileupload.less'; @import (once) '../../customize/src/less2/include/alertify.less'; @import (once) "../../customize/src/less2/include/mediatag.less"; +@import (once) '../../customize/src/less2/include/tokenfield.less'; .mediatag_base(); .toolbar_main(); .fileupload_main(); .alertify_main(); +.tokenfield_main(); // body font-size: unset; diff --git a/www/slide/inner.js b/www/slide/inner.js index 91830b749..0efe35d1c 100644 --- a/www/slide/inner.js +++ b/www/slide/inner.js @@ -516,6 +516,9 @@ define([ }; common.openFilePicker(pickerCfg); }).appendTo($rightside); + + var $tags = common.createButton('hashtag', true); + $rightside.append($tags); } metadataMgr.onChange(function () { From b15527565c47cf72e0291e56ae32fec13635b041 Mon Sep 17 00:00:00 2001 From: Caleb James DeLisle Date: Mon, 25 Sep 2017 15:42:08 +0200 Subject: [PATCH 13/18] Allow passing arguments when firing events --- www/common/common-util.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/www/common/common-util.js b/www/common/common-util.js index f6ec8d4df..4015fbfe4 100644 --- a/www/common/common-util.js +++ b/www/common/common-util.js @@ -18,7 +18,8 @@ define([], function () { fire: function () { if (fired) { return; } fired = true; - handlers.forEach(function (h) { h(); }); + var args = Array.prototype.slice.call(arguments); + handlers.forEach(function (h) { h.apply(null, args); }); } }; }; From 44018ee7e1525d9a3f013641516e8bd6356847fc Mon Sep 17 00:00:00 2001 From: Caleb James DeLisle Date: Mon, 25 Sep 2017 15:43:02 +0200 Subject: [PATCH 14/18] Improve the LessLoader check to hopefully stop the message saying cookies were blocked. --- www/common/LessLoader.js | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/www/common/LessLoader.js b/www/common/LessLoader.js index f7e4f6985..3275c88b5 100644 --- a/www/common/LessLoader.js +++ b/www/common/LessLoader.js @@ -9,18 +9,20 @@ define([ var module = { exports: {} }; var key = Config.requireConf.urlArgs; var localStorage = {}; - try { - localStorage = window.localStorage || {}; - if (localStorage['LESS_CACHE'] !== key) { - Object.keys(localStorage).forEach(function (k) { - if (k.indexOf('LESS_CACHE|') !== 0) { return; } - delete localStorage[k]; - }); - localStorage['LESS_CACHE'] = key; + if (!window.cryptpadCache) { + try { + localStorage = window.localStorage || {}; + if (localStorage['LESS_CACHE'] !== key) { + Object.keys(localStorage).forEach(function (k) { + if (k.indexOf('LESS_CACHE|') !== 0) { return; } + delete localStorage[k]; + }); + localStorage['LESS_CACHE'] = key; + } + } catch (e) { + console.error(e); + localStorage = {}; } - } catch (e) { - console.error(e); - localStorage = {}; } var cacheGet = function (k, cb) { From ae54cbca3305eb0947cda1853eab5e672eccf9b3 Mon Sep 17 00:00:00 2001 From: Caleb James DeLisle Date: Mon, 25 Sep 2017 15:44:03 +0200 Subject: [PATCH 15/18] Refactor sframe-cpnf-inner to export chainpad --- www/common/sframe-chainpad-netflux-inner.js | 42 +++++++++++---------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/www/common/sframe-chainpad-netflux-inner.js b/www/common/sframe-chainpad-netflux-inner.js index 787da1ca3..7e0eb2a57 100644 --- a/www/common/sframe-chainpad-netflux-inner.js +++ b/www/common/sframe-chainpad-netflux-inner.js @@ -46,7 +46,21 @@ define([ var metadataMgr = config.metadataMgr; config = undefined; - var chainpad; + var chainpad = ChainPad.create({ + userName: userName, + initialState: initialState, + transformFunction: transformFunction, + validateContent: validateContent, + avgSyncMilliseconds: avgSyncMilliseconds, + logLevel: logLevel + }); + chainpad.onMessage(function(message, cb) { + sframeChan.query('Q_RT_MESSAGE', message, cb); + }); + chainpad.onPatch(function () { + onRemote({ realtime: chainpad }); + }); + var myID; var isReady = false; var evConnected = Util.mkEvent(true); @@ -67,33 +81,20 @@ define([ sframeChan.on('EV_RT_DISCONNECT', function () { isReady = false; - if (chainpad) { chainpad.abort(); } + chainpad.abort(); onConnectionChange({ state: false }); }); sframeChan.on('EV_RT_CONNECT', function (content) { //content.members.forEach(userList.onJoin); - myID = content.myID; isReady = false; - if (chainpad) { + if (myID) { // it's a reconnect - if (chainpad) { chainpad.start(); } + myID = content.myID; + chainpad.start(); onConnectionChange({ state: true, myId: myID }); return; } - chainpad = ChainPad.create({ - userName: userName, - initialState: initialState, - transformFunction: transformFunction, - validateContent: validateContent, - avgSyncMilliseconds: avgSyncMilliseconds, - logLevel: logLevel - }); - chainpad.onMessage(function(message, cb) { - sframeChan.query('Q_RT_MESSAGE', message, cb); - }); - chainpad.onPatch(function () { - onRemote({ realtime: chainpad }); - }); + myID = content.myID; onInit({ myID: myID, realtime: chainpad, @@ -130,7 +131,8 @@ define([ getMyID: function () { return myID; }, metadataMgr: metadataMgr, whenRealtimeSyncs: whenRealtimeSyncs, - onInfiniteSpinner: evInfiniteSpinner.reg + onInfiniteSpinner: evInfiniteSpinner.reg, + chainpad: chainpad, }); }; return Object.freeze(module.exports); From 59ad96e491c9a25e448c591700f4a35b5a4b9861 Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 25 Sep 2017 16:11:50 +0200 Subject: [PATCH 16/18] Make sure the user is redirected to the drive at registration --- www/register/main.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/www/register/main.js b/www/register/main.js index 7de37e8bf..1b7103cac 100644 --- a/www/register/main.js +++ b/www/register/main.js @@ -85,6 +85,8 @@ define([ Cryptpad.whenRealtimeSyncs(result.realtime, function () { Cryptpad.login(result.userHash, result.userName, function () { registering = false; + /* + FIXME: migration and readme not working if not redirected to drive if (sessionStorage.redirectTo) { var h = sessionStorage.redirectTo; var parser = document.createElement('a'); @@ -95,6 +97,7 @@ define([ return; } } + */ window.location.href = '/drive/'; }); }); From 138ad17e3e1f5d8933325e6bbb6943cd3d541cc6 Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 25 Sep 2017 17:09:26 +0200 Subject: [PATCH 17/18] Fix 'import local pads' in settings creating duplicates --- www/common/mergeDrive.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/www/common/mergeDrive.js b/www/common/mergeDrive.js index ce3e0b157..0cbe312bf 100644 --- a/www/common/mergeDrive.js +++ b/www/common/mergeDrive.js @@ -111,12 +111,14 @@ define([ var newFo = newData.fo; var oldRecentPads = parsed.drive[newFo.FILES_DATA]; var newRecentPads = proxy.drive[newFo.FILES_DATA]; - var newFiles = newFo.getFiles([newFo.FILES_DATA]); var oldFiles = oldFo.getFiles([newFo.FILES_DATA]); + var newHrefs = Object.keys(newRecentPads).map(function (id) { + return newRecentPads[id].href; + }); oldFiles.forEach(function (id) { var href = oldRecentPads[id].href; // Do not migrate a pad if we already have it, it would create a duplicate in the drive - if (newFiles.indexOf(id) !== -1) { return; } + if (newHrefs.indexOf(href) !== -1) { return; } // If we have a stronger version, do not add the current href if (Cryptpad.findStronger(href, newRecentPads)) { return; } // If we have a weaker version, replace the href by the new one From a8eecee590faf5f9f9fa8ccefe3791d842621ef1 Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 25 Sep 2017 17:29:31 +0200 Subject: [PATCH 18/18] Fix access to undefined variable in drive --- www/common/userObject.js | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/www/common/userObject.js b/www/common/userObject.js index 3f4ab7dd6..ddacbb806 100644 --- a/www/common/userObject.js +++ b/www/common/userObject.js @@ -456,7 +456,7 @@ define([ }; exp.getRecentPads = function () { var allFiles = files[FILES_DATA]; - var sorted = Object.keys(allFiles) + var sorted = Object.keys(allFiles).filter(function (a) { return allFiles[a]; }) .sort(function (a,b) { return allFiles[a].atime < allFiles[b].atime; }) @@ -1037,20 +1037,6 @@ define([ } }); }; - var migrateAttributes = function (el, id, parsed) { - // Migrate old pad attributes - ['userid', 'previewMode'].forEach(function (attr) { - var key = parsed.hash + '.' + attr; - var key2 = parsed.hash.slice(0,-1) + '.' + attr;// old pads not ending with / - if (typeof(files[key]) !== "undefined" || typeof(files[key2]) !== "undefined") { - debug("Migrating pad attribute", attr, "for pad", id); - el[attr] = files[key] || files[key2]; - delete files[key]; - delete files[key2]; - } - }); - // Migration done - }; var fixFilesData = function () { if (typeof files[FILES_DATA] !== "object") { debug("OLD_FILES_DATA was not an object"); files[FILES_DATA] = {}; } var fd = files[FILES_DATA]; @@ -1077,8 +1063,6 @@ define([ continue; } - migrateAttributes(el, id, parsed); - if ((Cryptpad.isLoggedIn() || config.testMode) && rootFiles.indexOf(id) === -1) { debug("An element in filesData was not in ROOT, TEMPLATE or TRASH.", id, el); var newName = Cryptpad.createChannelId();