Skip to content

Commit cb58c4d

Browse files
fix(sponsors): respect hide config for the Readme.md sponsor list generator; (#243)
* feat: add sponsor list generator; * feat: added deploy action; * fix: fixed layout; * fix: use utm links inside tooltips; * fix(CI): set engine version; * chore: reverted the start button title change; * fix: add the ability to retry the request to get a list of sponsors; * chore: change sponsors config & fix sponsor card layout; * chore: hide 'incognito' sponsor from the list of sponsors; * chore: add Route4Me sponsor; * chore: fixed resolution of utm link for manually added sponsors; * chore: fixed sponsors' tiers resolving; * chore: draft; * chore(sponsors): disable utm links generation for `slotozilla-deutschland`; * chore(draft): Improve sponsors list generator; * chore(draft): fix origin preset; * chore(draft): delete generated icon; * chore(draft): add check to ensure dir exists; * chore(draft): add check to ensure dir exists; * chore(draft): activate GitHub data pulling; * chore(draft): fix crown chevron styling; * chore(draft): reduce logo min-width; * chore(draft): add missed `route4me` light logo; * chore(draft): add a title for readme sponsor block; * chore(draft): fix description resolving; * chore(draft): add utm links for sponsors rendered to markdown; * chore(draft): respect autoUTMLinks for utm links generation; * chore(draft): set user theme timeout to 24 hours; * chore(draft): set utm link for markdown output; * chore(draft): add sponsors' logos; * chore(draft): fix sponsor.json; * chore(draft): fix sponsor.json; * chore(draft): add principal logo; * chore(draft): add a hotfix for svg logos; * chore(draft): use image metadata instead of file extension to determine image format; * chore(draft): add Stytch & Descope links; * chore(draft): fix utm link generator to respect sponsor's params; * chore(draft): add page active link rendering; * chore(draft): notes block refactoring; * chore(draft): remove graphql packages; * chore(sponsors): add website link for buzzoid.com; * chore(sponsors): remove Route4me from the list; * chore(sponsors): Fixed relative URLs for dark theme logos in the Readme sponsor generator; * fix(sponsors): add a hotfix for sponsors generator by emulating OpenCollective's isActive property. * fix(sponsors): fix custom tiers processing; * fix(sponsors): respect `hide` config for the Readme.md sponsor list generator; * fix (sponsors): added default credit config to reduce sponsor list updates due to payment delays; * fix (sponsors): fix sponsor's score calculation; --------- Co-authored-by: Jay <[email protected]>
1 parent 0187370 commit cb58c4d

File tree

6 files changed

+72
-10
lines changed

6 files changed

+72
-10
lines changed

Diff for: assets/icons/new.svg

+13
Loading

Diff for: data/sponsors.json

+6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
"disappearCredit": 20,
55
"scoreTierPriceFactor": 0.80,
66
"scoreTotalAmountFactor": 0.2,
7+
"hide": {
8+
"incognito": true
9+
},
710
"tiers": {
811
"backer" : {
912
"name": "Backer",
@@ -141,6 +144,9 @@
141144
},
142145
"stephan9": {
143146
"website": "https://webogram.net/"
147+
},
148+
"soleks": {
149+
"showCaption": false
144150
}
145151
}
146152
}

Diff for: scripts/updateData.js

+34-7
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@ const renderMarkdownSponsors = async (sponsors) => {
356356
}
357357

358358
const filterSponsors = (fn) => Object.values(sponsors)
359+
.filter(({hide}) => !hide)
359360
.filter(fn)
360361
.sort((a, b) => new Date(a.createdAt) - new Date(b.createdAt));
361362

@@ -517,14 +518,15 @@ const processSponsors = async (collectiveSponsors, sponsorsConfig = './data/spon
517518
tiers,
518519
scoreTierPriceFactor = 0.5,
519520
scoreTotalAmountFactor = 0.2,
520-
creditDays = 0
521+
creditDays = 0,
522+
hide = {}
521523
} = await readJSON(sponsorsConfig) || {};
522524

523525
const mergedSponsors = {};
524526

