Add links to the CryptPad survey and to the crowdfunding page

This commit is contained in:
yflory 2019-10-03 18:09:20 +02:00
parent d5c4285c61
commit 390ca941e7
10 changed files with 109 additions and 49 deletions

View File

@ -97,7 +97,7 @@ define([
]);*/ ]);*/
var _link = h('a', { var _link = h('a', {
href: "https://opencollective.com/cryptpad/contribute", href: "https://opencollective.com/cryptpad/",
target: '_blank', target: '_blank',
rel: 'noopener', rel: 'noopener',
}); });

View File

@ -121,6 +121,9 @@
margin: 5px 0px; margin: 5px 0px;
height: 1px; height: 1px;
background: #bbb; background: #bbb;
& + hr {
display: none;
}
} }
p { p {

View File

@ -53,12 +53,22 @@
font-weight: bold; font-weight: bold;
} }
} }
.cp-limit-upgrade { .cp-limit-buttons {
padding: 0; display: flex;
line-height: 25px; flex-wrap: wrap;
height: 25px; justify-content: space-around;
margin: 0 3px; justify-content: space-evenly;
border-radius: 0; a {
height: 25px;
display: inline-flex;
align-items: center;
min-width: 200px;
width: 50%;
padding-top: 0;
padding-bottom: 0;
justify-content: center;
flex: 1;
}
} }
} }
} }

View File

@ -156,5 +156,7 @@ define(function() {
// by default by the CryptPad developers. // by default by the CryptPad developers.
config.disableSharedFolders = false; config.disableSharedFolders = false;
config.surveyURL = "https://survey.cryptpad.fr/index.php/672782";
return config; return config;
}); });

View File

