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', {
href: "https://opencollective.com/cryptpad/contribute",
href: "https://opencollective.com/cryptpad/",
target: '_blank',
rel: 'noopener',
});

View File

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

View File

@ -53,12 +53,22 @@
font-weight: bold;
}
}
.cp-limit-upgrade {
padding: 0;
line-height: 25px;
height: 25px;
margin: 0 3px;
border-radius: 0;
.cp-limit-buttons {
display: flex;
flex-wrap: wrap;
justify-content: space-around;
justify-content: space-evenly;
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.
config.disableSharedFolders = false;
config.surveyURL = "https://survey.cryptpad.fr/index.php/672782";
return config;
});

View File

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

View File

@ -42,7 +42,8 @@ define([
var origin = encodeURIComponent(window.location.hostname);
var common = window.Cryptpad = {
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,
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) {
Cryptpad.isOverPinLimit(null, function (e, overLimit, limits) {
cb({

View File

@ -1000,10 +1000,12 @@
"crowdfunding_home1": "CryptPad a besoin d'aide !",
"crowdfunding_home2": "Cliquez sur le bouton pour découvrir notre campagne de financement participatif.",
"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_yes": "Voir la page",
"crowdfunding_popup_no": "Pas maintenant",
"crowdfunding_popup_never": "Ne plus demander",
"survey": "Enquête CryptPad",
"markdown_toc": "Sommaire",
"debug_getGraph": "Obtenir le code permettant de générer un graphe de ce document",
"debug_getGraphWait": "Génération du graphe... Veuillez patienter.",

View File

@ -1020,10 +1020,12 @@
"crowdfunding_home1": "CryptPad needs your help!",
"crowdfunding_home2": "Click on the button to learn about our crowdfunding campaign.",
"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_yes": "Go to OpenCollective",
"crowdfunding_popup_no": "Not now",
"crowdfunding_popup_never": "Don't ask me again",
"survey": "CryptPad survey",
"markdown_toc": "Contents",
"fm_expirablePad": "This pad will expire on {0}",
"admin_authError": "Only administrators can access this page",

View File

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