@profullstack/waitlist 0.9.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/package.json +1 -1
- package/src/build.js +7 -0
- package/src/community.js +83 -0
- package/src/plugins.js +4 -2
- package/src/search.js +22 -6
- package/src/waitlist.css +9 -0
package/README.md
CHANGED
|
@@ -139,6 +139,8 @@ Every page showcases all plugins by default. Pick per site in `sites.json`:
|
|
|
139
139
|
| `buyaday` | `<pf-buy-a-day>` from [@profullstack/marketing-widgets](https://github.com/profullstack/marketing-widgets): the next free doors on [holi.days](https://holi.days.pit.world/calendars) calendars (ones matching the site's keywords first), baked in and refreshed live, every sale credited to this site with `?ref=<host>`. Nothing shows when the feed is down. `buyadayKeywords` / `buyadayLimit` in `sites.json` override the keywords and count (default 3) |
|
|
140
140
|
| `book` | The Profullstack pitch (four solution lines) and `<book-a-call>`, our booking widget: open times from the OutreachGraph public calendar in the reader's own time zone, booked inline as a PairUX call. A plain link to the booking page without script. `"booking": {"handle": "chovy"}` picks the calendar |
|
|
141
141
|
| `promo` | "More from the network": sister properties from the live `@profullstack/cross-promo` catalog, tagged `utm_medium=waitlist`. `"promoAudience": "developers"` (or a list) overrides the audience picked from the hierarchy |
|
|
142
|
+
| `community` | A header bar with Search and a branded **Community** button to the name's own tsbb board (`https://bbs.<name>.pit.world`, sign in with pit.world / CoinPay OAuth 2.1, or `tsbb login <board> --with coinpay`). Linked only once the board answers over HTTPS, so new names gain it as their certificate lands. Writes `brand.json` (look, colours, light/dark, closest tsbb skin) that pit.world's board seed uses to match the site |
|
|
143
|
+
| (search, resources) | Every search item and resource carries pit.world's result tools from `https://pit.world/widgets.js`: vote, Summarize, Listen and Share. They work without an account; on a pit.world host, "Sign in with CoinPay" (OAuth 2.1 + PKCE through pit.world) raises the limits. From a terminal the same account is `pit login` |
|
|
142
144
|
| `affiliate` | Referrals (0.9). Every signup gets a personal link `https://<site>/?ref=<code>`, shown right after joining by `<pf-referral-share>` ("You are #X of Y, N people referred.", copy button, plain X/Bluesky/LinkedIn/email links) and in the confirmation email with a signed status page. A visitor who arrives with `?ref=` keeps a 30-day first-party, first-touch cookie `wl_ref`; their signup credits the referrer once they confirm. Each confirmed referral moves the referrer up `bumpPlaces`. A "Move up the list" section bakes `<pf-referral-leaderboard>` (handles or masked emails only). With `buyaday` on, a door sold to a referred visitor credits the referrer too (holi.days `ref=<code>.<site>`). See below |
|
|
143
145
|
|
|
144
146
|
### Referrals (`affiliate`)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@profullstack/waitlist",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "Email waitlist for any launch page: a <waitlist-form> web component, a live signup chart, and a static-site builder on @profullstack/css + @profullstack/charts.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
package/src/build.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { mkdir, writeFile, copyFile, readFile, readdir } from 'node:fs/promises';
|
|
6
6
|
import { pluginSet, keywordsFor, runPlugins, baseSlot, affiliateConfig } from './plugins.js';
|
|
7
|
+
import { boardLive, boardUrl, brandJson, navHtml } from './community.js';
|
|
7
8
|
import {
|
|
8
9
|
TABS, SORTS, tabPath, searchPageHtml, searchPageMeta, searchJson, searchLlms, manifestJson,
|
|
9
10
|
openSearchXml, serviceWorker, maskableIconSvg,
|
|
@@ -168,6 +169,7 @@ ${slot.head.join('\n')}
|
|
|
168
169
|
</head>
|
|
169
170
|
<body class="waitlist-page">
|
|
170
171
|
<div data-look-marquee aria-hidden="true"><span>${esc(s.marquee)}</span></div>
|
|
172
|
+
${navHtml(s, { community: s.community ?? null, esc })}
|
|
171
173
|
<main class="container">
|
|
172
174
|
${main}
|
|
173
175
|
<p class="waitlist-meta">${s.moshpit ? `Also at <a href="${esc(s.nativeUrl)}">${esc(s.nativeUrl.replace(/\/$/, ''))}</a> on the Moshpit. ` : ''}One email when it opens, nothing else. Hosted on <a href="https://c0mpute.com/hosting">c0mpute</a>.</p>
|
|
@@ -261,6 +263,11 @@ export async function buildSite(spec, out, { footers = true, images = true, fetc
|
|
|
261
263
|
const foot = footers ? await renderFooters(s, { fetchImpl }) : '';
|
|
262
264
|
const { slot, search } = await runPlugins(s, out, { fetchImpl, cacheDir, maxAgeMs, searchOpts });
|
|
263
265
|
s.searchLive = Boolean(search?.live?.length);
|
|
266
|
+
// community: the name's own board, linked once it answers over HTTPS; brand.json for its look.
|
|
267
|
+
if (s.plugins.has('community')) {
|
|
268
|
+
s.community = (await boardLive(boardUrl(s), { fetchImpl })) ? boardUrl(s) : null;
|
|
269
|
+
await writeFile(join(out, 'brand.json'), JSON.stringify(await brandJson(s), null, 2) + '\n');
|
|
270
|
+
}
|
|
264
271
|
// Assets are cached by browsers and gateways (max-age 1 h), so a page must name the
|
|
265
272
|
// exact build of every script and stylesheet it needs, or a new page runs old code.
|
|
266
273
|
const ver = await versionAssets(out);
|
package/src/community.js
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* community: a branded "Community" link to the name's own board, and the site's brand for it.
|
|
3
|
+
*
|
|
4
|
+
* Every Moshpit name has a tsbb board at https://bbs.<name>.pit.world (pit.world makes it on the
|
|
5
|
+
* first visit; people sign in with their pit.world account, which is CoinPay OAuth 2.1, or with
|
|
6
|
+
* `tsbb login <board> --with coinpay` from a terminal). Its HTTPS certificate arrives with the
|
|
7
|
+
* name's, so the link is drawn only once the board answers over HTTPS: the daily rebuild adds it
|
|
8
|
+
* as certificates land, and a page never links to a broken board.
|
|
9
|
+
*
|
|
10
|
+
* brand.json tells the board how to look like this site: the look, its colours, light or dark,
|
|
11
|
+
* and the closest tsbb skin. pit.world's board seed reads it.
|
|
12
|
+
*/
|
|
13
|
+
import { readFile } from 'node:fs/promises';
|
|
14
|
+
import { createRequire } from 'node:module';
|
|
15
|
+
import { dirname, join } from 'node:path';
|
|
16
|
+
|
|
17
|
+
const require = createRequire(import.meta.url);
|
|
18
|
+
|
|
19
|
+
/** The closest tsbb skin (modern, classic, terminal, paper) for each @profullstack/css look. */
|
|
20
|
+
const SKIN = {
|
|
21
|
+
terminal: 'terminal', matrix: 'terminal', amber: 'terminal', bbs: 'terminal', minitel: 'terminal', compuserve: 'terminal',
|
|
22
|
+
geocities: 'classic', aol: 'classic', prodigy: 'classic', brutalist: 'classic',
|
|
23
|
+
editorial: 'paper', swiss: 'paper',
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
let looksCss = null;
|
|
27
|
+
async function looks() {
|
|
28
|
+
looksCss ??= await readFile(join(dirname(require.resolve('@profullstack/css/css')), 'looks.css'), 'utf8');
|
|
29
|
+
return looksCss;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** A look's palette from @profullstack/css: { scheme, primary, canvas, ink }. Missing values are null. */
|
|
33
|
+
export async function lookPalette(look) {
|
|
34
|
+
const css = await looks();
|
|
35
|
+
const at = css.indexOf(`:root[data-look="${look}"] {`);
|
|
36
|
+
if (at < 0) return { scheme: null, primary: null, canvas: null, ink: null };
|
|
37
|
+
const block = css.slice(at, css.indexOf('}', at));
|
|
38
|
+
const v = (name) => block.match(new RegExp(`--pf-color-${name}\\s*:\\s*(#[0-9a-fA-F]{3,8})`))?.[1] ?? null;
|
|
39
|
+
return { scheme: block.match(/color-scheme:\s*(light|dark)/)?.[1] ?? null, primary: v('primary'), canvas: v('canvas'), ink: v('ink') };
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function boardUrl(s) {
|
|
43
|
+
return s.moshpit ? `https://bbs.${s.name}.pit.world/` : null;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export async function brandJson(s) {
|
|
47
|
+
const p = await lookPalette(s.look);
|
|
48
|
+
return {
|
|
49
|
+
name: s.name,
|
|
50
|
+
title: s.title,
|
|
51
|
+
tagline: s.tagline,
|
|
52
|
+
url: s.url,
|
|
53
|
+
look: s.look,
|
|
54
|
+
scheme: p.scheme ?? (s.theme === 'light' ? 'light' : 'dark'),
|
|
55
|
+
primary: p.primary,
|
|
56
|
+
canvas: p.canvas,
|
|
57
|
+
ink: p.ink,
|
|
58
|
+
skin: SKIN[s.look] ?? 'modern',
|
|
59
|
+
icon: `${s.url}assets/icon-192.png`,
|
|
60
|
+
community: boardUrl(s),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** True when the board answers over HTTPS (any status below 500). Never throws. */
|
|
65
|
+
export async function boardLive(url, { fetchImpl = globalThis.fetch, timeoutMs = 10000 } = {}) {
|
|
66
|
+
if (!url) return false;
|
|
67
|
+
try {
|
|
68
|
+
const r = await fetchImpl(`${url}healthz`, { method: 'GET', redirect: 'manual', signal: AbortSignal.timeout(timeoutMs), headers: { 'user-agent': '@profullstack/waitlist (+https://github.com/profullstack/waitlist)' } });
|
|
69
|
+
return r.status < 500;
|
|
70
|
+
} catch {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** The header bar: the site's name, its search, and the Community link when the board is live. */
|
|
76
|
+
export function navHtml(s, { community = null, esc }) {
|
|
77
|
+
const links = [
|
|
78
|
+
s.searchLive ? `<a href="search/">Search</a>` : '',
|
|
79
|
+
community ? `<a class="waitlist-community" href="${esc(community)}" rel="noopener">Community</a>` : '',
|
|
80
|
+
].filter(Boolean);
|
|
81
|
+
if (!links.length) return '';
|
|
82
|
+
return `<nav class="waitlist-nav container" aria-label="${esc(s.title)}"><a class="waitlist-nav-home" href="./">${esc(s.title)}</a><span class="waitlist-nav-links">${links.join('')}</span></nav>`;
|
|
83
|
+
}
|
package/src/plugins.js
CHANGED
|
@@ -24,7 +24,7 @@ import { fetchSearch, searchCardHtml } from './search.js';
|
|
|
24
24
|
|
|
25
25
|
const require = createRequire(import.meta.url);
|
|
26
26
|
|
|
27
|
-
export const PLUGINS = ['form', 'stats', 'ab', 'faq', 'search', 'resources', 'board', 'share', 'feed', 'buyaday', 'book', 'promo', 'affiliate'];
|
|
27
|
+
export const PLUGINS = ['form', 'stats', 'ab', 'faq', 'search', 'resources', 'board', 'share', 'feed', 'buyaday', 'book', 'promo', 'affiliate', 'community'];
|
|
28
28
|
|
|
29
29
|
/** Resolve a site's `plugins` setting to a Set (default: all of them). */
|
|
30
30
|
export function pluginSet(setting) {
|
|
@@ -131,7 +131,7 @@ export function resourcesHtml(s, res, { comments = false, share = false } = {})
|
|
|
131
131
|
if (!res?.results?.length) return '';
|
|
132
132
|
return `<section class="stack" aria-labelledby="resources"><h2 id="resources">Resources</h2>
|
|
133
133
|
<p class="muted">Useful reading on ${esc(s.title)} while you wait, from <a href="https://pit.world/search?q=${encodeURIComponent(res.query)}">pit.world search</a>.</p>
|
|
134
|
-
<ul role="list" class="grid" data-columns="2">${res.results.map((r) => `<li class="card stack" data-space="sm"><a href="${esc(r.url)}" rel="noopener"><strong>${esc(r.title)}</strong></a><small class="muted">${esc(r.host)}</small>${r.summary ? `<p>${esc(r.summary)}</p>` : ''}${thread(r)}</li>`).join('')}</ul>
|
|
134
|
+
<ul role="list" class="grid" data-columns="2">${res.results.map((r) => `<li class="card stack" data-space="sm" data-pit-result data-url="${esc(r.url)}" data-title="${esc(r.title)}" data-host="${esc(r.host)}" data-q="${esc(res.query)}" data-tab="web"><a href="${esc(r.url)}" rel="noopener"><strong>${esc(r.title)}</strong></a><small class="muted">${esc(r.host)}</small>${r.summary ? `<p>${esc(r.summary)}</p>` : ''}${thread(r)}</li>`).join('')}</ul>
|
|
135
135
|
</section>`;
|
|
136
136
|
}
|
|
137
137
|
|
|
@@ -184,6 +184,8 @@ export async function runPlugins(s, out, { fetchImpl, cacheDir, maxAgeMs, search
|
|
|
184
184
|
: await fetchResources(s, { fetchImpl, cacheDir, maxAgeMs });
|
|
185
185
|
slot.sections.push(resourcesHtml(s, res, { comments: on.has('board'), share: on.has('share') }));
|
|
186
186
|
if (res.results.length) await writeFile(join(out, 'resources.json'), JSON.stringify(res, null, 2) + '\n');
|
|
187
|
+
// pit.world's own tools under each resource: vote, Summarize, Listen (https://pit.world/widgets.js).
|
|
188
|
+
if (res.results.length) slot.scripts.push('<script type="module" src="https://pit.world/widgets.js"></script>');
|
|
187
189
|
}
|
|
188
190
|
if (on.has('board')) {
|
|
189
191
|
const dir = dirname(require.resolve('@profullstack/comments'));
|
package/src/search.js
CHANGED
|
@@ -91,6 +91,8 @@ export function normalizeHit(x) {
|
|
|
91
91
|
channel: str(x.channel, 80),
|
|
92
92
|
author: str(x.author, 160),
|
|
93
93
|
extra: str(x.extra, 80),
|
|
94
|
+
// pit.world's signed Share link for this hit (its own page there).
|
|
95
|
+
share: typeof x.share === 'string' && x.share.startsWith('https://pit.world/share?') ? x.share : undefined,
|
|
94
96
|
};
|
|
95
97
|
for (const k of Object.keys(hit)) if (hit[k] === undefined) delete hit[k];
|
|
96
98
|
return hit;
|
|
@@ -219,14 +221,26 @@ function fmtDate(h) {
|
|
|
219
221
|
return /^\d{4}$/.test(h.date) ? h.date : new Date(t).toISOString().slice(0, 10);
|
|
220
222
|
}
|
|
221
223
|
|
|
222
|
-
|
|
224
|
+
/** The script that draws pit.world's tools (vote, Summarize, Listen, Share) under every marked result. */
|
|
225
|
+
export const TOOLS_SCRIPT = '<script type="module" src="https://pit.world/widgets.js"></script>';
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Marks a result for pit.world's tools (https://pit.world/widgets.js). They work without an
|
|
229
|
+
* account; signing in with CoinPay (OAuth 2.1) on a pit.world host raises the limits.
|
|
230
|
+
*/
|
|
231
|
+
export function toolAttrs(h, { q = '', tab = 'web', tools = '' } = {}) {
|
|
232
|
+
return ` data-pit-result data-url="${esc(h.url)}" data-title="${esc(h.title)}" data-host="${esc(h.host)}" data-q="${esc(q)}" data-tab="${esc(tab)}"${h.share ? ` data-share="${esc(h.share)}"` : ''}${tools ? ` data-tools="${esc(tools)}"` : ''}`;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
function hitHtml(h, tab, v, q = '') {
|
|
223
236
|
const meta = [h.host, h.author, h.channel, fmtDate(h), h.duration, h.extra].filter(Boolean).map(esc).join(' · ');
|
|
224
|
-
|
|
237
|
+
// Without script the count stands alone; with it, the vote buttons carry the live count.
|
|
238
|
+
const voted = v ? `<noscript> <span class="badge" title="pit.world votes">▲ ${v.up - v.down}</span></noscript>` : '';
|
|
225
239
|
if (tab === 'images') {
|
|
226
|
-
return `<li class="card wl-hit wl-hit-image"><a href="${esc(h.url)}" rel="noopener">${h.thumbnail ? `<img src="${esc(h.thumbnail)}" alt="${esc(h.title)}" loading="lazy" decoding="async" referrerpolicy="no-referrer">` : ''}<span>${esc(h.title)}</span></a><small class="muted">${esc(h.host)}</small></li>`;
|
|
240
|
+
return `<li class="card wl-hit wl-hit-image"${toolAttrs(h, { q, tab, tools: 'vote share' })}><a href="${esc(h.url)}" rel="noopener">${h.thumbnail ? `<img src="${esc(h.thumbnail)}" alt="${esc(h.title)}" loading="lazy" decoding="async" referrerpolicy="no-referrer">` : ''}<span>${esc(h.title)}</span></a><small class="muted">${esc(h.host)}</small></li>`;
|
|
227
241
|
}
|
|
228
242
|
const thumb = h.thumbnail ? `<img class="wl-thumb" src="${esc(h.thumbnail)}" alt="" loading="lazy" decoding="async" referrerpolicy="no-referrer" width="96" height="96">` : '';
|
|
229
|
-
return `<li class="card wl-hit">${thumb}<div class="stack" data-space="xs"><a href="${esc(h.url)}" rel="noopener"><strong>${esc(h.title)}</strong></a>${voted}<small class="muted">${meta}</small>${h.summary ? `<p>${esc(h.summary)}</p>` : ''}</div></li>`;
|
|
243
|
+
return `<li class="card wl-hit"${toolAttrs(h, { q, tab })}>${thumb}<div class="stack" data-space="xs" data-pit-tools><a href="${esc(h.url)}" rel="noopener"><strong>${esc(h.title)}</strong></a>${voted}<small class="muted">${meta}</small>${h.summary ? `<p>${esc(h.summary)}</p>` : ''}</div></li>`;
|
|
230
244
|
}
|
|
231
245
|
|
|
232
246
|
/** The SEO fields of one search page. */
|
|
@@ -306,9 +320,11 @@ export function searchPageHtml(s, search, tabId, sort, { chrome }) {
|
|
|
306
320
|
<nav class="wl-tabs" aria-label="Search tabs"><ul role="list">${tabs}</ul></nav>
|
|
307
321
|
<nav class="wl-sorts" aria-label="Sort"><ul role="list">${sorts}</ul></nav>
|
|
308
322
|
<section aria-labelledby="results" class="stack"><h2 id="results" class="visually-hidden">${esc(tabMeta.label)} results</h2>
|
|
309
|
-
<ol role="list" class="wl-results${tabId === 'images' ? ' wl-results-images' : ''}">${hits.map((h) => hitHtml(h, tabId, search.votes.get(h.url))).join('')}</ol>
|
|
323
|
+
<ol role="list" class="wl-results${tabId === 'images' ? ' wl-results-images' : ''}">${hits.map((h) => hitHtml(h, tabId, search.votes.get(h.url), data.query)).join('')}</ol>
|
|
324
|
+
<p data-pit-account></p>
|
|
310
325
|
<p class="muted">Results from <a href="https://pit.world/search?q=${encodeURIComponent(data.query)}${tabId === 'web' ? '' : `&t=${tabId}`}">pit.world search</a>${data.provider ? ` (${esc(data.provider)})` : ''}, updated ${esc(data.fetchedAt.slice(0, 10))}.</p>
|
|
311
|
-
</section
|
|
326
|
+
</section>
|
|
327
|
+
${TOOLS_SCRIPT}`;
|
|
312
328
|
return { html: rebase(chrome({ head, body, spec: ps }), up), path: tabPath(tabId, sort), meta: m };
|
|
313
329
|
}
|
|
314
330
|
|
package/src/waitlist.css
CHANGED
|
@@ -46,3 +46,12 @@
|
|
|
46
46
|
.wl-search .field-group { display: flex; gap: .4rem; }
|
|
47
47
|
.wl-search input[type="search"] { flex: 1; min-width: 0; }
|
|
48
48
|
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
|
|
49
|
+
|
|
50
|
+
/* community: the header bar with the Community link (0.11.0) */
|
|
51
|
+
.waitlist-nav { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-block: .75rem; }
|
|
52
|
+
.waitlist-nav-home { font-weight: 700; text-decoration: none; color: inherit; }
|
|
53
|
+
.waitlist-nav-links { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
|
|
54
|
+
.waitlist-nav-links a { text-decoration: none; padding: .35rem .8rem; border-radius: 999px; border: 1px solid color-mix(in srgb, currentColor 25%, transparent); color: inherit; font-size: .9rem; }
|
|
55
|
+
.waitlist-nav-links a:hover { border-color: currentColor; }
|
|
56
|
+
.waitlist-nav-links a.waitlist-community { background: var(--pf-color-primary, currentColor); color: var(--pf-color-on-primary, #fff); border-color: transparent; font-weight: 700; }
|
|
57
|
+
.waitlist-nav-links a.waitlist-community:hover { filter: brightness(1.1); }
|