@ -2205,15 +2205,16 @@ define([
var $limit = $('<span>', {'class': 'cp-limit-bar'}).appendTo($container); var $limit = $('<span>', {'class': 'cp-limit-bar'}).appendTo($container);
var quota = usage/limit; var quota = usage/limit;
var $usage = $('<span>', {'class': 'cp-limit-usage'}).css('width', quota*100+'%'); var $usage = $('<span>', {'class': 'cp-limit-usage'}).css('width', quota*100+'%');
var $buttons = $(h('span.cp-limit-buttons')).appendTo($container);
var urls = common.getMetadataMgr().getPrivateData().accounts; var urls = common.getMetadataMgr().getPrivateData().accounts;
var makeDonateButton = function () { var makeDonateButton = function () {
var $a = $('<a>', { var $a = $('<a>', {
'class': 'cp-limit-upgrade btn btn-success', 'class': 'cp-limit-upgrade btn btn-primary',
href: urls.donateURL, href: urls.donateURL,
rel: "noreferrer noopener", rel: "noreferrer noopener",
target: "_blank", target: "_blank",
}).text(Messages.supportCryptpad).appendTo($container); }).text(Messages.crowdfunding_button2).appendTo($buttons);
$a.click(function () { $a.click(function () {
Feedback.send('SUPPORT_CRYPTPAD'); Feedback.send('SUPPORT_CRYPTPAD');
}); });
@ -2225,7 +2226,7 @@ define([
href: urls.upgradeURL, href: urls.upgradeURL,
rel: "noreferrer noopener", rel: "noreferrer noopener",
target: "_blank", target: "_blank",
}).text(Messages.upgradeAccount).appendTo($container); }).text(Messages.upgradeAccount).appendTo($buttons);
$a.click(function () { $a.click(function () {
Feedback.send('UPGRADE_ACCOUNT'); Feedback.send('UPGRADE_ACCOUNT');
}); });
@ -2238,6 +2239,7 @@ define([
} else if (!plan) { } else if (!plan) {
// user is logged in and subscriptions are allowed // user is logged in and subscriptions are allowed
// and they don't have one. show upgrades // and they don't have one. show upgrades
makeDonateButton();
makeUpgradeButton(); makeUpgradeButton();
} else { } else {
// they have a plan. show nothing // they have a plan. show nothing
@ -2548,15 +2550,42 @@ define([
content: h('span', Messages.supportPage || 'Support') content: h('span', Messages.supportPage || 'Support')
}); });
} }
options.push({ options.push({ tag: 'hr' });
tag: 'a', if (Config.allowSubscriptions) {
attributes: { options.push({
'target': '_blank', tag: 'a',
'href': origin+'/features.html', attributes: {
'class': 'fa fa-star-o' 'target': '_blank',
}, 'href': priv.plan ? priv.accounts.upgradeURL : origin+'/features.html',
content: h('span', priv.plan ? Messages.settings_cat_subscription : Messages.pricing) 'class': 'fa fa-star-o'
}); },
content: h('span', priv.plan ? Messages.settings_cat_subscription : Messages.pricing)
});
}
if (!priv.plan && !Config.removeDonateButton) {
options.push({
tag: 'a',
attributes: {
'target': '_blank',
'rel': 'noopener',
'href': priv.accounts.donateURL,
'class': 'fa fa-gift'
},
content: h('span', Messages.crowdfunding_button2)
});
}
if (AppConfig.surveyURL) {
options.push({
tag: 'a',
attributes: {
'target': '_blank',
'rel': 'noopener',
'href': AppConfig.surveyURL,
'class': 'fa fa-graduation-cap'
},
content: h('span', Messages.survey)
});
}
options.push({ tag: 'hr' }); options.push({ tag: 'hr' });
// Add login or logout button depending on the current status // Add login or logout button depending on the current status
if (accountName) { if (accountName) {
@ -3440,37 +3469,40 @@ define([
setTimeout(function () { setTimeout(function () {
common.getAttribute(['general', 'crowdfunding'], function (err, val) { common.getAttribute(['general', 'crowdfunding'], function (err, val) {
if (err || val === false) { return; } if (err || val === false) { return; }
// Display the popup common.getSframeChannel().query('Q_GET_PINNED_USAGE', null, function (err, obj) {
var text = Messages.crowdfunding_popup_text; var quotaMb = obj.quota / (1024 * 1024);
var yes = h('button.cp-corner-primary', Messages.crowdfunding_popup_yes); if (quotaMb < 10) { return; }
var no = h('button.cp-corner-primary', Messages.crowdfunding_popup_no); // Display the popup
var never = h('button.cp-corner-cancel', Messages.crowdfunding_popup_never); var text = Messages.crowdfunding_popup_text;
var actions = h('div', [yes, no, never]); var yes = h('button.cp-corner-primary', Messages.crowdfunding_popup_yes);
var no = h('button.cp-corner-primary', Messages.crowdfunding_popup_no);
var never = h('button.cp-corner-cancel', Messages.crowdfunding_popup_never);
var actions = h('div', [yes, no, never]);
var modal = UI.cornerPopup(text, actions, null, {big: true}); var modal = UI.cornerPopup(text, actions, null, {big: true});
$(yes).click(function () { $(yes).click(function () {
modal.delete(); modal.delete();
common.openURL('https://opencollective.com/cryptpad/contribute'); common.openURL(priv.accounts.donateURL);
Feedback.send('CROWDFUNDING_YES'); Feedback.send('CROWDFUNDING_YES');
});
$(modal.popup).find('a').click(function (e) {
e.stopPropagation();
e.preventDefault();
modal.delete();
common.openURL(priv.accounts.donateURL);
Feedback.send('CROWDFUNDING_LINK');
});
$(no).click(function () {
modal.delete();
Feedback.send('CROWDFUNDING_NO');
});
$(never).click(function () {
modal.delete();
common.setAttribute(['general', 'crowdfunding'], false);
Feedback.send('CROWDFUNDING_NEVER');
});
}); });
$(modal.popup).find('a').click(function (e) {
e.stopPropagation();
e.preventDefault();
modal.delete();
common.openURL('https://opencollective.com/cryptpad/');
Feedback.send('CROWDFUNDING_LINK');
});
$(no).click(function () {
modal.delete();
Feedback.send('CROWDFUNDING_NO');
});
$(never).click(function () {
modal.delete();
common.setAttribute(['general', 'crowdfunding'], false);
Feedback.send('CROWDFUNDING_NEVER');
});
}); });
}, 5000); }, 5000);
}; };

View File

