openvibers/openvibe.markets Commits

Alerts through Deals' watches (#4)

OP OpenVibers committed 13 days ago · 6eae133558 · 3 files, +6 −1

Plan §L.1 ("Watch tells you when the price drops"). Deals already keeps keyword and price-below watches for
signed-in people, and /watches?query= fills "Alert me about …": a search's Deals results link there. No
second alert system in Markets.

Changes

ddiff --git a/public/markets.css b/public/markets.css
iindex e44ba06..6bedd96 100644
---- a/public/markets.css
++++ b/public/markets.css
@@@ -67,3 +67,6 @@ html[data-ov-motion="off"] .mk-photo.is-busy .mk-photo-said { animation: none; }
.mk-error { padding: 10px 14px; border-radius: 12px; border: 1px solid var(--danger, #b91c1c); color: var(--danger, #fca5a5); }
.mk-from-photo { margin: 8px 0 0; color: var(--text-secondary, #9aa4b2); }
.mk-from-photo b { color: var(--text, #e8ecf3); }
++.mk-watch { margin: 10px 0 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
++.mk-watch a { display: inline-flex; align-items: center; min-height: 44px; font-weight: 600; color: var(--accent, #5b8cff); }
++.mk-watch small { color: var(--text-secondary, #9aa4b2); }
ddiff --git a/server/views.js b/server/views.js
iindex e4ef91f..f3fd839 100644
---- a/server/views.js
++++ b/server/views.js
@@@ -87,7 +87,8 @@ function results({ q, deals, links, now = Date.now(), fromPhoto = false }) {
return page({
title: `${q}: every marketplace`, path: `/search?q=${encodeURIComponent(q)}`, robots: 'noindex, follow', body: `
<header class="mk-head">${searchForm(q)}${fromPhoto ? `<p class="mk-from-photo">From your photo: <b>${esc(q)}</b>. Not quite it? Change the words above.</p>` : ''}</header>
--<section class="mk-sec" aria-labelledby="mk-deals-h"><h2 id="mk-deals-h">Deals</h2>${found}</section>
++<section class="mk-sec" aria-labelledby="mk-deals-h"><h2 id="mk-deals-h">Deals</h2>${found}
++<p class="mk-watch"><a href="https://openvibe.deals/watches?query=${encodeURIComponent(q)}">Alert me about new deals for “${esc(q)}”</a> <small>on OpenVibe Deals, when you are signed in</small></p></section>
<section class="mk-sec" aria-labelledby="mk-else-h"><h2 id="mk-else-h">Search it on</h2>
<ul class="mk-elsewhere">${links.map((l) => `<li><a href="${esc(l.url)}" target="_blank" rel="noopener noreferrer"><b>${esc(l.name)}</b><small>${esc(l.kind)}</small></a></li>`).join('')}</ul>
<p class="mk-note">These open each marketplace's own search with your words in it. Markets does not fetch from them or know what you do there; as a permitted feed comes for one, its listings join the results above.</p></section>` });
ddiff --git a/test/app.test.js b/test/app.test.js
iindex 257ac71..70eb085 100644
---- a/test/app.test.js
++++ b/test/app.test.js
@@@ -70,6 +70,7 @@ const OFFERS = [
assert.doesNotMatch(r.text, /javascript:alert/, 'only https links');
assert.match(r.text, /<a href="https:\/\/www\.ebay\.com\/sch\/i\.html\?_nkw=headphones" target="_blank" rel="noopener noreferrer">/);
assert.strictEqual(asked.pop(), '/api/v1/search?q=headphones&limit=24');
++ assert.match(r.text, /href="https:\/\/openvibe\.deals\/watches\?query=headphones">Alert me about new deals for “headphones”/, 'alerts are Deals\' watches');
r = await get('/search?q=a%20sofa');
assert.match(r.text, /No deal on OpenVibe Deals matches these words yet/);