Skip to content

fix(sponsors): respect hide config for the Readme.md sponsor list generator; #243

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 66 commits into from
Apr 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
4bc8290
feat: add sponsor list generator;
DigitalBrainJS Mar 3, 2023
ee08fd7
feat: added deploy action;
DigitalBrainJS Mar 5, 2023
41f9e16
Merge branch 'master' of https://github.com/axios/axios-docs into master
DigitalBrainJS Mar 5, 2023
40786a2
fix: fixed layout;
DigitalBrainJS Mar 5, 2023
40d1a3e
fix: use utm links inside tooltips;
DigitalBrainJS Mar 6, 2023
19c8502
fix(CI): set engine version;
DigitalBrainJS Mar 8, 2023
fff1739
chore: reverted the start button title change;
DigitalBrainJS May 5, 2023
e3dab01
fix: add the ability to retry the request to get a list of sponsors;
DigitalBrainJS May 5, 2023
7b6a7ee
Merge branch 'master' of https://github.com/axios/axios-docs into master
DigitalBrainJS Oct 2, 2023
c422c0f
chore: change sponsors config & fix sponsor card layout;
DigitalBrainJS Oct 11, 2023
0cacb8d
chore: hide 'incognito' sponsor from the list of sponsors;
DigitalBrainJS Feb 18, 2024
7e5ea9d
Merge branch 'master' of https://github.com/axios/axios-docs into cho…
DigitalBrainJS Feb 18, 2024
9c095a1
chore: add Route4Me sponsor;
DigitalBrainJS Jul 13, 2024
994feea
Merge branch 'master' of https://github.com/axios/axios-docs into cho…
DigitalBrainJS Jul 13, 2024
1de0ae2
chore: fixed resolution of utm link for manually added sponsors;
DigitalBrainJS Jul 15, 2024
e2a8980
Merge branch 'master' of https://github.com/axios/axios-docs into cho…
DigitalBrainJS Jul 15, 2024
5d596d7
chore: fixed sponsors' tiers resolving;
DigitalBrainJS Aug 1, 2024
eb40933
chore: draft;
DigitalBrainJS Aug 6, 2024
fc788d6
Merge branch 'master' of https://github.com/axios/axios-docs into master
DigitalBrainJS Aug 6, 2024
1323284
chore(sponsors): disable utm links generation for `slotozilla-deutsch…
DigitalBrainJS Aug 6, 2024
2b25c52
chore(draft): Improve sponsors list generator;
DigitalBrainJS Aug 16, 2024
e04de97
Merge branch 'master' of https://github.com/axios/axios-docs into cho…
DigitalBrainJS Aug 16, 2024
0581c93
chore(draft): fix origin preset;
DigitalBrainJS Aug 16, 2024
257ca85
chore(draft): delete generated icon;
DigitalBrainJS Aug 16, 2024
e271d28
Merge branch 'chore/sponsors-generator' into master
DigitalBrainJS Aug 16, 2024
485a129
chore(draft): add check to ensure dir exists;
DigitalBrainJS Aug 16, 2024
88b391c
chore(draft): add check to ensure dir exists;
DigitalBrainJS Aug 16, 2024
7cdfde9
chore(draft): activate GitHub data pulling;
DigitalBrainJS Aug 16, 2024
7e1677a
chore(draft): fix crown chevron styling;
DigitalBrainJS Aug 16, 2024
142c72a
chore(draft): reduce logo min-width;
DigitalBrainJS Aug 16, 2024
f60ee95
chore(draft): add missed `route4me` light logo;
DigitalBrainJS Aug 16, 2024
383f9e9
chore(draft): add a title for readme sponsor block;
DigitalBrainJS Aug 16, 2024
50cf187
chore(draft): fix description resolving;
DigitalBrainJS Aug 16, 2024
3002a68
chore(draft): add utm links for sponsors rendered to markdown;
DigitalBrainJS Aug 16, 2024
29354f9
chore(draft): respect autoUTMLinks for utm links generation;
DigitalBrainJS Aug 16, 2024
1078438
chore(draft): set user theme timeout to 24 hours;
DigitalBrainJS Aug 17, 2024
a369593
chore(draft): set utm link for markdown output;
DigitalBrainJS Aug 17, 2024
cffcb2e
chore(draft): add sponsors' logos;
DigitalBrainJS Aug 17, 2024
d0f2b6c
chore(draft): fix sponsor.json;
DigitalBrainJS Aug 17, 2024
b508733
chore(draft): fix sponsor.json;
DigitalBrainJS Aug 17, 2024
410237d
chore(draft): add principal logo;
DigitalBrainJS Aug 17, 2024
86b8d06
chore(draft): add a hotfix for svg logos;
DigitalBrainJS Aug 17, 2024
106f263
chore(draft): use image metadata instead of file extension to determi…
DigitalBrainJS Aug 17, 2024
081b280
chore(draft): add Stytch & Descope links;
DigitalBrainJS Aug 17, 2024
7c75d3d
chore(draft): fix utm link generator to respect sponsor's params;
DigitalBrainJS Aug 17, 2024
f043be0
chore(draft): add page active link rendering;
DigitalBrainJS Aug 18, 2024
c94d98b
chore(draft): notes block refactoring;
DigitalBrainJS Aug 18, 2024
0723dd8
chore(draft): remove graphql packages;
DigitalBrainJS Aug 18, 2024
9ddc201
chore(sponsors): add website link for buzzoid.com;
DigitalBrainJS Aug 28, 2024
3b88169
Merge branch 'master' of https://github.com/axios/axios-docs into master
DigitalBrainJS Aug 28, 2024
34728f8
chore(sponsors): remove Route4me from the list;
DigitalBrainJS Sep 12, 2024
fc56bc9
chore(sponsors): Fixed relative URLs for dark theme logos in the Read…
DigitalBrainJS Oct 14, 2024
a532b98
Merge branch 'master' into master
DigitalBrainJS Oct 14, 2024
2c65f76
Merge branch 'master' into master
jasonsaayman Oct 15, 2024
37b9cf0
Merge branch 'master' of https://github.com/axios/axios-docs into master
DigitalBrainJS Nov 13, 2024
d9a4467
Merge branch 'master' of https://github.com/DigitalBrainJS/axios-docs…
DigitalBrainJS Mar 11, 2025
60477f5
fix(sponsors): add a hotfix for sponsors generator by emulating OpenC…
DigitalBrainJS Mar 12, 2025
ebe93cc
Merge branch 'master' into fix/sponsors-generator
DigitalBrainJS Mar 12, 2025
23c056d
Merge branch 'master' of https://github.com/axios/axios-docs into fix…
DigitalBrainJS Mar 14, 2025
e4b2cf6
fix(sponsors): fix custom tiers processing;
DigitalBrainJS Mar 14, 2025
61949a0
Merge remote-tracking branch 'origin/fix/sponsors-generator' into fix…
DigitalBrainJS Mar 14, 2025
2bf5d48
fix(sponsors): respect `hide` config for the Readme.md sponsor list g…
DigitalBrainJS Mar 28, 2025
f74bd42
Merge branch 'master' into fix/sponsors-generator
DigitalBrainJS Mar 28, 2025
2ce9e0a
fix (sponsors): added default credit config to reduce sponsor list up…
DigitalBrainJS Apr 4, 2025
71e851d
Merge remote-tracking branch 'origin/fix/sponsors-generator' into fix…
DigitalBrainJS Apr 4, 2025
34e96b1
fix (sponsors): fix sponsor's score calculation;
DigitalBrainJS Apr 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions assets/icons/new.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions data/sponsors.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
"disappearCredit": 20,
"scoreTierPriceFactor": 0.80,
"scoreTotalAmountFactor": 0.2,
"hide": {
"incognito": true
},
"tiers": {
"backer" : {
"name": "Backer",
Expand Down Expand Up @@ -141,6 +144,9 @@
},
"stephan9": {
"website": "https://webogram.net/"
},
"soleks": {
"showCaption": false
}
}
}
41 changes: 34 additions & 7 deletions scripts/updateData.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ const renderMarkdownSponsors = async (sponsors) => {
}

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

Expand Down Expand Up @@ -517,14 +518,15 @@ const processSponsors = async (collectiveSponsors, sponsorsConfig = './data/spon
tiers,
scoreTierPriceFactor = 0.5,
scoreTotalAmountFactor = 0.2,
creditDays = 0
creditDays = 0,
hide = {}
} = await readJSON(sponsorsConfig) || {};

const mergedSponsors = {};

// merge Open Collective sponsors
collectiveSponsors.forEach(sponsor => {
if (sponsor.role !== 'BACKER' && sponsor.role) {
if ((sponsor.role !== 'BACKER' && sponsor.role) || hide[sponsor.login?.toLowerCase()] || hide[sponsor.name?.toLowerCase()]) {
Copy link
Preview

Copilot AI Apr 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider extracting the hide check into a separate variable (e.g., isHidden) to improve clarity and reduce the potential for errors in this complex conditional.

Copilot is powered by AI, so mistakes are possible. Review output carefully before use.

return;
}

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

if (lastTransactionAmount) {
sponsor.tier = findTier(lastTransactionAmount, sponsorTiers);

let partiallyPaid = findTier(lastTransactionAmount * 1.1, sponsorTiers);

if (sponsor.tier !== partiallyPaid) {
sponsor.tier = partiallyPaid;
}
Comment on lines 576 to +582
Copy link
Preview

Copilot AI Apr 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The sponsor tier is reassigned using the partiallyPaid value immediately after initial assignment; consolidating the tier determination logic could help avoid potential inconsistencies.

Suggested change
sponsor.tier = findTier(lastTransactionAmount, sponsorTiers);
let partiallyPaid = findTier(lastTransactionAmount * 1.1, sponsorTiers);
if (sponsor.tier !== partiallyPaid) {
sponsor.tier = partiallyPaid;
}
sponsor.tier = findTier(lastTransactionAmount * 1.1, sponsorTiers);

Copilot is powered by AI, so mistakes are possible. Review output carefully before use.

}

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

const {price, benefits, period = PERIOD} = tierData || {};
let {price, benefits, period = PERIOD, credit = 3} = tierData || {};

let shortageFactor = price && lastTransactionAmount < price ? lastTransactionAmount / price * 0.9 : 1;

period = period * shortageFactor;

sponsor.isNew = !!(sponsor.createdAt && days(sponsor.createdAt) < 7);

sponsor.credit ??= credit || 0;

period += sponsor.credit;

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

const isCustomTier = !!(tierData && price !== originalTierPrice);
sponsor.tierId = tierId;
sponsor.tier = sponsor.tier + (lastTransactionAmount > originalTierPrice ? '+' : '')
sponsor.tierPrice = price;
sponsor.tier = sponsor.tier ? sponsor.tier + (lastTransactionAmount > originalTierPrice ? '+' : '') : null;
sponsor.tierPrice = price || 0;
sponsor.originalTierPrice = originalTierPrice;
sponsor.isCustomTier = isCustomTier;
sponsor.totalAmountDonated = sponsor.totalAmountDonated || lastTransactionAmount || 0;
Expand Down Expand Up @@ -677,10 +695,19 @@ const processSponsors = async (collectiveSponsors, sponsorsConfig = './data/spon
opacity: timeLeft == null || timeLeft > 0 ? 1 :(sponsor.timeLeft / (creditDays * DAY))
}

const score = Math.round(
sponsor.totalAmountDonated * scoreTotalAmountFactor +
averageMonthlyContribution +
tierPrice * scoreTierPriceFactor
);

console.log(
`Add sponsor badge [${sponsor.displayName}]
- tier: ${tier ? tier + '(' + tierPrice + '$)' : '< none >'}
- score : ${score}
- tier: ${tier || '< null >'}
- tier price: ${tierPrice}
- total amount donated: ${sponsor.totalAmountDonated}$
- averageMonthlyContribution: ${averageMonthlyContribution}
- last donation date: ${sponsor.lastTransactionAt}
- created: ${sponsor.createdAt}
- target link: ${sponsor.targetLink}
Expand All @@ -693,7 +720,7 @@ const processSponsors = async (collectiveSponsors, sponsorsConfig = './data/spon
return {
...sponsor,
averageMonthlyContribution,
score: Math.round(sponsor.totalAmountDonated * scoreTotalAmountFactor + averageMonthlyContribution + tierPrice * scoreTierPriceFactor)
score
};
})
.sort((a, b) => b.score - a.score)
Expand Down
15 changes: 15 additions & 0 deletions scss/sponsors.scss
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,21 @@ li.sponsor-card {
animation: tilt-move-shaking 0.8s infinite ease-in-out;
}

