Merge branch 'staging' into newdrive

pull/1/head
yflory 7 years ago
commit cdeac00633

@ -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()
])
];
};

@ -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;

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

@ -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 {

@ -230,7 +230,7 @@ define([
if (data !== false) {
$previewContainer.show();
APP.$previewButton.addClass('active');
$codeMirror.removeClass('fullPage');
$codeMirror.removeClass('cp-app-code-fullpage');
}
});
return;
@ -238,7 +238,7 @@ define([
APP.$previewButton.hide();
$previewContainer.hide();
APP.$previewButton.removeClass('active');
$codeMirror.addClass('fullPage');
$codeMirror.addClass('cp-app-code-fullpage');
};
config.onInit = function (info) {
@ -374,6 +374,9 @@ define([
};
common.openFilePicker(pickerCfg);
}).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; }));
}).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") {

@ -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) {

@ -135,6 +135,11 @@ define([
});
};
var $root = $t.parent();
$t.on('tokenfield:removetoken', function () {
$root.find('.token-input').focus();
});
t.preventDuplicates = function (cb) {
$t.on('tokenfield:createtoken', function (ev) {
var val;
@ -181,26 +186,29 @@ define([
UI.warn(Messages._getKey('tags_duplicate', [val]));
});
var close = Util.once(function () {
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);
});
findCancelButton(tagger).click(function () {
close();
CB(null);
var $cancel = findCancelButton(tagger).click(function () {
close(null);
});
listenForKeys(function () {
$ok.click();
}, function () {
$cancel.click();
});
document.body.appendChild(tagger);
// :(
setTimeout(function () {
field.setTokens(tags);

@ -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); });
}
};
};

@ -111,12 +111,14 @@ define([
var newFo = proxyData.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

@ -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),

@ -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);

@ -112,10 +112,13 @@ define([
};
onComplete = function (href) {
var mdMgr = common.getMetadataMgr();
var origin = mdMgr.getPrivateData().origin;
$link.prepend($('<span>', {'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]));

@ -205,12 +205,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;
@ -418,7 +417,7 @@ define([
$userAdminContent.append($userName);
options.push({
tag: 'p',
attributes: {'class': 'accountData'},
attributes: {'class': 'cp-toolbar-account'},
content: $userAdminContent.html()
});
}

@ -259,7 +259,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);

@ -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;
@ -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);
};

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

@ -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/';
});
});

@ -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;

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

Loading…
Cancel
Save