Merge branch 'staging' into newdrive

pull/1/head
yflory 7 years ago
commit cdeac00633

@ -570,12 +570,12 @@ define([
}; };
var appToolbar = function () { var appToolbar = function () {
return h('div#toolbar.toolbar-container'); return h('div#cp-toolbar.cp-toolbar-container');
}; };
Pages['/whiteboard/'] = Pages['/whiteboard/index.html'] = function () { Pages['/whiteboard/'] = Pages['/whiteboard/index.html'] = function () {
return [ return [
h('div#cp-toolbar.cp-toolbar-container'), appToolbar(),
h('div#cp-app-whiteboard-canvas-area', h('canvas#cp-app-whiteboard-canvas', { h('div#cp-app-whiteboard-canvas-area', h('canvas#cp-app-whiteboard-canvas', {
width: 600, width: 600,
height: 600 height: 600
@ -680,8 +680,7 @@ define([
]) ])
]) ])
]) ])
]), ])
loadingScreen()
]; ];
}; };

@ -28,6 +28,11 @@
td { td {
padding: @upload_pad_h @upload_pad_v; padding: @upload_pad_h @upload_pad_v;
} }
.cp-fileupload-table-link {
.fa {
margin-right: 5px;
}
}
.cp-fileupload-table-progress { .cp-fileupload-table-progress {
width: 200px; width: 200px;
position: relative; position: relative;

@ -650,6 +650,14 @@
} }
} }
} }
p.cp-toolbar-account {
&> span {
font-weight: bold;
span {
font-weight: normal;
}
}
}
.cp-toolbar-backup { .cp-toolbar-backup {
margin: 0; margin: 0;
border-radius: 0; border-radius: 0;

@ -3,10 +3,12 @@
@import (once) "../../customize/src/less2/include/markdown.less"; @import (once) "../../customize/src/less2/include/markdown.less";
@import (once) '../../customize/src/less2/include/fileupload.less'; @import (once) '../../customize/src/less2/include/fileupload.less';
@import (once) '../../customize/src/less2/include/alertify.less'; @import (once) '../../customize/src/less2/include/alertify.less';
@import (once) '../../customize/src/less2/include/tokenfield.less';
.toolbar_main(); .toolbar_main();
.fileupload_main(); .fileupload_main();
.alertify_main(); .alertify_main();
.tokenfield_main();
// body // body
&.cp-app-code { &.cp-app-code {

@ -230,7 +230,7 @@ define([
if (data !== false) { if (data !== false) {
$previewContainer.show(); $previewContainer.show();
APP.$previewButton.addClass('active'); APP.$previewButton.addClass('active');
$codeMirror.removeClass('fullPage'); $codeMirror.removeClass('cp-app-code-fullpage');
} }
}); });
return; return;
@ -238,7 +238,7 @@ define([
APP.$previewButton.hide(); APP.$previewButton.hide();
$previewContainer.hide(); $previewContainer.hide();
APP.$previewButton.removeClass('active'); APP.$previewButton.removeClass('active');
$codeMirror.addClass('fullPage'); $codeMirror.addClass('cp-app-code-fullpage');
}; };
config.onInit = function (info) { config.onInit = function (info) {
@ -374,6 +374,9 @@ define([
}; };
common.openFilePicker(pickerCfg); common.openFilePicker(pickerCfg);
}).appendTo($rightside); }).appendTo($rightside);
var $tags = common.createButton('hashtag', true);
$rightside.append($tags);
} }
}; };
@ -604,7 +607,7 @@ define([
SFCommon.create(waitFor(function (c) { APP.common = common = c; })); SFCommon.create(waitFor(function (c) { APP.common = common = c; }));
}).nThen(function (/*waitFor*/) { }).nThen(function (/*waitFor*/) {
CodeMirror = common.initCodeMirrorApp(null, CM); CodeMirror = common.initCodeMirrorApp(null, CM);
$('.CodeMirror').addClass('fullPage'); $('.CodeMirror').addClass('cp-app-code-fullpage');
editor = CodeMirror.editor; editor = CodeMirror.editor;
Cryptpad.onError(function (info) { Cryptpad.onError(function (info) {
if (info && info.type === "store") { if (info && info.type === "store") {

@ -9,6 +9,7 @@ define([
var module = { exports: {} }; var module = { exports: {} };
var key = Config.requireConf.urlArgs; var key = Config.requireConf.urlArgs;
var localStorage = {}; var localStorage = {};
if (!window.cryptpadCache) {
try { try {
localStorage = window.localStorage || {}; localStorage = window.localStorage || {};
if (localStorage['LESS_CACHE'] !== key) { if (localStorage['LESS_CACHE'] !== key) {
@ -22,6 +23,7 @@ define([
console.error(e); console.error(e);
localStorage = {}; localStorage = {};
} }
}
var cacheGet = function (k, cb) { var cacheGet = function (k, cb) {
if (window.cryptpadCache) { return void window.cryptpadCache.get(k, cb); } if (window.cryptpadCache) { return void window.cryptpadCache.get(k, cb); }

@ -135,6 +135,11 @@ define([
}); });
}; };
var $root = $t.parent();
$t.on('tokenfield:removetoken', function () {
$root.find('.token-input').focus();
});
t.preventDuplicates = function (cb) { t.preventDuplicates = function (cb) {
$t.on('tokenfield:createtoken', function (ev) { $t.on('tokenfield:createtoken', function (ev) {
var val; var val;
@ -181,26 +186,29 @@ define([
UI.warn(Messages._getKey('tags_duplicate', [val])); UI.warn(Messages._getKey('tags_duplicate', [val]));
}); });
var close = Util.once(function () { var listener;
var $t = $(tagger).fadeOut(150, function () { $t.remove(); }); var close = Util.once(function (result, ev) {
}); var $frame = $(tagger).fadeOut(150, function () {
var listener = listenForKeys(function () {}, function () {
close();
stopListening(listener); stopListening(listener);
$frame.remove();
cb(result, ev);
});
}); });
var CB = Util.once(cb); var $ok = findOKButton(tagger).click(function () {
findOKButton(tagger).click(function () {
var tokens = field.getTokens(); var tokens = field.getTokens();
close(); close(tokens);
CB(tokens); });
var $cancel = findCancelButton(tagger).click(function () {
close(null);
}); });
findCancelButton(tagger).click(function () { listenForKeys(function () {
close(); $ok.click();
CB(null); }, function () {
$cancel.click();
}); });
document.body.appendChild(tagger);
// :( // :(
setTimeout(function () { setTimeout(function () {
field.setTokens(tags); field.setTokens(tags);

@ -18,7 +18,8 @@ define([], function () {
fire: function () { fire: function () {
if (fired) { return; } if (fired) { return; }
fired = true; fired = true;
handlers.forEach(function (h) { h(); }); var args = Array.prototype.slice.call(arguments);
handlers.forEach(function (h) { h.apply(null, args); });
} }
}; };
}; };

@ -111,12 +111,14 @@ define([
var newFo = proxyData.fo; var newFo = proxyData.fo;
var oldRecentPads = parsed.drive[newFo.FILES_DATA]; var oldRecentPads = parsed.drive[newFo.FILES_DATA];
var newRecentPads = proxy.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 oldFiles = oldFo.getFiles([newFo.FILES_DATA]);
var newHrefs = Object.keys(newRecentPads).map(function (id) {
return newRecentPads[id].href;
});
oldFiles.forEach(function (id) { oldFiles.forEach(function (id) {
var href = oldRecentPads[id].href; var href = oldRecentPads[id].href;
// Do not migrate a pad if we already have it, it would create a duplicate in the drive // 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 we have a stronger version, do not add the current href
if (Cryptpad.findStronger(href, newRecentPads)) { return; } if (Cryptpad.findStronger(href, newRecentPads)) { return; }
// If we have a weaker version, replace the href by the new one // If we have a weaker version, replace the href by the new one

@ -623,19 +623,6 @@ define([
throw new Error('unsupported datatype: '+ DeepProxy.type(cfg.data)); 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 = { var realtimeOptions = {
userName: cfg.userName, userName: cfg.userName,
initialState: Sortify(cfg.data), initialState: Sortify(cfg.data),

@ -46,7 +46,21 @@ define([
var metadataMgr = config.metadataMgr; var metadataMgr = config.metadataMgr;
config = undefined; 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 myID;
var isReady = false; var isReady = false;
var evConnected = Util.mkEvent(true); var evConnected = Util.mkEvent(true);
@ -67,33 +81,20 @@ define([
sframeChan.on('EV_RT_DISCONNECT', function () { sframeChan.on('EV_RT_DISCONNECT', function () {
isReady = false; isReady = false;
if (chainpad) { chainpad.abort(); } chainpad.abort();
onConnectionChange({ state: false }); onConnectionChange({ state: false });
}); });
sframeChan.on('EV_RT_CONNECT', function (content) { sframeChan.on('EV_RT_CONNECT', function (content) {
//content.members.forEach(userList.onJoin); //content.members.forEach(userList.onJoin);
myID = content.myID;
isReady = false; isReady = false;
if (chainpad) { if (myID) {
// it's a reconnect // it's a reconnect
if (chainpad) { chainpad.start(); } myID = content.myID;
chainpad.start();
onConnectionChange({ state: true, myId: myID }); onConnectionChange({ state: true, myId: myID });
return; return;
} }
chainpad = ChainPad.create({ myID = content.myID;
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 });
});
onInit({ onInit({
myID: myID, myID: myID,
realtime: chainpad, realtime: chainpad,
@ -130,7 +131,8 @@ define([
getMyID: function () { return myID; }, getMyID: function () { return myID; },
metadataMgr: metadataMgr, metadataMgr: metadataMgr,
whenRealtimeSyncs: whenRealtimeSyncs, whenRealtimeSyncs: whenRealtimeSyncs,
onInfiniteSpinner: evInfiniteSpinner.reg onInfiniteSpinner: evInfiniteSpinner.reg,
chainpad: chainpad,
}); });
}; };
return Object.freeze(module.exports); return Object.freeze(module.exports);

@ -112,10 +112,13 @@ define([
}; };
onComplete = function (href) { onComplete = function (href) {
var mdMgr = common.getMetadataMgr();
var origin = mdMgr.getPrivateData().origin;
$link.prepend($('<span>', {'class': 'fa fa-external-link'}));
$link.attr('href', href) $link.attr('href', href)
.click(function (e) { .click(function (e) {
e.preventDefault(); e.preventDefault();
window.open($link.attr('href'), '_blank'); window.open(origin + $link.attr('href'), '_blank');
}); });
var title = metadata.name; var title = metadata.name;
Cryptpad.log(Messages._getKey('upload_success', [title])); Cryptpad.log(Messages._getKey('upload_success', [title]));

@ -205,12 +205,11 @@ define([
.click(function () { .click(function () {
sframeChan.query('Q_TAGS_GET', null, function (err, res) { sframeChan.query('Q_TAGS_GET', null, function (err, res) {
if (err || res.error) { return void console.error(err || res.error); } 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; } if (!Array.isArray(tags)) { return; }
console.error(tags); console.error(tags);
sframeChan.event('EV_TAGS_SET', tags); sframeChan.event('EV_TAGS_SET', tags);
}); });
document.body.appendChild(dialog);
}); });
}); });
break; break;
@ -418,7 +417,7 @@ define([
$userAdminContent.append($userName); $userAdminContent.append($userName);
options.push({ options.push({
tag: 'p', tag: 'p',
attributes: {'class': 'accountData'}, attributes: {'class': 'cp-toolbar-account'},
content: $userAdminContent.html() content: $userAdminContent.html()
}); });
} }

@ -259,7 +259,7 @@ define([
if (msg) { if (msg) {
msg = msg.replace(/^cp\|/, ''); msg = msg.replace(/^cp\|/, '');
var decryptedMsg = crypto.decrypt(msg, secret.keys.validateKey); var decryptedMsg = crypto.decrypt(msg, secret.keys.validateKey);
msgs.push(decryptedMsg) msgs.push(decryptedMsg);
} }
}; };
network.on('message', onMsg); network.on('message', onMsg);

@ -688,7 +688,7 @@ define([
}; };
var typing = -1; var typing = -1;
var kickSpinner = function (toolbar, config, local) { var kickSpinner = function (toolbar, config/*, local*/) {
if (!toolbar.spinner) { return; } if (!toolbar.spinner) { return; }
var $spin = toolbar.spinner; var $spin = toolbar.spinner;
@ -708,7 +708,7 @@ define([
window.clearInterval($spin.interval); window.clearInterval($spin.interval);
typing = -1; typing = -1;
$spin.text(Messages.saved); $spin.text(Messages.saved);
}, local ? 0 : SPINNER_DISAPPEAR_TIME); }, /*local ? 0 :*/ SPINNER_DISAPPEAR_TIME);
}; };
config.sfCommon.whenRealtimeSyncs(onSynced); config.sfCommon.whenRealtimeSyncs(onSynced);
}; };

@ -457,7 +457,7 @@ define([
}; };
exp.getRecentPads = function () { exp.getRecentPads = function () {
var allFiles = files[FILES_DATA]; 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) { .sort(function (a,b) {
return allFiles[a].atime < allFiles[b].atime; return allFiles[a].atime < allFiles[b].atime;
}) })
@ -1041,20 +1041,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 () { var fixFilesData = function () {
if (typeof files[FILES_DATA] !== "object") { debug("OLD_FILES_DATA was not an object"); files[FILES_DATA] = {}; } if (typeof files[FILES_DATA] !== "object") { debug("OLD_FILES_DATA was not an object"); files[FILES_DATA] = {}; }
var fd = files[FILES_DATA]; var fd = files[FILES_DATA];
@ -1081,8 +1067,6 @@ define([
continue; continue;
} }
migrateAttributes(el, id, parsed);
if ((loggedIn || config.testMode) && rootFiles.indexOf(id) === -1) { if ((loggedIn || config.testMode) && rootFiles.indexOf(id) === -1) {
debug("An element in filesData was not in ROOT, TEMPLATE or TRASH.", id, el); debug("An element in filesData was not in ROOT, TEMPLATE or TRASH.", id, el);
var newName = Cryptpad.createChannelId(); var newName = Cryptpad.createChannelId();

@ -85,6 +85,8 @@ define([
Cryptpad.whenRealtimeSyncs(result.realtime, function () { Cryptpad.whenRealtimeSyncs(result.realtime, function () {
Cryptpad.login(result.userHash, result.userName, function () { Cryptpad.login(result.userHash, result.userName, function () {
registering = false; registering = false;
/*
FIXME: migration and readme not working if not redirected to drive
if (sessionStorage.redirectTo) { if (sessionStorage.redirectTo) {
var h = sessionStorage.redirectTo; var h = sessionStorage.redirectTo;
var parser = document.createElement('a'); var parser = document.createElement('a');
@ -95,6 +97,7 @@ define([
return; return;
} }
} }
*/
window.location.href = '/drive/'; window.location.href = '/drive/';
}); });
}); });

@ -4,11 +4,13 @@
@import (once) '../../customize/src/less2/include/fileupload.less'; @import (once) '../../customize/src/less2/include/fileupload.less';
@import (once) '../../customize/src/less2/include/alertify.less'; @import (once) '../../customize/src/less2/include/alertify.less';
@import (once) "../../customize/src/less2/include/mediatag.less"; @import (once) "../../customize/src/less2/include/mediatag.less";
@import (once) '../../customize/src/less2/include/tokenfield.less';
.mediatag_base(); .mediatag_base();
.toolbar_main(); .toolbar_main();
.fileupload_main(); .fileupload_main();
.alertify_main(); .alertify_main();
.tokenfield_main();
// body // body
font-size: unset; font-size: unset;

@ -516,6 +516,9 @@ define([
}; };
common.openFilePicker(pickerCfg); common.openFilePicker(pickerCfg);
}).appendTo($rightside); }).appendTo($rightside);
var $tags = common.createButton('hashtag', true);
$rightside.append($tags);
} }
metadataMgr.onChange(function () { metadataMgr.onChange(function () {

Loading…
Cancel
Save