525527
// merge Open Collective sponsors
526528
collectiveSponsors.forEach(sponsor => {
527-
if (sponsor.role !== 'BACKER' && sponsor.role) {
529+
if ((sponsor.role !== 'BACKER' && sponsor.role) || hide[sponsor.login?.toLowerCase()] || hide[sponsor.name?.toLowerCase()]) {
528530
return;
529531
}
530532

@@ -572,6 +574,12 @@ const processSponsors = async (collectiveSponsors, sponsorsConfig = './data/spon
572574

573575
if (lastTransactionAmount) {
574576
sponsor.tier = findTier(lastTransactionAmount, sponsorTiers);
577+
578+
let partiallyPaid = findTier(lastTransactionAmount * 1.1, sponsorTiers);
579+
580+
if (sponsor.tier !== partiallyPaid) {
581+
sponsor.tier = partiallyPaid;
582+
}
575583
}
576584

577585
const tierId = sponsor.tier ? sponsor.tier?.toLowerCase() : null;
@@ -581,7 +589,17 @@ const processSponsors = async (collectiveSponsors, sponsorsConfig = './data/spon
581589
console.log(`Unknown tier [${sponsor.tier}]`);
582590
}
583591

584-
const {price, benefits, period = PERIOD} = tierData || {};
592+
let {price, benefits, period = PERIOD, credit = 3} = tierData || {};
593+
594+
let shortageFactor = price && lastTransactionAmount < price ? lastTransactionAmount / price * 0.9 : 1;
595+
596+
period = period * shortageFactor;
597+
598+
sponsor.isNew = !!(sponsor.createdAt && days(sponsor.createdAt) < 7);
599+
600+
sponsor.credit ??= credit || 0;
601+
602+
period += sponsor.credit;
585603

586604
if (sponsor.isActive == null) {
587605
sponsor.isActive = tierData && days(lastTransactionAt) <= period && sponsor.lastTransactionAmount >= price;
@@ -593,8 +611,8 @@ const processSponsors = async (collectiveSponsors, sponsorsConfig = './data/spon
593611

594612
const isCustomTier = !!(tierData && price !== originalTierPrice);
595613
sponsor.tierId = tierId;
596-
sponsor.tier = sponsor.tier + (lastTransactionAmount > originalTierPrice ? '+' : '')
597-
sponsor.tierPrice = price;
614+
sponsor.tier = sponsor.tier ? sponsor.tier + (lastTransactionAmount > originalTierPrice ? '+' : '') : null;
615+
sponsor.tierPrice = price || 0;
598616
sponsor.originalTierPrice = originalTierPrice;
599617
sponsor.isCustomTier = isCustomTier;
600618
sponsor.totalAmountDonated = sponsor.totalAmountDonated || lastTransactionAmount || 0;
@@ -677,10 +695,19 @@ const processSponsors = async (collectiveSponsors, sponsorsConfig = './data/spon
677695
opacity: timeLeft == null || timeLeft > 0 ? 1 :(sponsor.timeLeft / (creditDays * DAY))
678696
}
679697

698+
const score = Math.round(
699+
sponsor.totalAmountDonated * scoreTotalAmountFactor +
700+
averageMonthlyContribution +
701+
tierPrice * scoreTierPriceFactor
702+
);
703+
680704
console.log(
681705
`Add sponsor badge [${sponsor.displayName}]
682-
- tier: ${tier ? tier + '(' + tierPrice + '$)' : '< none >'}
706+
- score : ${score}
707+
- tier: ${tier || '< null >'}
708+
- tier price: ${tierPrice}
683709
- total amount donated: ${sponsor.totalAmountDonated}$
710+
- averageMonthlyContribution: ${averageMonthlyContribution}
684711
- last donation date: ${sponsor.lastTransactionAt}
685712
- created: ${sponsor.createdAt}
686713
- target link: ${sponsor.targetLink}
@@ -693,7 +720,7 @@ const processSponsors = async (collectiveSponsors, sponsorsConfig = './data/spon
693720
return {
694721
...sponsor,
695722
averageMonthlyContribution,
696-
score: Math.round(sponsor.totalAmountDonated * scoreTotalAmountFactor + averageMonthlyContribution + tierPrice * scoreTierPriceFactor)
723+
score
697724
};
698725
})
699726
.sort((a, b) => b.score - a.score)

Diff for: scss/sponsors.scss

+15
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,21 @@ li.sponsor-card {
317317
animation: tilt-move-shaking 0.8s infinite ease-in-out;
318318
}
319319

320+
.sponsor_chevron_new{
321+
width: 2.5rem;
322+
height:2.5rem;
323+
background-image: url(/assets/icons/new.svg);
324+
background-size: cover;
325+
background-repeat: no-repeat;
326+
position: absolute;
327+
left: -1.5rem;
328+
top: -1rem;
329+
transform: rotateZ(-45deg);
330+
z-index: 1;
331+
/* animation: tilt-shaking 0.5s infinite;*/
332+
animation: tilt-move-shaking 0.8s infinite ease-in-out;
333+
}
334+
320335

321336
.become_sponsor{
322337
display: flex;

Diff for: templates/home.ejs

+3-2
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@
107107
<a href="<%= sponsor.targetLink || '#' %>" target="_blank" >
108108
<% if(sponsor.image){ %>
109109
<div>
110-
<% if(sponsor.benefits.crown) { %><div class="chevron"><span class="sponsor_chevron_crown"></span></div><% } %>
110+
<% if(sponsor.benefits.crown) { %><div class="chevron"><span class="sponsor_chevron_crown"></span></div><% } else if (sponsor.isNew) { %>
111+
<div class="chevron"><span class="sponsor_chevron_new"></span></div><% } %>
111112
<img src="<%= sponsor.image %>" alt="<%= sponsor.alt %>"/>
112113
</div><% } %>
113114
<% if(sponsor.showCaption !== false){ %><span class="caption"><%= sponsor.displayName %></span><% } %>
@@ -235,7 +236,7 @@
235236
document.addEventListener('DOMContentLoaded', () => {
236237
setTimeout(() => {
237238
splide.Components.AutoScroll.play();
238-
}, 3000);
239+
}, 5000);
239240
});
240241
241242
splide.mount(window.splide.Extensions);

Diff for: templates/post.ejs

+1-1
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@
357357
358358
setTimeout(() => {
359359
splide.Components.AutoScroll.play();
360-
}, 3000);
360+
}, 5000);
361361
}
362362
}
363363

0 commit comments

Comments
 (0)