openvibers/openvibe.deals Commits
A campaign's line leaves out a kind its platform's name already says (#198)
Changes
@@@ -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>`;@@@ -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&sort=magic"'));
@@ -27,6 +27,8 @@ function money(cents, currency) {
@@ -27,6 +27,8 @@ function money(cents, currency) {
}
}
const count = (n) => Number(n).toLocaleString('en-US');
const count = (n) => Number(n).toLocaleString('en-US');
const KIND = { COLLECTIVE: 'Collective', PROJECT: 'Project', FUND: 'Fund' };
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) {
function campaignCard(c) {
const raised = money(c.raised_cents, c.currency);
const raised = money(c.raised_cents, c.currency);
@@ -34,7 +36,7 @@ function campaignCard(c) {
@@ -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);
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">
return html`<li class="card cf-campaign">
<h3><a href="${c.url}" rel="nofollow noopener">${c.name}</a></h3>
<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>` : ''}
${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>` : ''}
${facts.length ? html`<p class="meta">${facts.join(' · ')} <span class="cf-asof">(as of ${day(c.observed_at)})</span></p>` : ''}
</li>`;
</li>`;
@@ -59,7 +59,8 @@ const campaign = (id, { slug, name, raised, backers, created, tag = null, type =
@@ -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('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('$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('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/);
assert.match(robotsOf(r.text), /^index/);
const s = await t.get('/crowdfunding?q=solar+charger&sort=new');
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&sort=magic"'));
assert.ok(s.text.includes('href="https://www.kickstarter.com/discover/advanced?term=solar%20charger&sort=magic"'));