@ -42,7 +42,8 @@ define([
var origin = encodeURIComponent(window.location.hostname); var origin = encodeURIComponent(window.location.hostname);
var common = window.Cryptpad = { var common = window.Cryptpad = {
Messages: Messages, Messages: Messages,
donateURL: 'https://accounts.cryptpad.fr/#/donate?on=' + origin, //donateURL: 'https://accounts.cryptpad.fr/#/donate?on=' + origin,
donateURL: "https://opencollective.com/cryptpad/",
upgradeURL: 'https://accounts.cryptpad.fr/#/?on=' + origin, upgradeURL: 'https://accounts.cryptpad.fr/#/?on=' + origin,
account: {}, account: {},
}; };

View File

@ -376,6 +376,14 @@ define([
}); });
}); });
sframeChan.on('Q_GET_PINNED_USAGE', function (data, cb) {
Cryptpad.getPinnedUsage({}, function (e, used) {
cb({
error: e,
quota: used
});
});
});
sframeChan.on('Q_GET_PIN_LIMIT_STATUS', function (data, cb) { sframeChan.on('Q_GET_PIN_LIMIT_STATUS', function (data, cb) {
Cryptpad.isOverPinLimit(null, function (e, overLimit, limits) { Cryptpad.isOverPinLimit(null, function (e, overLimit, limits) {
cb({ cb({

View File

@ -1000,10 +1000,12 @@
"crowdfunding_home1": "CryptPad a besoin d'aide !", "crowdfunding_home1": "CryptPad a besoin d'aide !",
"crowdfunding_home2": "Cliquez sur le bouton pour découvrir notre campagne de financement participatif.", "crowdfunding_home2": "Cliquez sur le bouton pour découvrir notre campagne de financement participatif.",
"crowdfunding_button": "Soutenir CryptPad", "crowdfunding_button": "Soutenir CryptPad",
"crowdfunding_button2": "Aider CryptPad",
"crowdfunding_popup_text": "<h3>Aider CryptPad</h3>Pour vous assurer que CryptPad soit activement développé, nous vous invitons à supporter le projet via la <a href=\"https://opencollective.com/cryptpad\">page OpenCollective</a>, où vous pouvez trouver notre <b>Roadmap</b> et nos <b>objectifs de financement</b>.", "crowdfunding_popup_text": "<h3>Aider CryptPad</h3>Pour vous assurer que CryptPad soit activement développé, nous vous invitons à supporter le projet via la <a href=\"https://opencollective.com/cryptpad\">page OpenCollective</a>, où vous pouvez trouver notre <b>Roadmap</b> et nos <b>objectifs de financement</b>.",
"crowdfunding_popup_yes": "Voir la page", "crowdfunding_popup_yes": "Voir la page",
"crowdfunding_popup_no": "Pas maintenant", "crowdfunding_popup_no": "Pas maintenant",
"crowdfunding_popup_never": "Ne plus demander", "crowdfunding_popup_never": "Ne plus demander",
"survey": "Enquête CryptPad",
"markdown_toc": "Sommaire", "markdown_toc": "Sommaire",
"debug_getGraph": "Obtenir le code permettant de générer un graphe de ce document", "debug_getGraph": "Obtenir le code permettant de générer un graphe de ce document",
"debug_getGraphWait": "Génération du graphe... Veuillez patienter.", "debug_getGraphWait": "Génération du graphe... Veuillez patienter.",

View File

@ -1020,10 +1020,12 @@
"crowdfunding_home1": "CryptPad needs your help!", "crowdfunding_home1": "CryptPad needs your help!",
"crowdfunding_home2": "Click on the button to learn about our crowdfunding campaign.", "crowdfunding_home2": "Click on the button to learn about our crowdfunding campaign.",
"crowdfunding_button": "Support CryptPad", "crowdfunding_button": "Support CryptPad",
"crowdfunding_button2": "Help CryptPad",
"crowdfunding_popup_text": "<h3>We need your help!</h3>To ensure that CryptPad is actively developed, consider supporting the project via the <a href=\"https://opencollective.com/cryptpad\">OpenCollective page</a>, where you can see our <b>Roadmap</b> and <b>Funding goals</b>.", "crowdfunding_popup_text": "<h3>We need your help!</h3>To ensure that CryptPad is actively developed, consider supporting the project via the <a href=\"https://opencollective.com/cryptpad\">OpenCollective page</a>, where you can see our <b>Roadmap</b> and <b>Funding goals</b>.",
"crowdfunding_popup_yes": "Go to OpenCollective", "crowdfunding_popup_yes": "Go to OpenCollective",
"crowdfunding_popup_no": "Not now", "crowdfunding_popup_no": "Not now",
"crowdfunding_popup_never": "Don't ask me again", "crowdfunding_popup_never": "Don't ask me again",
"survey": "CryptPad survey",
"markdown_toc": "Contents", "markdown_toc": "Contents",
"fm_expirablePad": "This pad will expire on {0}", "fm_expirablePad": "This pad will expire on {0}",
"admin_authError": "Only administrators can access this page", "admin_authError": "Only administrators can access this page",

View File

@ -47,7 +47,7 @@
height: 100%; height: 100%;
} }
} }
.cp-limit-upgrade { .cp-limit-buttons {
display: none; display: none;
} }
} }