Merge branch 'staging' of github.com:xwiki-labs/cryptpad into staging

pull/1/head
ansuz 7 years ago
commit 8c4ed76fa7

@ -92,16 +92,25 @@ define([
]); ]);
} }
var button = h('button.navbar-toggler', {
'type':'button',
/*'data-toggle':'collapse',
'data-target':'#menuCollapse',
'aria-controls': 'menuCollapse',
'aria-expanded':'false',
'aria-label':'Toggle navigation'*/
}, h('i.fa.fa-bars '));
$(button).click(function () {
if ($('#menuCollapse').is(':visible')) {
return void $('#menuCollapse').slideUp();
}
$('#menuCollapse').slideDown();
});
return h('nav.navbar.navbar-expand-lg', return h('nav.navbar.navbar-expand-lg',
h('a.navbar-brand', { href: '/index.html'}), h('a.navbar-brand', { href: '/index.html'}),
h('button.navbar-toggler', { button,
'type':'button',
'data-toggle':'collapse',
'data-target':'#menuCollapse',
'aria-controls': 'menuCollapse',
'aria-expanded':'false',
'aria-label':'Toggle navigation'
}, h('i.fa.fa-bars ')),
h('div.collapse.navbar-collapse.justify-content-end#menuCollapse', [ h('div.collapse.navbar-collapse.justify-content-end#menuCollapse', [
//h('a.nav-item.nav-link', { href: '/what-is-cryptpad.html'}, Msg.topbar_whatIsCryptpad), // Moved the FAQ //h('a.nav-item.nav-link', { href: '/what-is-cryptpad.html'}, Msg.topbar_whatIsCryptpad), // Moved the FAQ
h('a.nav-item.nav-link', { href: '/faq.html'}, Msg.faq_link), h('a.nav-item.nav-link', { href: '/faq.html'}, Msg.faq_link),

@ -55,9 +55,23 @@
user-select: none; user-select: none;
float: none; float: none;
text-align: left; text-align: left;
font: @dropdown_font;
line-height: 1em; line-height: 1em;
align-items: center;
&:not(.fa) {
font: @dropdown_font;
}
&.fa {
font-size: 18px;
&::before {
width: 40px;
margin-left: -10px;
text-align: center;
}
* {
font: @dropdown_font;
}
}
.fa { .fa {
width: 20px; width: 20px;

@ -27,8 +27,7 @@ $(function () {
window.Tether = function () {}; window.Tether = function () {};
require([ require([
'less!/customize/src/less2/main.less', 'less!/customize/src/less2/main.less',
'css!/bower_components/bootstrap/dist/css/bootstrap.min.css', 'css!/bower_components/bootstrap/dist/css/bootstrap.min.css'
'/bower_components/bootstrap/dist/js/bootstrap.bundle.min.js'
], function () { ], function () {
$body.append($main); $body.append($main);

@ -145,6 +145,8 @@ define(function () {
out.useTemplate = "Commencer avec un modèle?"; out.useTemplate = "Commencer avec un modèle?";
out.useTemplateOK = 'Choisir un modèle (Entrée)'; out.useTemplateOK = 'Choisir un modèle (Entrée)';
out.useTemplateCancel = 'Document vierge (Échap)'; out.useTemplateCancel = 'Document vierge (Échap)';
out.template_import = "Importer un modèle";
out.template_empty = "Aucun modèle disponible";
out.previewButtonTitle = "Afficher ou cacher la prévisualisation de Markdown"; out.previewButtonTitle = "Afficher ou cacher la prévisualisation de Markdown";
@ -611,9 +613,6 @@ define(function () {
out.pad_showToolbar = "Afficher la barre d'outils"; out.pad_showToolbar = "Afficher la barre d'outils";
out.pad_hideToolbar = "Cacher la barre d'outils"; out.pad_hideToolbar = "Cacher la barre d'outils";
// general warnings
out.warn_notPinned = "Ce pad n'est stocké dans aucun CryptDrive. Il va expirer après 3 mois d'inactivité. <a href='/about.html#pinning'>En savoir plus...</a>";
// markdown toolbar // markdown toolbar
out.mdToolbar_button = "Afficher ou cacher la barre d'outils Markdown"; out.mdToolbar_button = "Afficher ou cacher la barre d'outils Markdown";
out.mdToolbar_defaultText = "Votre texte ici"; out.mdToolbar_defaultText = "Votre texte ici";
@ -952,8 +951,6 @@ define(function () {
// Header.html // Header.html
out.header_france = '<a href="http://www.xwiki.com/fr" target="_blank" rel="noopener noreferrer">Fait avec <img class="bottom-bar-heart" src="/customize/heart.png" alt="amour" /> en <img class="bottom-bar-fr" title="France" alt="France" src="/customize/fr.png" /> par <img src="/customize/logo-xwiki.png" alt="XWiki SAS" class="bottom-bar-xwiki"/></a>';
out.header_support = '<a href="http://ng.open-paas.org/" title="OpenPaaS::ng" target="_blank" rel="noopener noreferrer"> <img src="/customize/openpaasng.png" alt="OpenPaaS-ng" class="bottom-bar-openpaas" /></a>';
out.updated_0_header_logoTitle = 'Retourner vers votre CryptDrive'; out.updated_0_header_logoTitle = 'Retourner vers votre CryptDrive';
out.header_logoTitle = out.updated_0_header_logoTitle; out.header_logoTitle = out.updated_0_header_logoTitle;
out.header_homeTitle = "Aller sur la page d'accueil"; out.header_homeTitle = "Aller sur la page d'accueil";

@ -146,6 +146,8 @@ define(function () {
out.useTemplate = "Start with a template?"; //Would you like to "You have available templates for this type of pad. Do you want to use one?"; out.useTemplate = "Start with a template?"; //Would you like to "You have available templates for this type of pad. Do you want to use one?";
out.useTemplateOK = 'Pick a template (Enter)'; out.useTemplateOK = 'Pick a template (Enter)';
out.useTemplateCancel = 'Start fresh (Esc)'; out.useTemplateCancel = 'Start fresh (Esc)';
out.template_import = "Import a template";
out.template_empty = "No template available";
out.previewButtonTitle = "Display or hide the Markdown preview mode"; out.previewButtonTitle = "Display or hide the Markdown preview mode";
@ -615,9 +617,6 @@ define(function () {
out.pad_showToolbar = "Show toolbar"; out.pad_showToolbar = "Show toolbar";
out.pad_hideToolbar = "Hide toolbar"; out.pad_hideToolbar = "Hide toolbar";
// general warnings
out.warn_notPinned = "This pad is not in anyone's CryptDrive. It will expire after 3 months. <a href='/about.html#pinning'>Learn more...</a>";
// markdown toolbar // markdown toolbar
out.mdToolbar_button = "Show or hide the Markdown toolbar"; out.mdToolbar_button = "Show or hide the Markdown toolbar";
out.mdToolbar_defaultText = "Your text here"; out.mdToolbar_defaultText = "Your text here";
@ -996,9 +995,6 @@ define(function () {
// Header.html // Header.html
out.header_france = '<a href="http://www.xwiki.com/" target="_blank" rel="noopener noreferrer">With <img class="bottom-bar-heart" src="/customize/heart.png" alt="love" /> from <img class="bottom-bar-fr" src="/customize/fr.png" title="France" alt="France"/> by <img src="/customize/logo-xwiki.png" alt="XWiki SAS" class="bottom-bar-xwiki"/></a>';
out.header_support = '<a href="http://ng.open-paas.org/" title="OpenPaaS::ng" target="_blank" rel="noopener noreferrer"> <img src="/customize/openpaasng.png" alt="OpenPaaS-ng" class="bottom-bar-openpaas" /></a>';
out.updated_0_header_logoTitle = 'Go to your CryptDrive'; out.updated_0_header_logoTitle = 'Go to your CryptDrive';
out.header_logoTitle = out.updated_0_header_logoTitle; out.header_logoTitle = out.updated_0_header_logoTitle;
out.header_homeTitle = 'Go to CryptPad homepage'; out.header_homeTitle = 'Go to CryptPad homepage';

@ -482,13 +482,44 @@ define([
'class': 'fa fa-upload cp-toolbar-icon-import', 'class': 'fa fa-upload cp-toolbar-icon-import',
title: Messages.importButtonTitle, title: Messages.importButtonTitle,
}).append($('<span>', {'class': 'cp-toolbar-drawer-element'}).text(Messages.importButton)); }).append($('<span>', {'class': 'cp-toolbar-drawer-element'}).text(Messages.importButton));
if (callback) { /*if (data.types) {
// New import button in the toolbar
var importFunction = {
template: function () {
UIElements.openTemplatePicker(common, true);
},
file: function (cb) {
importContent('text/plain', function (content, file) {
cb(content, file);
}, {accept: data ? data.accept : undefined})
}
};
var toImport = [];
Object.keys(data.types).forEach(function (importType) {
if (!importFunction[importType] || !data.types[importType]) { return; }
var option = h('button', importType);
$(option).click(function () {
importFunction[importType](data.types[importType]);
});
toImport.push(options);
});
button.click(common.prepareFeedback(type));
if (toImport.length === 1) {
button.click(function () { $(toImport[0]).click(); });
} else {
Cryptpad.alert(h('p.cp-import-container', toImport));
}
}
else if (callback) {*/
// Old import button, used in settings
button button
.click(common.prepareFeedback(type)) .click(common.prepareFeedback(type))
.click(importContent('text/plain', function (content, file) { .click(importContent('text/plain', function (content, file) {
callback(content, file); callback(content, file);
}, {accept: data ? data.accept : undefined})); }, {accept: data ? data.accept : undefined}));
} //}
break; break;
case 'upload': case 'upload':
button = $('<button>', { button = $('<button>', {
@ -520,6 +551,17 @@ define([
if (data.accept) { $input.attr('accept', data.accept); } if (data.accept) { $input.attr('accept', data.accept); }
button.click(function () { $input.click(); }); button.click(function () { $input.click(); });
break; break;
case 'importtemplate':
button = $('<button>', {
'class': 'fa fa-upload cp-toolbar-icon-import',
title: Messages.template_import,
}).append($('<span>', {'class': 'cp-toolbar-drawer-element'}).text(Messages.template_import));
button
.click(common.prepareFeedback(type))
.click(function () {
UIElements.openTemplatePicker(common, true);
});
break;
case 'template': case 'template':
if (!AppConfig.enableTemplates) { return; } if (!AppConfig.enableTemplates) { return; }
if (!common.isLoggedIn()) { return; } if (!common.isLoggedIn()) { return; }
@ -584,7 +626,8 @@ define([
sframeChan.query('Q_MOVE_TO_TRASH', null, function (err) { sframeChan.query('Q_MOVE_TO_TRASH', null, function (err) {
if (err) { return void callback(err); } if (err) { return void callback(err); }
var cMsg = common.isLoggedIn() ? Messages.movedToTrash : Messages.deleted; var cMsg = common.isLoggedIn() ? Messages.movedToTrash : Messages.deleted;
UI.alert(cMsg, undefined, true); var msg = common.fixLinks($('<div>').html(cMsg));
UI.alert(msg);
callback(); callback();
return; return;
}); });
@ -920,18 +963,7 @@ define([
h('ul', elements) h('ul', elements)
]); ]);
var origin = common.getMetadataMgr().getPrivateData().origin || ''; common.fixLinks(text);
$(text).find('a').click(function (e) {
e.preventDefault();
e.stopPropagation();
var href = $(this).attr('href');
var absolute = /^https?:\/\//i;
if (!absolute.test(href)) {
if (href.slice(0,1) !== '/') { href = '/' + href; }
href = origin + href;
}
common.openUnsafeURL(href);
});
var closeButton = h('span.cp-help-close.fa.fa-window-close'); var closeButton = h('span.cp-help-close.fa.fa-window-close');
var $toolbarButton = common.createButton('', true, { var $toolbarButton = common.createButton('', true, {
@ -1422,50 +1454,51 @@ define([
tag: 'a', tag: 'a',
attributes: { attributes: {
'target': '_blank', 'target': '_blank',
'href': origin+'/drive/' 'href': origin+'/drive/',
'class': 'fa fa-hdd-o'
}, },
content: Messages.login_accessDrive content: h('span', Messages.login_accessDrive)
}); });
} }
// Add the change display name button if not in read only mode // Add the change display name button if not in read only mode
if (config.changeNameButtonCls && config.displayChangeName && !AppConfig.disableProfile) { if (config.changeNameButtonCls && config.displayChangeName && !AppConfig.disableProfile) {
options.push({ options.push({
tag: 'a', tag: 'a',
attributes: {'class': config.changeNameButtonCls}, attributes: {'class': config.changeNameButtonCls + ' fa fa-user'},
content: Messages.user_rename content: h('span', Messages.user_rename)
}); });
} }
if (accountName && !AppConfig.disableProfile) { if (accountName && !AppConfig.disableProfile) {
options.push({ options.push({
tag: 'a', tag: 'a',
attributes: {'class': 'cp-toolbar-menu-profile'}, attributes: {'class': 'cp-toolbar-menu-profile fa fa-user-circle'},
content: Messages.profileButton content: h('span', Messages.profileButton)
}); });
} }
if (padType !== 'settings') { if (padType !== 'settings') {
options.push({ options.push({
tag: 'a', tag: 'a',
attributes: {'class': 'cp-toolbar-menu-settings'}, attributes: {'class': 'cp-toolbar-menu-settings fa fa-cog'},
content: Messages.settingsButton content: h('span', Messages.settingsButton)
}); });
} }
// Add login or logout button depending on the current status // Add login or logout button depending on the current status
if (accountName) { if (accountName) {
options.push({ options.push({
tag: 'a', tag: 'a',
attributes: {'class': 'cp-toolbar-menu-logout'}, attributes: {'class': 'cp-toolbar-menu-logout fa fa-sign-out'},
content: Messages.logoutButton content: h('span', Messages.logoutButton)
}); });
} else { } else {
options.push({ options.push({
tag: 'a', tag: 'a',
attributes: {'class': 'cp-toolbar-menu-login'}, attributes: {'class': 'cp-toolbar-menu-login fa fa-sign-in'},
content: Messages.login_login content: h('span', Messages.login_login)
}); });
options.push({ options.push({
tag: 'a', tag: 'a',
attributes: {'class': 'cp-toolbar-menu-register'}, attributes: {'class': 'cp-toolbar-menu-register fa fa-user-plus'},
content: Messages.login_register content: h('span', Messages.login_register)
}); });
} }
var $icon = $('<span>', {'class': 'fa fa-user-secret'}); var $icon = $('<span>', {'class': 'fa fa-user-secret'});
@ -1521,9 +1554,8 @@ define([
UIElements.displayAvatar(Common, $avatar, url, UIElements.displayAvatar(Common, $avatar, url,
newName || Messages.anonymous, function ($img) { newName || Messages.anonymous, function ($img) {
oldUrl = url; oldUrl = url;
if ($img) { $userAdmin.find('> button').removeClass('cp-avatar');
$userAdmin.find('> button').addClass('cp-avatar'); if ($img) { $userAdmin.find('> button').addClass('cp-avatar'); }
}
loadingAvatar = false; loadingAvatar = false;
}); });
return; return;
@ -1742,7 +1774,7 @@ define([
sframeChan.event("EV_FILE_PICKER_OPEN", types); sframeChan.event("EV_FILE_PICKER_OPEN", types);
}; };
UIElements.openTemplatePicker = function (common) { UIElements.openTemplatePicker = function (common, force) {
var metadataMgr = common.getMetadataMgr(); var metadataMgr = common.getMetadataMgr();
var type = metadataMgr.getMetadataLazy().type; var type = metadataMgr.getMetadataLazy().type;
var sframeChan = common.getSframeChannel(); var sframeChan = common.getSframeChannel();
@ -1782,10 +1814,13 @@ define([
if (data) { if (data) {
common.openFilePicker(pickerCfg); common.openFilePicker(pickerCfg);
focus = document.activeElement; focus = document.activeElement;
if (force) { return void onConfirm(true); }
UI.confirm(Messages.useTemplate, onConfirm, { UI.confirm(Messages.useTemplate, onConfirm, {
ok: Messages.useTemplateOK, ok: Messages.useTemplateOK,
cancel: Messages.useTemplateCancel, cancel: Messages.useTemplateCancel,
}); });
} else if (force) {
UI.alert(Messages.template_empty);
} }
}); });
}; };

@ -34,6 +34,10 @@ define(['json.sortify'], function (Sortify) {
} }
if (!metadataObj.users) { metadataObj.users = {}; } if (!metadataObj.users) { metadataObj.users = {}; }
if (!metadataLazyObj.users) { metadataLazyObj.users = {}; } if (!metadataLazyObj.users) { metadataLazyObj.users = {}; }
if (!metadataObj.type) { metadataObj.type = meta.doc.type; }
if (!metadataLazyObj.type) { metadataLazyObj.type = meta.doc.type; }
var mdo = {}; var mdo = {};
// We don't want to add our user data to the object multiple times. // We don't want to add our user data to the object multiple times.
//var containsYou = false; //var containsYou = false;

@ -572,6 +572,9 @@ define([
toolbar.$rightside.append($templateButton); toolbar.$rightside.append($templateButton);
} }
var $importTemplateButton = common.createButton('importtemplate', true);
toolbar.$drawer.append($importTemplateButton);
/* add a forget button */ /* add a forget button */
toolbar.$rightside.append(common.createButton('forget', true, {}, function (err) { toolbar.$rightside.append(common.createButton('forget', true, {}, function (err) {
if (err) { return; } if (err) { return; }

@ -643,10 +643,19 @@ define([
replaceHash(Utils.Hash.getEditHashFromKeys(wc, secret.keys)); replaceHash(Utils.Hash.getEditHashFromKeys(wc, secret.keys));
} }
}; };
Object.keys(rtConfig).forEach(function (k) {
cpNfCfg[k] = rtConfig[k]; nThen(function (waitFor) {
if (isNewFile && cfg.owned && !window.location.hash) {
Cryptpad.getMetadata(waitFor(function (err, m) {
cpNfCfg.owners = [m.priv.edPublic];
}));
}
}).nThen(function () {
Object.keys(rtConfig).forEach(function (k) {
cpNfCfg[k] = rtConfig[k];
});
CpNfOuter.start(cpNfCfg);
}); });
CpNfOuter.start(cpNfCfg);
}; };
sframeChan.on('Q_CREATE_PAD', function (data, cb) { sframeChan.on('Q_CREATE_PAD', function (data, cb) {

@ -343,6 +343,27 @@ define([
window.open(bounceHref); window.open(bounceHref);
}; };
funcs.fixLinks = function (domElement) {
var origin = ctx.metadataMgr.getPrivateData().origin;
$(domElement).find('a[target="_blank"]').click(function (e) {
e.preventDefault();
e.stopPropagation();
var href = $(this).attr('href');
var absolute = /^https?:\/\//i;
if (!absolute.test(href)) {
if (href.slice(0,1) !== '/') { href = '/' + href; }
href = origin + href;
}
funcs.openUnsafeURL(href);
});
$(domElement).find('a[target!="_blank"]').click(function (e) {
e.preventDefault();
e.stopPropagation();
funcs.gotoURL($(this).attr('href'));
});
return $(domElement)[0];
};
funcs.whenRealtimeSyncs = evRealtimeSynced.reg; funcs.whenRealtimeSyncs = evRealtimeSynced.reg;
var logoutHandlers = []; var logoutHandlers = [];

@ -370,7 +370,8 @@ define([
currentPath = [FILES_DATA]; currentPath = [FILES_DATA];
$tree.hide(); $tree.hide();
if (Object.keys(files.root).length && !proxy.anonymousAlert) { if (Object.keys(files.root).length && !proxy.anonymousAlert) {
UI.alert(Messages.fm_alert_anonymous, null, true); var msg = common.fixLinks($('<div>').html(Messages.fm_alert_anonymous));
UI.alert(msg);
proxy.anonymousAlert = true; proxy.anonymousAlert = true;
} }
} }
@ -1516,13 +1517,7 @@ define([
} }
if (!APP.loggedIn) { if (!APP.loggedIn) {
msg = Messages.fm_info_anonymous; msg = Messages.fm_info_anonymous;
$box.html(msg); return $(common.fixLinks($box.html(msg)));
$box.find('a[target!="_blank"]').click(function (e) {
e.preventDefault();
var href = $(this).attr('href');
common.gotoURL(href);
});
return $box;
} }
if (!msg || APP.store['hide-info-' + path[0]] === '1') { if (!msg || APP.store['hide-info-' + path[0]] === '1') {
$box.hide(); $box.hide();

@ -93,6 +93,7 @@ define([
getSecrets: getSecrets, getSecrets: getSecrets,
noHash: true, // Don't add the hash in the URL if it doesn't already exist noHash: true, // Don't add the hash in the URL if it doesn't already exist
addRpc: addRpc, addRpc: addRpc,
owned: true
}); });
}); });
}); });

@ -46,6 +46,7 @@ define([
SFCommonO.start({ SFCommonO.start({
getSecrets: getSecrets, getSecrets: getSecrets,
noHash: true, noHash: true,
owned: true
}); });
}); });
}); });

Loading…
Cancel
Save