From 7970f5026bac74817cd6b1f2246e716ae9045d83 Mon Sep 17 00:00:00 2001 From: ansuz Date: Thu, 14 May 2020 18:53:14 -0400 Subject: [PATCH 01/12] add support for displaying languages that administrators understand on the support panel --- customize.dist/application_config.js | 2 ++ www/support/inner.js | 29 +++++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/customize.dist/application_config.js b/customize.dist/application_config.js index a7ad90f11..0187cf74b 100644 --- a/customize.dist/application_config.js +++ b/customize.dist/application_config.js @@ -9,5 +9,7 @@ define(['/common/application_config_internal.js'], function (AppConfig) { // Example: If you want to remove the survey link in the menu: // AppConfig.surveyURL = ""; + AppConfig.supportLanguages = [ 'en', 'fr' ]; // XXX + return AppConfig; }); diff --git a/www/support/inner.js b/www/support/inner.js index 701d01817..48bb1c4ef 100644 --- a/www/support/inner.js +++ b/www/support/inner.js @@ -11,6 +11,7 @@ define([ '/common/hyperscript.js', '/support/ui.js', '/api/config', + '/customize/application_config.js', 'css!/bower_components/bootstrap/dist/css/bootstrap.min.css', 'css!/bower_components/components-font-awesome/css/font-awesome.min.css', @@ -27,7 +28,8 @@ define([ Messages, h, Support, - ApiConfig + ApiConfig, + AppConfig ) { var APP = window.APP = {}; @@ -41,6 +43,7 @@ define([ 'cp-support-list', ], 'new': [ + 'cp-support-language', 'cp-support-form', ], }; @@ -132,6 +135,30 @@ define([ return $div; }; + create['language'] = function () { + if (!Array.isArray(AppConfig.supportLanguages)) { return $(h('div')); } + var languages = AppConfig.supportLanguages; + + var list = h('li', languages + .map(function (lang) { + return Messages._languages[lang]; + }) + .filter(Boolean) + .map(function (lang) { + return h('li', lang); + }) + ); + + var preamble = "This server's administrators speak the following languages:"; // XXX + var $div = $( + h('div.cp-support-language', [ + preamble, + list, + ]) + ); + return $div; + }; + // Create a new tickets create['form'] = function () { var key = 'form'; From 704557fb2e75e50a5d1da3b7120b05349b29e6a0 Mon Sep 17 00:00:00 2001 From: ansuz Date: Wed, 3 Jun 2020 13:29:38 -0400 Subject: [PATCH 02/12] prototype info menu --- www/common/common-ui-elements.js | 114 +++++++++++++++++++++++-------- 1 file changed, 85 insertions(+), 29 deletions(-) diff --git a/www/common/common-ui-elements.js b/www/common/common-ui-elements.js index 0caa39c92..9b15659d6 100644 --- a/www/common/common-ui-elements.js +++ b/www/common/common-ui-elements.js @@ -2255,6 +2255,80 @@ define([ return $container; }; + UIElements.displayInfoMenu = function (Common, metadataMgr) { + var padType = metadataMgr.getMetadata().type; + var priv = metadataMgr.getPrivateData(); + var origin = priv.origin; + + Messages.help_faq = "Review our list of frequently asked questions"; // XXX + var faqLine = h('p', + h('a', { + target: '_blank', + rel: 'noreferrer noopener', + href: origin + '/faq.html', + }, Messages.help_faq) + ); + + var supportLine; + if (padType === 'support' || !Config.supportMailbox) { + // do nothing + } else if (priv.accountName) { + // registered users can submit support tickets + Messages.help_support = "Submit a support ticket"; // XXX + supportLine = h('p', [ + h('a', { + target: '_blank', + rel: 'noreferrer noopener', + href: origin + '/support/', + }, Messages.help_support) + ]); + } else { + // register to submit support tickets + Messages.help_supportRegisteredOnly = "Registered users can submit support tickets"; // XXX + var login = h('button', Messages.login_login); + $(login).click(function () { + Common.setLoginRedirect(function () { + Common.gotoURL('/login/'); + }); + }); + var register = h('button', Messages.login_register); + $(register).click(function () { + Common.setLoginRedirect(function () { + Common.gotoURL('/register/'); + }); + }); + supportLine = h('span', [ + Messages.help_supportRegisteredOnly, + h('div', [ + login, + register, + ]) + ]); + } + + var content = h('div', [ + // CryptPad version number + h('h6', Pages.versionString), + // First point users to our FAQ + faqLine, + // Link to the support ticket form in case their + // question isn't answered by the FAQ + supportLine, + ]); + + var buttons = [ + { + className: 'primary', + name: Messages.filePicker_close, + onClick: function () {}, + keys: [27], + }, + ]; + + var modal = UI.dialog.customModal(content, {buttons: buttons }); + UI.openCustomModal(modal); + }; + UIElements.createUserAdminMenu = function (Common, config) { var metadataMgr = Common.getMetadataMgr(); @@ -2366,7 +2440,6 @@ define([ }, }); } - options.push({ tag: 'hr' }); // Add administration panel link if the user is an admin if (priv.edPublic && Array.isArray(Config.adminKeys) && Config.adminKeys.indexOf(priv.edPublic) !== -1) { options.push({ @@ -2382,20 +2455,6 @@ define([ }, }); } - if (padType !== 'support' && accountName && Config.supportMailbox) { - options.push({ - tag: 'a', - attributes: {'class': 'cp-toolbar-menu-support fa fa-life-ring'}, - content: h('span', Messages.supportPage || 'Support'), - action: function () { - if (padType) { - window.open(origin+'/support/'); - } else { - window.parent.location = origin+'/support/'; - } - }, - }); - } options.push({ tag: 'hr' }); if (Config.allowSubscriptions) { options.push({ @@ -2435,20 +2494,17 @@ define([ }, }); } - if (Pages.versionString) { - Messages.user_about = Messages.about; // XXX "About CryptPad" - options.push({ - tag: 'a', - attributes: { - 'class': 'cp-toolbar-about fa fa-info', - }, - content: h('span', Messages.user_about), - action: function () { - // XXX UIElements.createHelpButton - UI.alert(Pages.versionString); - }, - }); - } + Messages.user_about = 'About CryptPad'; // XXX + options.push({ + tag: 'a', + attributes: { + 'class': 'cp-toolbar-about fa fa-info', + }, + content: h('span', Messages.user_about), + action: function () { + UIElements.displayInfoMenu(Common, metadataMgr); + }, + }); options.push({ tag: 'hr' }); // Add login or logout button depending on the current status From 26f861f3be1a2953713ce7e3db38d497135cdfce Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 4 Jun 2020 12:17:21 +0200 Subject: [PATCH 03/12] Add Turkish translation --- www/common/translations/messages.tr.json | 1 + 1 file changed, 1 insertion(+) create mode 100644 www/common/translations/messages.tr.json diff --git a/www/common/translations/messages.tr.json b/www/common/translations/messages.tr.json new file mode 100644 index 000000000..0967ef424 --- /dev/null +++ b/www/common/translations/messages.tr.json @@ -0,0 +1 @@ +{} From 259b3bca65ca5133122f2012bed7c0a522e9db9a Mon Sep 17 00:00:00 2001 From: ansuz Date: Mon, 8 Jun 2020 15:34:20 -0400 Subject: [PATCH 04/12] use safe links by default --- www/common/drive-ui.js | 2 +- www/common/inner/access.js | 2 +- www/common/migrate-user-object.js | 36 ++++++++++++++++++++++++++-- www/common/notifications.js | 15 ++++++++++++ www/common/outer/mailbox-handlers.js | 6 +++++ www/common/sframe-common-outer.js | 5 ++-- 6 files changed, 60 insertions(+), 6 deletions(-) diff --git a/www/common/drive-ui.js b/www/common/drive-ui.js index 8c8d7f5f1..b86da80ec 100644 --- a/www/common/drive-ui.js +++ b/www/common/drive-ui.js @@ -1097,7 +1097,7 @@ define([ var priv = metadataMgr.getPrivateData(); var useUnsafe = Util.find(priv, ['settings', 'security', 'unsafeLinks']); - if (useUnsafe !== false) { // true of undefined: use unsafe links + if (useUnsafe === true) { return void window.open(APP.origin + href); } diff --git a/www/common/inner/access.js b/www/common/inner/access.js index 55a4dbbe9..190af4279 100644 --- a/www/common/inner/access.js +++ b/www/common/inner/access.js @@ -874,7 +874,7 @@ define([ // Use hidden hash if needed (we're an owner of this pad so we know it is stored) var useUnsafe = Util.find(priv, ['settings', 'security', 'unsafeLinks']); var href = (priv.readOnly && data.roHref) ? data.roHref : data.href; - if (useUnsafe === false) { + if (useUnsafe !== true) { var newParsed = Hash.parsePadUrl(href); var newSecret = Hash.getSecrets(newParsed.type, newParsed.hash, newPass); var newHash = Hash.getHiddenHashFromKeys(parsed.type, newSecret, {}); diff --git a/www/common/migrate-user-object.js b/www/common/migrate-user-object.js index 18bc9c61b..231c39ebd 100644 --- a/www/common/migrate-user-object.js +++ b/www/common/migrate-user-object.js @@ -7,9 +7,10 @@ define([ '/common/cryptget.js', '/common/outer/mailbox.js', '/customize/messages.js', + '/common/common-realtime.js', '/bower_components/nthen/index.js', '/bower_components/chainpad-crypto/crypto.js', -], function (AppConfig, Feedback, Hash, Util, Messaging, Crypt, Mailbox, Messages, nThen, Crypto) { +], function (AppConfig, Feedback, Hash, Util, Messaging, Crypt, Mailbox, Messages, Realtime, nThen, Crypto) { // Start migration check // Versions: // 1: migrate pad attributes @@ -456,6 +457,37 @@ define([ if (version < 10) { fixTodo(); } + }).nThen(function (waitFor) { + if (version >= 11) { return; } + // Migration 11: alert users of safe links as the new default + + var done = function () { + Feedback.send('Migrate-11', true); + userObject.version = version = 11; + }; + + /* userObject.settings.security.unsafeLinks + undefined => the user has never touched it + false => the user has explicitly enabled "safe links" + true => the user has explicitly disabled "safe links" + */ + var unsafeLinks = Util.find(userObject, [ 'settings', 'security', 'unsafeLinks' ]); + if (unsafeLinks !== undefined) { return void done(); } + + var ctx = { + store: store, + }; + var myData = Messaging.createData(userObject); + + Mailbox.sendTo(ctx, 'SAFE_LINKS_DEFAULT', { + user: myData, + }, { + channel: myData.notifications, + curvePublic: myData.curvePublic + }, waitFor(function (obj) { + if (obj && obj.error) { return void console.error(obj); } + done(); + })); /*}).nThen(function (waitFor) { // Test progress bar in the loading screen var i = 0; @@ -467,7 +499,7 @@ define([ }, 500); progress(0, 0);*/ }).nThen(function () { - setTimeout(cb); + Realtime.whenRealtimeSyncs(store.realtime, Util.bake(cb)); }); }; }); diff --git a/www/common/notifications.js b/www/common/notifications.js index 3abc40ca8..94c2dcb15 100644 --- a/www/common/notifications.js +++ b/www/common/notifications.js @@ -387,6 +387,21 @@ define([ } }; + handlers['SAFE_LINKS_DEFAULT'] = function (common, data) { + Messages.settings_safeLinkDefault = "SAFE LINKS ARE NOW DEFAULT"; // XXX + + var content = data.content; + content.getFormatText = function () { + return Messages.settings_safeLinkDefault; + }; + + content.handler = function () { + common.openURL('/settings/#security'); + }; + if (!content.archived) { + content.dismissHandler = defaultDismiss(common, data); + } + }; // NOTE: don't forget to fixHTML everything returned by "getFormatText" diff --git a/www/common/outer/mailbox-handlers.js b/www/common/outer/mailbox-handlers.js index a55a2d63d..6d10b089f 100644 --- a/www/common/outer/mailbox-handlers.js +++ b/www/common/outer/mailbox-handlers.js @@ -515,6 +515,12 @@ define([ cb(); }; + handlers["SAFE_LINKS_DEFAULT"] = function (ctx, box, data, cb) { // XXX + var curve = ctx.store.proxy.curvePublic; + if (data.msg.author !== curve) { return void cb(true); } + cb(); + }; + // Hide duplicates when receiving a SHARE_PAD notification: // Keep only one notification per channel: the stronger and more recent one var comments = {}; diff --git a/www/common/sframe-common-outer.js b/www/common/sframe-common-outer.js index b5baf6301..71ecd6dcf 100644 --- a/www/common/sframe-common-outer.js +++ b/www/common/sframe-common-outer.js @@ -823,7 +823,7 @@ define([ var opts = parsed.getOptions(); var hash = Utils.Hash.getHiddenHashFromKeys(parsed.type, secret, opts); var useUnsafe = Utils.Util.find(settings, ['security', 'unsafeLinks']); - if (useUnsafe === false && window.history && window.history.replaceState) { + if (useUnsafe !== true && window.history && window.history.replaceState) { if (!/^#/.test(hash)) { hash = '#' + hash; } window.history.replaceState({}, window.document.title, hash); } @@ -854,6 +854,7 @@ define([ path: initialPathInDrive, // Where to store the pad if we don't have it in our drive forceSave: true }; + // XXX copypaste from above... Cryptpad.setPadTitle(data, function (err) { if (!err && !(obj && obj.notStored)) { // No error and the pad was correctly stored @@ -861,7 +862,7 @@ define([ var opts = parsed.getOptions(); var hash = Utils.Hash.getHiddenHashFromKeys(parsed.type, secret, opts); var useUnsafe = Utils.Util.find(settings, ['security', 'unsafeLinks']); - if (useUnsafe === false && window.history && window.history.replaceState) { + if (useUnsafe !== true && window.history && window.history.replaceState) { if (!/^#/.test(hash)) { hash = '#' + hash; } window.history.replaceState({}, window.document.title, hash); } From 9737224281021fd29177106ded29997a2d42d4c2 Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 9 Jun 2020 10:44:37 +0200 Subject: [PATCH 05/12] Use safe links by defaults for new users --- www/common/outer/async-store.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/www/common/outer/async-store.js b/www/common/outer/async-store.js index 885bc1131..df2e2a710 100644 --- a/www/common/outer/async-store.js +++ b/www/common/outer/async-store.js @@ -41,6 +41,9 @@ define([ pad: { width: true }, + security: { + unsafeLinks: false + }, general: { allowUserFeedback: true } From c514471c2e56328cfd280bb609ab695d833fa0ba Mon Sep 17 00:00:00 2001 From: Weblate Date: Tue, 9 Jun 2020 15:14:32 +0200 Subject: [PATCH 06/12] Translated using Weblate (Romanian) Currently translated at 44.0% (564 of 1281 strings) Translation: CryptPad/App Translate-URL: http://weblate.cryptpad.fr/projects/cryptpad/app/ro/ --- www/common/translations/messages.ro.json | 48 ++++++++++++++++++++---- 1 file changed, 40 insertions(+), 8 deletions(-) diff --git a/www/common/translations/messages.ro.json b/www/common/translations/messages.ro.json index 5b744e4a7..6572c00e4 100644 --- a/www/common/translations/messages.ro.json +++ b/www/common/translations/messages.ro.json @@ -14,7 +14,7 @@ "error": "Eroare", "saved": "Salvat", "synced": "Totul a fost salvat", - "deleted": "Pad șters din CryptDrive-ul tău", + "deleted": "Șters", "disconnected": "Deconectat", "synchronizing": "Se sincronizează", "reconnecting": "Reconectare...", @@ -239,7 +239,7 @@ "settings_pinningNotAvailable": "Pad-urile fixate sunt disponibile doar utilizatorilor înregistrați.", "settings_pinningError": "Ceva nu a funcționat", "settings_usageAmount": "Pad-urile tale fixate ocupă {0}MB", - "settings_logoutEverywhereTitle": "Deloghează-te peste tot", + "settings_logoutEverywhereTitle": "Închide sesiunile remote", "settings_logoutEverywhere": "Deloghează-te din toate sesiunile web", "settings_logoutEverywhereConfirm": "Ești sigur? Va trebui să te loghezi, din nou, pe toate device-urile tale.", "upload_serverError": "Eroare de server: fișierele tale nu pot fi încărcate la momentul acesta.", @@ -317,7 +317,8 @@ "todo": "De facut", "contacts": "Contacte", "sheet": "Foaie de calcul", - "kanban": "Foaie Kanban" + "kanban": "Foaie Kanban", + "teams": "Echipe" }, "button_newkanban": "Kanban nou", "padNotPinned": "Aceasta filă va expira după 3 luni de inactivitate, {0}autentifică-te{1} sau {2}înregistrează-te{3} pentru a o păstra.", @@ -455,7 +456,7 @@ "profile_create": "Crează un profil", "profile_description": "Descriere", "profile_fieldSaved": "Valoare nouă salvată: {0}", - "userlist_addAsFriendTitle": "Adaugă \"{0}\" în lista de contacte", + "userlist_addAsFriendTitle": "Trimite o cerere de contact către \"{0}\"", "canvas_currentBrush": "Culoarea curentă", "profile_viewMyProfile": "Vezi profilul tău", "contacts_title": "Contacte", @@ -477,7 +478,7 @@ "contacts_confirmRemoveHistory": "Ești sigur că vrei să ștergi definitiv istoricul chat-ului? Datele nu vor putea fi recuperate", "contacts_removeHistoryServerError": "A apărut o eroare în timpul ștergerii istoricului chat-ului. Te rugăm să încerci mai târziu", "contacts_fetchHistory": "Recuperează istoricul mai vechi", - "contacts_friends": "Prieteni", + "contacts_friends": "Persoane de contact", "contacts_rooms": "Camere", "contacts_leaveRoom": "Părăsește această cameră", "contacts_online": "Un alt utilizator din această cameră este online", @@ -492,7 +493,7 @@ "fm_removePermanentlyNote": "Pad-urile tale vor fi șterse de pe server dacă vei continua", "fm_deleteOwnedPad": "Ești sigur că vrei să ștergi definitiv acest pad de pe server?", "fm_deleteOwnedPads": "Ești sigur că vrei să ștergi definitiv aceste pad-uri de pe server?", - "fm_info_recent": "Listează pad-urile deschise sau modificate recent", + "fm_info_recent": "Aceste documente au fost deschise sau modificate recent de către tine sau de către colaboratorii tăi.", "fm_info_sharedFolder": "Acesta este un dosar partajat. Deoarece nu ești logat, îl poți vizualiza doar în modul citire.
Înscrie-te sau Log in pentru a-l putea importa in CryptDrive-ul tău si a-l modifica.", "fm_info_owned": "Ești proprietarul pad-urilor afișate aici. Acest lucru înseamna că le poți șterge definitiv de pe server oricând vei dori. Dacă decizi să le ștergi, alți utilizatori nu le vor mai putea accesa.", "fm_error_cantPin": "O eroare internă de server a apărut. Te rugăm să reîncarci pagina și să încerci din nou.", @@ -510,7 +511,7 @@ "fm_tags_used": "Numărul de utilizări", "fm_restoreDrive": "Drive-ul tău va fi setat la o versiune aneterioară. Pentru a obține cele mai bune rezultate, te rugăm să eviți să aduci modificări în drive-ul tău până când procesul va fi terminat.", "fm_moveNestedSF": "Nu poti plasa un folder partajat în interiorul altuia. Folderul {0} nu a fost mutat.", - "fm_passwordProtected": "Acest document este protejat cu o parolă", + "fm_passwordProtected": "Parolă protejată", "fc_newsharedfolder": "Folder partajat nou", "fc_delete_owned": "Șterge de pe server", "fc_remove_sharedfolder": "Șterge", @@ -547,5 +548,36 @@ "settings_resetNewTitle": "Curățare CryptDrive", "settings_resetButton": "Șterge", "settings_resetTipsAction": "Resetează", - "settings_thumbnails": "Miniaturi" + "settings_thumbnails": "Miniaturi", + "settings_padWidth": "Lățimea maximă a editorului", + "settings_codeFontSize": "Dimensiunea font-ului in editorul de cod", + "settings_codeUseTabs": "Indentarea prin etichete (în loc de spații)", + "settings_codeIndentation": "Indentarea editorului de cod (spații)", + "settings_driveDuplicateLabel": "Ascunde duplicatele", + "settings_driveDuplicateHint": "Când deplasezi documentele tale într-un dosar comun, o copie este păstrată în CryptDrive-ul tău pentru asigura păstrarea drepturilor tale de control asupra lui. Poți ascunde fișierele duplicate. Doar versiunea partajata va fi vizibilă, dacă nu este ștearsă, în acest ultim caz originalul va fi afișat în locația precedentă.", + "settings_driveDuplicateTitle": "Documentele tale duplicate", + "register_emailWarning3": "Dacă înțelegeți aceste aspecte și dorești totuși să utilizezi adresa ta de e-mail ca și nume de utilizator, apasă OK.", + "padNotPinnedVariable": "Acest document va expira dupa {4} zile de inactivitate, {0}autentifică-te{1} sau {2}creează-ți un cont{3} pentru a-l pastra.", + "settings_logoutEverywhereButton": "Deconectează-te", + "settings_deleted": "Contul tău de utilizator este șters. Apasă OK pentru a reveni la pagina principală.", + "settings_deleteConfirm": "Dacă apeși OK, contul tău va fi șters permanent. Ești sigur?", + "settings_deleteModal": "Furnizează aceste informații administratorului CryptPad-ului tău astfel încât acestea să fie șterse de pe server.", + "settings_deleteButton": "Șterge contul tău", + "settings_deleteHint": "Ștergerea contului este permanentă. Cryptdrive-ul tău și lista ta de documente vor fi șterse de pe server. Restul documentelor vor fi șterse în timp de 90 de zile dacă nimeni nu le stochează în CryptDrive-ul său.", + "settings_deleteTitle": "Ștergere cont", + "settings_userFeedbackTitle": "Feedback", + "settings_autostoreMaybe": "Manual (întreabă întotdeauna)", + "settings_autostoreNo": "Manual (nu mai întreba)", + "settings_autostoreYes": "Automat", + "settings_autostoreHint": "Automat Toate documentele accesate sunt stocate în CryptDrive-ul dumneavoastră.
Manual (întreabă întotdeauna) Dacă nu ai stocat încă un document, vei fi întrebat dacă dorești să îl stochezi în Cryptdrive-ul tău.
Manual (nu mai întreba) Documentele nu sunt stocate automat în Cryptpad-ul tău. Opțiunea de a le stoca ulterior va fi ascunsă.", + "settings_autostoreTitle": "Capacitatea de stocare a documentului în CryptDrive", + "register_emailWarning2": "Nu vei putea reseta parola utilizând adresa ta de e-mail.", + "register_emailWarning1": "Poți proceda astfel dacă doreşti, însă nici o notificare nu va fi transmisă server-ului nostru.", + "register_emailWarning0": "Se pare că ai adăugat adresa ta de e-mail în loc de numele tău de utilizator.", + "fc_expandAll": "Extinde", + "fc_openInCode": "Deschide in editorul de cod", + "fc_color": "Schimbă culoarea", + "fm_morePads": "Mai mult", + "uploadFolderButton": "Încarcă dosar", + "storageStatus": "Capacitate de stocare:
{0} utilizat din {1}" } From c9ed27c65201c32a6322efab181832ca75310aeb Mon Sep 17 00:00:00 2001 From: ansuz Date: Tue, 9 Jun 2020 13:11:52 -0400 Subject: [PATCH 07/12] display the admin's supported languages inline in the support ticket form --- www/support/app-support.less | 8 ++++++++ www/support/inner.js | 8 ++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/www/support/app-support.less b/www/support/app-support.less index c033332eb..7684c054e 100644 --- a/www/support/app-support.less +++ b/www/support/app-support.less @@ -17,5 +17,13 @@ display: flex; flex-flow: column; + + .cp-support-language-list { + .cp-support-language { + margin-left: 5px; + background-color: rgba(0, 0, 0, 0.1); + padding: 0 5px; + } + } } diff --git a/www/support/inner.js b/www/support/inner.js index de1164344..3d907421d 100644 --- a/www/support/inner.js +++ b/www/support/inner.js @@ -139,20 +139,20 @@ define([ if (!Array.isArray(AppConfig.supportLanguages)) { return $(h('div')); } var languages = AppConfig.supportLanguages; - var list = h('li', languages + var list = h('span.cp-support-language-list', languages .map(function (lang) { return Messages._languages[lang]; }) .filter(Boolean) .map(function (lang) { - return h('li', lang); + return h('span.cp-support-language', lang); }) ); - var preamble = "This server's administrators speak the following languages:"; // XXX + Messages.support_languagesPreamble = "This server's administrators speak the following languages:"; // XXX var $div = $( h('div.cp-support-language', [ - preamble, + Messages.support_languagesPreamble, list, ]) ); From e763f8792aa1602dc30d0e6e65613891bffa2d0e Mon Sep 17 00:00:00 2001 From: ansuz Date: Tue, 9 Jun 2020 13:28:42 -0400 Subject: [PATCH 08/12] keep the support button visible, broaden the scope of the info menu --- www/common/common-ui-elements.js | 60 ++++++++++++-------------------- 1 file changed, 22 insertions(+), 38 deletions(-) diff --git a/www/common/common-ui-elements.js b/www/common/common-ui-elements.js index b3ab9ee53..f09f3e621 100644 --- a/www/common/common-ui-elements.js +++ b/www/common/common-ui-elements.js @@ -2300,7 +2300,7 @@ define([ }; UIElements.displayInfoMenu = function (Common, metadataMgr) { - var padType = metadataMgr.getMetadata().type; + //var padType = metadataMgr.getMetadata().type; var priv = metadataMgr.getPrivateData(); var origin = priv.origin; @@ -2313,42 +2313,11 @@ define([ }, Messages.help_faq) ); - var supportLine; - if (padType === 'support' || !Config.supportMailbox) { - // do nothing - } else if (priv.accountName) { - // registered users can submit support tickets - Messages.help_support = "Submit a support ticket"; // XXX - supportLine = h('p', [ - h('a', { - target: '_blank', - rel: 'noreferrer noopener', - href: origin + '/support/', - }, Messages.help_support) - ]); - } else { - // register to submit support tickets - Messages.help_supportRegisteredOnly = "Registered users can submit support tickets"; // XXX - var login = h('button', Messages.login_login); - $(login).click(function () { - Common.setLoginRedirect(function () { - Common.gotoURL('/login/'); - }); - }); - var register = h('button', Messages.login_register); - $(register).click(function () { - Common.setLoginRedirect(function () { - Common.gotoURL('/register/'); - }); - }); - supportLine = h('span', [ - Messages.help_supportRegisteredOnly, - h('div', [ - login, - register, - ]) - ]); - } + // XXX link to the most recent changelog/release notes + // XXX FAQ + // XXX GitHub + // XXX privacy policy + // XXX legal notice var content = h('div', [ // CryptPad version number @@ -2357,7 +2326,7 @@ define([ faqLine, // Link to the support ticket form in case their // question isn't answered by the FAQ - supportLine, + //supportLine, ]); var buttons = [ @@ -2484,6 +2453,7 @@ define([ }, }); } + options.push({ tag: 'hr' }); // Add administration panel link if the user is an admin if (priv.edPublic && Array.isArray(Config.adminKeys) && Config.adminKeys.indexOf(priv.edPublic) !== -1) { options.push({ @@ -2499,6 +2469,20 @@ define([ }, }); } + if (padType !== 'support' && accountName && Config.supportMailbox) { + options.push({ + tag: 'a', + attributes: {'class': 'cp-toolbar-menu-support fa fa-life-ring'}, + content: h('span', Messages.supportPage || 'Support'), + action: function () { + if (padType) { + window.open(origin+'/support/'); + } else { + window.parent.location = origin+'/support/'; + } + }, + }); + } options.push({ tag: 'hr' }); if (Config.allowSubscriptions) { options.push({ From 3fa7a09b68413babe551b8ca2a4229de2e993623 Mon Sep 17 00:00:00 2001 From: ansuz Date: Tue, 9 Jun 2020 13:42:41 -0400 Subject: [PATCH 09/12] remove hardcoded supportLanguage config value --- customize.dist/application_config.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/customize.dist/application_config.js b/customize.dist/application_config.js index 0187cf74b..4a8820682 100644 --- a/customize.dist/application_config.js +++ b/customize.dist/application_config.js @@ -9,7 +9,8 @@ define(['/common/application_config_internal.js'], function (AppConfig) { // Example: If you want to remove the survey link in the menu: // AppConfig.surveyURL = ""; - AppConfig.supportLanguages = [ 'en', 'fr' ]; // XXX + // To inform users of the support ticket panel which languages your admins speak: + //AppConfig.supportLanguages = [ 'en', 'fr' ]; return AppConfig; }); From 85d75cd0ff5727cccb184a8081ff0744fdb04f77 Mon Sep 17 00:00:00 2001 From: ansuz Date: Tue, 9 Jun 2020 13:56:36 -0400 Subject: [PATCH 10/12] factor out a bit of duplicated code --- www/common/sframe-common-outer.js | 41 ++++++++++++------------------- 1 file changed, 16 insertions(+), 25 deletions(-) diff --git a/www/common/sframe-common-outer.js b/www/common/sframe-common-outer.js index 71ecd6dcf..ef983503c 100644 --- a/www/common/sframe-common-outer.js +++ b/www/common/sframe-common-outer.js @@ -806,16 +806,8 @@ define([ var title = currentTabTitle.replace(/\{title\}/g, currentTitle || 'CryptPad'); document.title = title; }; - sframeChan.on('Q_SET_PAD_TITLE_IN_DRIVE', function (newData, cb) { - var newTitle = newData.title || newData.defaultTitle; - currentTitle = newTitle; - setDocumentTitle(); - var data = { - password: password, - title: newTitle, - channel: secret.channel, - path: initialPathInDrive // Where to store the pad if we don't have it in our drive - }; + + var setPadTitle = function (data, cb) { Cryptpad.setPadTitle(data, function (err, obj) { if (!err && !(obj && obj.notStored)) { // No error and the pad was correctly stored @@ -830,6 +822,19 @@ define([ } cb({error: err}); }); + }; + + sframeChan.on('Q_SET_PAD_TITLE_IN_DRIVE', function (newData, cb) { + var newTitle = newData.title || newData.defaultTitle; + currentTitle = newTitle; + setDocumentTitle(); + var data = { + password: password, + title: newTitle, + channel: secret.channel, + path: initialPathInDrive // Where to store the pad if we don't have it in our drive + }; + setPadTitle(data, cb); }); sframeChan.on('EV_SET_TAB_TITLE', function (newTabTitle) { currentTabTitle = newTabTitle; @@ -854,21 +859,7 @@ define([ path: initialPathInDrive, // Where to store the pad if we don't have it in our drive forceSave: true }; - // XXX copypaste from above... - Cryptpad.setPadTitle(data, function (err) { - if (!err && !(obj && obj.notStored)) { - // No error and the pad was correctly stored - // hide the hash - var opts = parsed.getOptions(); - var hash = Utils.Hash.getHiddenHashFromKeys(parsed.type, secret, opts); - var useUnsafe = Utils.Util.find(settings, ['security', 'unsafeLinks']); - if (useUnsafe !== true && window.history && window.history.replaceState) { - if (!/^#/.test(hash)) { hash = '#' + hash; } - window.history.replaceState({}, window.document.title, hash); - } - } - cb({error: err}); - }); + setPadTitle(data, cb); }); sframeChan.on('Q_IS_PAD_STORED', function (data, cb) { Cryptpad.getPadAttribute('title', function (err, data) { From c14cb9fa2a2e43a80316101bd1709ee11e689783 Mon Sep 17 00:00:00 2001 From: ansuz Date: Tue, 9 Jun 2020 13:57:06 -0400 Subject: [PATCH 11/12] remove some XXX notes that have been addressed --- www/common/common-ui-elements.js | 1 - www/common/outer/mailbox-handlers.js | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/www/common/common-ui-elements.js b/www/common/common-ui-elements.js index f09f3e621..4393d1201 100644 --- a/www/common/common-ui-elements.js +++ b/www/common/common-ui-elements.js @@ -1364,7 +1364,6 @@ define([ case 'import': button = $('