.sponsor_chevron_new{
width: 2.5rem;
height:2.5rem;
background-image: url(/assets/icons/new.svg);
background-size: cover;
background-repeat: no-repeat;
position: absolute;
left: -1.5rem;
top: -1rem;
transform: rotateZ(-45deg);
z-index: 1;
/* animation: tilt-shaking 0.5s infinite;*/
animation: tilt-move-shaking 0.8s infinite ease-in-out;
}


.become_sponsor{
display: flex;
Expand Down
5 changes: 3 additions & 2 deletions templates/home.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@
<a href="<%= sponsor.targetLink || '#' %>" target="_blank" >
<% if(sponsor.image){ %>
<div>
<% if(sponsor.benefits.crown) { %><div class="chevron"><span class="sponsor_chevron_crown"></span></div><% } %>
<% if(sponsor.benefits.crown) { %><div class="chevron"><span class="sponsor_chevron_crown"></span></div><% } else if (sponsor.isNew) { %>
<div class="chevron"><span class="sponsor_chevron_new"></span></div><% } %>
<img src="<%= sponsor.image %>" alt="<%= sponsor.alt %>"/>
</div><% } %>
<% if(sponsor.showCaption !== false){ %><span class="caption"><%= sponsor.displayName %></span><% } %>
Expand Down Expand Up @@ -235,7 +236,7 @@
document.addEventListener('DOMContentLoaded', () => {
setTimeout(() => {
splide.Components.AutoScroll.play();
}, 3000);
}, 5000);
});

splide.mount(window.splide.Extensions);
Expand Down
2 changes: 1 addition & 1 deletion templates/post.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@

setTimeout(() => {
splide.Components.AutoScroll.play();
}, 3000);
}, 5000);
}
}

Expand Down