diff --git a/assets/icons/new.svg b/assets/icons/new.svg new file mode 100644 index 00000000..da221262 --- /dev/null +++ b/assets/icons/new.svg @@ -0,0 +1,13 @@ + + + + new-rectangle + + + + + + + + + \ No newline at end of file diff --git a/data/sponsors.json b/data/sponsors.json index 10a14839..faa957d6 100644 --- a/data/sponsors.json +++ b/data/sponsors.json @@ -4,6 +4,9 @@ "disappearCredit": 20, "scoreTierPriceFactor": 0.80, "scoreTotalAmountFactor": 0.2, + "hide": { + "incognito": true + }, "tiers": { "backer" : { "name": "Backer", @@ -141,6 +144,9 @@ }, "stephan9": { "website": "https://webogram.net/" + }, + "soleks": { + "showCaption": false } } } diff --git a/scripts/updateData.js b/scripts/updateData.js index 396cccb9..922c3441 100644 --- a/scripts/updateData.js +++ b/scripts/updateData.js @@ -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)); @@ -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()]) { return; } @@ -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; + } } const tierId = sponsor.tier ? sponsor.tier?.toLowerCase() : null; @@ -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; @@ -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; @@ -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} @@ -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) diff --git a/scss/sponsors.scss b/scss/sponsors.scss index fca1f6ed..5dce73e4 100644 --- a/scss/sponsors.scss +++ b/scss/sponsors.scss @@ -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; diff --git a/templates/home.ejs b/templates/home.ejs index 5b5ff4db..2dd0499b 100644 --- a/templates/home.ejs +++ b/templates/home.ejs @@ -107,7 +107,8 @@ <% if(sponsor.image){ %>
- <% if(sponsor.benefits.crown) { %>
<% } %> + <% if(sponsor.benefits.crown) { %>
<% } else if (sponsor.isNew) { %> +
<% } %> <%= sponsor.alt %>
<% } %> <% if(sponsor.showCaption !== false){ %><%= sponsor.displayName %><% } %> @@ -235,7 +236,7 @@ document.addEventListener('DOMContentLoaded', () => { setTimeout(() => { splide.Components.AutoScroll.play(); - }, 3000); + }, 5000); }); splide.mount(window.splide.Extensions); diff --git a/templates/post.ejs b/templates/post.ejs index 0e53a2c9..526da342 100644 --- a/templates/post.ejs +++ b/templates/post.ejs @@ -357,7 +357,7 @@ setTimeout(() => { splide.Components.AutoScroll.play(); - }, 3000); + }, 5000); } }