remove some unused code, speed up home page load time

master
ansuz 3 years ago
parent f0263d82c2
commit 8222566961

@ -109,7 +109,7 @@ define([
return h('a', attrs, [icon, text]); return h('a', attrs, [icon, text]);
}; };
Pages.versionString = "v4.14.1"; Pages.versionString = "5.0.0";
var customURLs = Pages.customURLs = {}; var customURLs = Pages.customURLs = {};
(function () { (function () {
@ -146,7 +146,7 @@ define([
Pages.Instance = {}; Pages.Instance = {};
Object.keys(Instance).forEach(function (k) { Object.keys(Instance).forEach(function (k) {
var value = Instance[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; var name;
@ -230,7 +230,7 @@ define([
}), }),
h('span.logo-font', 'CryptPad') 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 footLink('https://opencollective.com/cryptpad/contribute/', 'footer_donate', null, 'money') // XXX DB: add OpenCollective icon
]), ]),
h('div.cp-footer-center', [ h('div.cp-footer-center', [
@ -330,22 +330,5 @@ define([
return crowdFunding; 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; return Pages;
}); });

@ -2,8 +2,6 @@ define([
'jquery', 'jquery',
'/api/config', '/api/config',
'/common/hyperscript.js', '/common/hyperscript.js',
'/common/common-feedback.js',
'/common/common-interface.js',
'/common/common-hash.js', '/common/common-hash.js',
'/common/common-constants.js', '/common/common-constants.js',
'/common/common-util.js', '/common/common-util.js',
@ -12,8 +10,7 @@ define([
'/customize/application_config.js', '/customize/application_config.js',
'/common/outer/local-store.js', '/common/outer/local-store.js',
'/customize/pages.js', '/customize/pages.js',
//'json!/api/instance', ], function ($, Config, h, Hash, Constants, Util, TextFit, Msg, AppConfig, LocalStore, Pages) {
], function ($, Config, h, Feedback, UI, Hash, Constants, Util, TextFit, Msg, AppConfig, LocalStore, Pages) {
var urlArgs = Config.requireConf.urlArgs; var urlArgs = Config.requireConf.urlArgs;
var isAvailableType = function (x) { var isAvailableType = function (x) {
@ -55,6 +52,7 @@ define([
var s = 'div.bs-callout.cp-callout-' + x[0]; var s = 'div.bs-callout.cp-callout-' + x[0];
var cls = ''; var cls = '';
var isEnabled = checkRegisteredType(x[0]); var isEnabled = checkRegisteredType(x[0]);
var isEAEnabled = checkEarlyAccess(x[0]); var isEAEnabled = checkEarlyAccess(x[0]);
//if (i > 2) { s += '.cp-more.cp-hidden'; } //if (i > 2) { s += '.cp-more.cp-hidden'; }
var icon = AppConfig.applicationsIcon[x[0]]; var icon = AppConfig.applicationsIcon[x[0]];
@ -62,6 +60,8 @@ define([
var href = '/'+ x[0] +'/'; var href = '/'+ x[0] +'/';
var attr = isEnabled ? { href: href } : { var attr = isEnabled ? { href: href } : {
onclick: function () { 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 loginURL = Hash.hashToHref('', 'login');
var url = Hash.getNewPadURL(loginURL, { href: href }); var url = Hash.getNewPadURL(loginURL, { href: href });
window.location.href = url; window.location.href = url;
@ -89,15 +89,6 @@ define([
TextFit($(a).find('.pad-button-text')[0], {minFontSize: 13, maxFontSize: 18}); 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) { var pageLink = function (ref, loc, text) {
if (!ref) { return; } if (!ref) { return; }
@ -195,7 +186,7 @@ define([
var subButton = function () { var subButton = function () {
if (Pages.areSubscriptionsAllowed()) { if (Pages.areSubscriptionsAllowed()) {
sub = h('div.cp-sub-prompt', [ var sub = h('div.cp-sub-prompt', [
h('span', Msg.home_morestorage), h('span', Msg.home_morestorage),
h('br'), h('br'),
h('button', Msg.features_f_subscribe), h('button', Msg.features_f_subscribe),
@ -220,7 +211,7 @@ define([
alt: '' alt: ''
}), }),
h('h1.cp-instance-title', Pages.Instance.name), 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, locationBlock,
termsLink, termsLink,
privacyLink, privacyLink,

@ -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(),
]);
};
});
Loading…
Cancel
Save