From 9e711e4cd4fd024761f4fb10cb94adbbe47e5e7b Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 22 Mar 2018 10:49:20 +0100 Subject: [PATCH 1/7] Remove Bootstrap's JS in static pages --- customize.dist/pages.js | 25 +++++++++++++++++-------- customize.dist/template.js | 3 +-- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/customize.dist/pages.js b/customize.dist/pages.js index 4cd4f49f4..bd7ff5317 100644 --- a/customize.dist/pages.js +++ b/customize.dist/pages.js @@ -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', h('a.navbar-brand', { href: '/index.html'}), - 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, 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: '/faq.html'}, Msg.faq_link), diff --git a/customize.dist/template.js b/customize.dist/template.js index 5a702a25d..0ee34d407 100644 --- a/customize.dist/template.js +++ b/customize.dist/template.js @@ -27,8 +27,7 @@ $(function () { window.Tether = function () {}; require([ 'less!/customize/src/less2/main.less', - 'css!/bower_components/bootstrap/dist/css/bootstrap.min.css', - '/bower_components/bootstrap/dist/js/bootstrap.bundle.min.js' + 'css!/bower_components/bootstrap/dist/css/bootstrap.min.css' ], function () { $body.append($main); From db9eee383ceb5ca3014e542153dc39a99c6e98c2 Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 22 Mar 2018 15:16:19 +0100 Subject: [PATCH 2/7] Owned profile --- www/common/sframe-common-outer.js | 15 ++++++++++++--- www/profile/main.js | 1 + 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/www/common/sframe-common-outer.js b/www/common/sframe-common-outer.js index 0ba403750..431d1c74f 100644 --- a/www/common/sframe-common-outer.js +++ b/www/common/sframe-common-outer.js @@ -643,10 +643,19 @@ define([ 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) { diff --git a/www/profile/main.js b/www/profile/main.js index 234e28d8a..2449ea96b 100644 --- a/www/profile/main.js +++ b/www/profile/main.js @@ -93,6 +93,7 @@ define([ getSecrets: getSecrets, noHash: true, // Don't add the hash in the URL if it doesn't already exist addRpc: addRpc, + owned: true }); }); }); From d0c38d31e466493c3b646d0571d85a2594f2b703 Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 22 Mar 2018 15:18:41 +0100 Subject: [PATCH 3/7] Owned todo --- www/todo/main.js | 1 + 1 file changed, 1 insertion(+) diff --git a/www/todo/main.js b/www/todo/main.js index 322e2363b..b86546bf6 100644 --- a/www/todo/main.js +++ b/www/todo/main.js @@ -46,6 +46,7 @@ define([ SFCommonO.start({ getSecrets: getSecrets, noHash: true, + owned: true }); }); }); From d4dfbddaa6536093dc472f570c498a1628c7e32d Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 22 Mar 2018 15:19:14 +0100 Subject: [PATCH 4/7] Add icons in the user menu --- .../src/less2/include/dropdown.less | 16 ++++++++- www/common/common-ui-elements.js | 34 +++++++++---------- 2 files changed, 32 insertions(+), 18 deletions(-) diff --git a/customize.dist/src/less2/include/dropdown.less b/customize.dist/src/less2/include/dropdown.less index 3cf32537e..0d3552450 100644 --- a/customize.dist/src/less2/include/dropdown.less +++ b/customize.dist/src/less2/include/dropdown.less @@ -55,9 +55,23 @@ user-select: none; float: none; text-align: left; - font: @dropdown_font; 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 { width: 20px; diff --git a/www/common/common-ui-elements.js b/www/common/common-ui-elements.js index 10e00f27f..e25c3ee2e 100644 --- a/www/common/common-ui-elements.js +++ b/www/common/common-ui-elements.js @@ -1422,50 +1422,51 @@ define([ tag: 'a', attributes: { '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 if (config.changeNameButtonCls && config.displayChangeName && !AppConfig.disableProfile) { options.push({ tag: 'a', - attributes: {'class': config.changeNameButtonCls}, - content: Messages.user_rename + attributes: {'class': config.changeNameButtonCls + ' fa fa-user'}, + content: h('span', Messages.user_rename) }); } if (accountName && !AppConfig.disableProfile) { options.push({ tag: 'a', - attributes: {'class': 'cp-toolbar-menu-profile'}, - content: Messages.profileButton + attributes: {'class': 'cp-toolbar-menu-profile fa fa-user-circle'}, + content: h('span', Messages.profileButton) }); } if (padType !== 'settings') { options.push({ tag: 'a', - attributes: {'class': 'cp-toolbar-menu-settings'}, - content: Messages.settingsButton + attributes: {'class': 'cp-toolbar-menu-settings fa fa-cog'}, + content: h('span', Messages.settingsButton) }); } // Add login or logout button depending on the current status if (accountName) { options.push({ tag: 'a', - attributes: {'class': 'cp-toolbar-menu-logout'}, - content: Messages.logoutButton + attributes: {'class': 'cp-toolbar-menu-logout fa fa-sign-out'}, + content: h('span', Messages.logoutButton) }); } else { options.push({ tag: 'a', - attributes: {'class': 'cp-toolbar-menu-login'}, - content: Messages.login_login + attributes: {'class': 'cp-toolbar-menu-login fa fa-sign-in'}, + content: h('span', Messages.login_login) }); options.push({ tag: 'a', - attributes: {'class': 'cp-toolbar-menu-register'}, - content: Messages.login_register + attributes: {'class': 'cp-toolbar-menu-register fa fa-user-plus'}, + content: h('span', Messages.login_register) }); } var $icon = $('', {'class': 'fa fa-user-secret'}); @@ -1521,9 +1522,8 @@ define([ UIElements.displayAvatar(Common, $avatar, url, newName || Messages.anonymous, function ($img) { oldUrl = url; - if ($img) { - $userAdmin.find('> button').addClass('cp-avatar'); - } + $userAdmin.find('> button').removeClass('cp-avatar'); + if ($img) { $userAdmin.find('> button').addClass('cp-avatar'); } loadingAvatar = false; }); return; From 0c2987a6d123b961e049a2fad405c84049ae0d1d Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 22 Mar 2018 17:01:01 +0100 Subject: [PATCH 5/7] Import template in existing pads --- customize.dist/translations/messages.fr.js | 2 + customize.dist/translations/messages.js | 2 + www/common/common-ui-elements.js | 50 ++++++++++++++++++++-- www/common/sframe-app-framework.js | 3 ++ 4 files changed, 54 insertions(+), 3 deletions(-) diff --git a/customize.dist/translations/messages.fr.js b/customize.dist/translations/messages.fr.js index 47bce2af8..911ee3821 100644 --- a/customize.dist/translations/messages.fr.js +++ b/customize.dist/translations/messages.fr.js @@ -145,6 +145,8 @@ define(function () { out.useTemplate = "Commencer avec un modèle?"; out.useTemplateOK = 'Choisir un modèle (Entrée)'; 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"; diff --git a/customize.dist/translations/messages.js b/customize.dist/translations/messages.js index 6ab51d35d..4e81182e9 100644 --- a/customize.dist/translations/messages.js +++ b/customize.dist/translations/messages.js @@ -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.useTemplateOK = 'Pick a template (Enter)'; 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"; diff --git a/www/common/common-ui-elements.js b/www/common/common-ui-elements.js index e25c3ee2e..8cadc5c31 100644 --- a/www/common/common-ui-elements.js +++ b/www/common/common-ui-elements.js @@ -482,13 +482,44 @@ define([ 'class': 'fa fa-upload cp-toolbar-icon-import', title: Messages.importButtonTitle, }).append($('', {'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 .click(common.prepareFeedback(type)) .click(importContent('text/plain', function (content, file) { callback(content, file); }, {accept: data ? data.accept : undefined})); - } + //} break; case 'upload': button = $('