From 822256696155b7e03908c71c7e7fc6dac679b247 Mon Sep 17 00:00:00 2001 From: ansuz Date: Wed, 4 May 2022 18:35:30 +0530 Subject: [PATCH] remove some unused code, speed up home page load time --- customize.dist/pages.js | 23 +---- customize.dist/pages/index.js | 21 ++--- customize.dist/pages/what-is-cryptpad.js | 113 ----------------------- 3 files changed, 9 insertions(+), 148 deletions(-) delete mode 100644 customize.dist/pages/what-is-cryptpad.js diff --git a/customize.dist/pages.js b/customize.dist/pages.js index c9daeebfc..607ec2e57 100644 --- a/customize.dist/pages.js +++ b/customize.dist/pages.js @@ -109,7 +109,7 @@ define([ return h('a', attrs, [icon, text]); }; - Pages.versionString = "v4.14.1"; + Pages.versionString = "5.0.0"; var customURLs = Pages.customURLs = {}; (function () { @@ -146,7 +146,7 @@ define([ Pages.Instance = {}; Object.keys(Instance).forEach(function (k) { var value = Instance[k]; - var result = Pages.Instance[k] = value[l] || value.default || undefined; + Pages.Instance[k] = value[l] || value.default || undefined; }); var name; @@ -230,7 +230,7 @@ define([ }), h('span.logo-font', 'CryptPad') ]), - footLink('https://cryptpad.org', null, 'Website', 'link'), + footLink('https://cryptpad.org', null, 'Website', 'link'), // XXX translate footLink('https://opencollective.com/cryptpad/contribute/', 'footer_donate', null, 'money') // XXX DB: add OpenCollective icon ]), h('div.cp-footer-center', [ @@ -330,22 +330,5 @@ define([ return crowdFunding; }; - Pages.subscribeButton = function (onClick) { - var _link = h('a', { - href: AppConfig.upgradeURL || "/accounts/", - }); - - var subscribe = h('button', [ - Msg.features_f_subscribe, - ]); - - $(subscribe).click(function () { - _link.click(); - if (typeof(onClick) === 'function') { onClick(); } - }); - - return subscribe; - }; - return Pages; }); diff --git a/customize.dist/pages/index.js b/customize.dist/pages/index.js index dcbde792e..143c8af94 100644 --- a/customize.dist/pages/index.js +++ b/customize.dist/pages/index.js @@ -2,8 +2,6 @@ define([ 'jquery', '/api/config', '/common/hyperscript.js', - '/common/common-feedback.js', - '/common/common-interface.js', '/common/common-hash.js', '/common/common-constants.js', '/common/common-util.js', @@ -12,8 +10,7 @@ define([ '/customize/application_config.js', '/common/outer/local-store.js', '/customize/pages.js', - //'json!/api/instance', -], function ($, Config, h, Feedback, UI, Hash, Constants, Util, TextFit, Msg, AppConfig, LocalStore, Pages) { +], function ($, Config, h, Hash, Constants, Util, TextFit, Msg, AppConfig, LocalStore, Pages) { var urlArgs = Config.requireConf.urlArgs; var isAvailableType = function (x) { @@ -55,6 +52,7 @@ define([ var s = 'div.bs-callout.cp-callout-' + x[0]; var cls = ''; var isEnabled = checkRegisteredType(x[0]); + var isEAEnabled = checkEarlyAccess(x[0]); //if (i > 2) { s += '.cp-more.cp-hidden'; } var icon = AppConfig.applicationsIcon[x[0]]; @@ -62,6 +60,8 @@ define([ var href = '/'+ x[0] +'/'; var attr = isEnabled ? { href: href } : { onclick: function () { + // if the app is not enabled then we send them to the login page + // which will redirect to the app in question ? var loginURL = Hash.hashToHref('', 'login'); var url = Hash.getNewPadURL(loginURL, { href: href }); window.location.href = url; @@ -89,15 +89,6 @@ define([ TextFit($(a).find('.pad-button-text')[0], {minFontSize: 13, maxFontSize: 18}); }); }); - UI.addTooltips(); - - var subscribeButton; - /* Display a subscribe button if they are enabled and the button's translation key exists */ - if (Config.allowSubscriptions) { - subscribeButton = Pages.subscribeButton(function () { - Feedback.send('HOME_SUBSCRIBE_CRYPTPAD'); - }); - } var pageLink = function (ref, loc, text) { if (!ref) { return; } @@ -195,7 +186,7 @@ define([ var subButton = function () { if (Pages.areSubscriptionsAllowed()) { - sub = h('div.cp-sub-prompt', [ + var sub = h('div.cp-sub-prompt', [ h('span', Msg.home_morestorage), h('br'), h('button', Msg.features_f_subscribe), @@ -220,7 +211,7 @@ define([ alt: '' }), h('h1.cp-instance-title', Pages.Instance.name), - UI.setHTML(h('span.tag-line'), Pages.Instance.description), + Pages.setHTML(h('span.tag-line'), Pages.Instance.description), locationBlock, termsLink, privacyLink, diff --git a/customize.dist/pages/what-is-cryptpad.js b/customize.dist/pages/what-is-cryptpad.js deleted file mode 100644 index b1c3de3d0..000000000 --- a/customize.dist/pages/what-is-cryptpad.js +++ /dev/null @@ -1,113 +0,0 @@ -define([ - '/api/config', - '/common/hyperscript.js', - '/customize/messages.js', - '/customize/pages.js', - '/common/common-feedback.js', -], function (Config, h, Msg, Pages, Feedback) { - var urlArgs = Config.requireConf.urlArgs; - - var logoLink = function (alt, src, url, cls) { - var img = h('img' + (cls || ''), { - src: src + '?' + urlArgs, - alt: alt, - }); - if (!url) { return img; } - return h('a', { href: url, }, img); - }; - - return function () { - var xwiki_info = Pages.setHTML(h('span'), Msg.whatis_xwiki_info); - Pages.externalLink(xwiki_info.querySelector('a'), "https://xwiki.com"); - - return h('div#cp-main', [ - Pages.infopageTopbar(), - h('div.container.cp-container', [ - h('div.row.cp-page-title',[ - h('div.col-12.text-center', h('h1', Msg.whatis_title)), - ]), - h('div.row.cp-page-section', [ - h('div.col-md-6', [ - Pages.setHTML(h('h2'), Msg.whatis_collaboration), - Pages.setHTML(h('span'), Msg.whatis_collaboration_info), - ]), - h('div.col-md-6', [ - h('img.cp-img-invert', { - src: '/customize/images/collaboration.png?' + urlArgs, - alt: '', - 'aria-hidden': 'true' - }), - ]), - ]), - h('div.row.cp-page-section', [ - h('div.col-md-6.order-md-2', [ - Pages.setHTML(h('h2'), Msg.whatis_apps), - Pages.setHTML(h('span'), Msg.whatis_apps_info), - ]), - h('div.col-md-6.order-md-1', [ - h('img', { - src: '/customize/images/apps-preview.png?' + urlArgs, - alt: '', - 'aria-hidden': 'true' - }), - ]), - ]), - h('div.row.cp-page-section', [ - h('div.col-md-6', [ - Pages.setHTML(h('h2'), Msg.whatis_drive), - Pages.setHTML(h('span'), Msg.whatis_drive_info), - ]), - h('div.col-md-6', [ - h('img.cp-shadow', { - src: '/customize/images/drive-grid.png?' + urlArgs, - alt: '', - 'aria-hidden': 'true' - }), - ]), - ]), - h('div.row.cp-page-section', [ - h('div.col-md-6.order-md-2', [ - Pages.setHTML(h('h2'), Msg.whatis_model), - Pages.setHTML(h('span'), Msg.whatis_model_info), - Config.allowSubscriptions ? - Pages.subscribeButton(function () { - Feedback.send('WHATIS_SUBSCRIBE_CRYPTPAD'); - }) : undefined, - Pages.crowdfundingButton(function () { - Feedback.send('WHATIS_SUPPORT_CRYPTPAD'); - }), - ]), - h('div.col-md-6.order-md-1.small-logos', [ - logoLink('NGI Award 2019', '/customize/images/logo_ngi.png', - 'https://www.ngi.eu/', '.cp-img-invert'), - logoLink('NLnet Foundation logo', '/customize/images/logo_nlnet.svg', - 'https://nlnet.nl', '.cp-img-invert'), - - logoLink('BPI France logo', '/customize/images/logo_bpifrance.svg', - 'https://bpifrance.com'), - logoLink('Mozilla Open Source Support logo', '/customize/images/logo_moss.jpg', - 'https://www.mozilla.org/en-US/moss/'), - logoLink('NGI Trust logo', '/customize/images/logo_ngi_trust.png', - 'https://www.ngi.eu/ngi-projects/ngi-trust/'), - logoLink('NGI DAPSI LOGO', '/customize/images/logo_ngi_dapsi.png', - 'https://dapsi.ngi.eu/'), - ]), - ]), - h('div.row.cp-page-section', [ - h('div.col-md-6', [ - Pages.setHTML(h('h2'), Msg.whatis_xwiki), - xwiki_info, - ]), - h('div.col-md-6.small-logos', [ - h('img', { - src: '/customize/images/logo_XWiki.svg?' + urlArgs, - alt: 'Logo XWiki' - }), - ]), - ]), - ]), - Pages.infopageFooter(), - ]); - }; -}); -