openvibers/openvibe.deals Commits

A campaign's line leaves out a kind its platform's name already says (#198)

OP OpenVibers committed 11 days ago · 592d6b14c3 · 2 files, +5 −2

The home and /crowdfunding read "Logseq · Open Collective · Collective · #knowledge-base": the
kind COLLECTIVE repeated the last word of Open Collective. It is left out when the platform's
name ends with it.

Changes

ddiff --git a/server/http/crowdfunding.js b/server/http/crowdfunding.js
iindex ce3c2dd..411475c 100644
---- a/server/http/crowdfunding.js
++++ b/server/http/crowdfunding.js
@@@ -27,6 +27,8 @@ function money(cents, currency) {
}
const count = (n) => Number(n).toLocaleString('en-US');
const KIND = { COLLECTIVE: 'Collective', PROJECT: 'Project', FUND: 'Fund' };
++// The kind, unless the platform's name already ends with it ("Open Collective · Collective" on the home, 2026-11-02).
++const kindAfter = (c) => { const k = c.kind && KIND[c.kind]; return k && !String(c.platform || '').toLowerCase().endsWith(k.toLowerCase()) ? k : ''; };
function campaignCard(c) {
const raised = money(c.raised_cents, c.currency);
@@@ -34,7 +36,7 @@ function campaignCard(c) {
const facts = [raised ? `${raised} received to date` : null, c.backers ? `${count(c.backers)} contributor${c.backers === 1 ? '' : 's'}` : null, budget ? `${budget} a year` : null].filter(Boolean);
return html`<li class="card cf-campaign">
<h3><a href="${c.url}" rel="nofollow noopener">${c.name}</a></h3>
--<p class="meta">${c.platform}${c.kind && KIND[c.kind] ? html` · ${KIND[c.kind]}` : ''}${c.tag ? html` · #${c.tag}` : ''}</p>
++<p class="meta">${c.platform}${kindAfter(c) ? html` · ${kindAfter(c)}` : ''}${c.tag ? html` · #${c.tag}` : ''}</p>
${c.summary ? html`<p>${c.summary.length > 220 ? `${c.summary.slice(0, 217)}…` : c.summary}</p>` : ''}
${facts.length ? html`<p class="meta">${facts.join(' · ')} <span class="cf-asof">(as of ${day(c.observed_at)})</span></p>` : ''}
</li>`;
ddiff --git a/test/crowdfunding.test.js b/test/crowdfunding.test.js
iindex 30780ac..8cd8d59 100644
---- a/test/crowdfunding.test.js
++++ b/test/crowdfunding.test.js
@@@ -59,7 +59,8 @@ const campaign = (id, { slug, name, raised, backers, created, tag = null, type =
assert.ok(r.text.includes('href="https://www.kickstarter.com/discover" rel="nofollow noopener" target="_blank"'));
assert.ok(r.text.includes('$956,600 received to date · 12,182 contributors · $239,150 a year'), r.text.slice(r.text.indexOf('cf-campaign'), r.text.indexOf('cf-campaign') + 600));
assert.ok(r.text.includes('href="https://opencollective.com/logseq" rel="nofollow noopener"'));
-- assert.ok(r.text.includes('Open Collective · Collective · #knowledge-base'));
++ // The kind is left out when the platform's name already says it (no "Open Collective · Collective").
++ assert.ok(r.text.includes('Open Collective · #knowledge-base') && !r.text.includes('Open Collective · Collective'));
assert.match(robotsOf(r.text), /^index/);
const s = await t.get('/crowdfunding?q=solar+charger&sort=new');
assert.ok(s.text.includes('href="https://www.kickstarter.com/discover/advanced?term=solar%20charger&amp;sort=magic"'));