data = fetch("events.json", { cache: "no-store" })
.then(r => (r.ok ? r.json() : { events: [], failed: true }))
.catch(() => ({ events: [], failed: true }))upcoming events
← rubber rabbitbrush
Upcoming events
Readings, talks and shows by a few writers and musicians. Checked every Monday.
viewof view = {
const todayIso = new Date().toLocaleDateString("en-CA");
const upcoming = (data.events ?? []).filter(e => (e.end ?? e.start) >= todayIso);
const counts = { all: upcoming.length, near: upcoming.filter(e => e.near !== false).length };
const form = html`<div class="view-toggle" role="group" aria-label="Which events to show">
<button type="button" data-v="all">Everything everywhere <span class="count">${counts.all}</span></button>
<button type="button" data-v="near">Close to us <span class="count">${counts.near}</span></button>
</div>`;
const set = v => {
form.value = v;
form.querySelectorAll("button").forEach(b => b.setAttribute("aria-pressed", String(b.dataset.v === v)));
};
form.querySelectorAll("button").forEach(b => b.addEventListener("click", () => {
set(b.dataset.v);
history.replaceState(null, "", b.dataset.v === "all" ? "#everywhere" : location.pathname + location.search);
form.dispatchEvent(new Event("input", { bubbles: true }));
}));
set(location.hash === "#everywhere" ? "all" : "near");
return form;
}{
// ISO dates are parsed as local calendar dates, not UTC midnight.
const asDate = s => { const [y, m, d] = s.split("-").map(Number); return new Date(y, m - 1, d); };
const fmt = (d, opts) => d.toLocaleDateString("en-US", opts);
const todayIso = new Date().toLocaleDateString("en-CA");
if (data.failed) {
return html`<p class="events-empty">The event list didn't load. Try again in a bit.</p>`;
}
// The weekly run prunes past events. This also hides any that passed since.
const events = (data.events ?? [])
.filter(e => (e.end ?? e.start) >= todayIso)
.filter(e => view === "all" || e.near !== false)
.sort((a, b) => a.start.localeCompare(b.start) || a.name.localeCompare(b.name));
const updated = data.updated_at
? html`<p class="events-updated">Last checked ${fmt(new Date(data.updated_at), { month: "long", day: "numeric", year: "numeric" })}.</p>`
: "";
if (!events.length) {
const msg = view === "near"
? "Nothing close to us right now. Try Everything everywhere."
: "Nothing on the calendar right now.";
return html`<p class="events-empty">${msg}</p>${updated}`;
}
const when = e => {
const s = asDate(e.start);
if (!e.end || e.end === e.start) return fmt(s, { weekday: "short", month: "short", day: "numeric" });
const t = asDate(e.end);
const endOpts = t.getMonth() === s.getMonth() ? { day: "numeric" } : { month: "short", day: "numeric" };
return `${fmt(s, { month: "short", day: "numeric" })}–${fmt(t, endOpts)}`;
};
const countryName = new Intl.DisplayNames(["en"], { type: "region" });
const area = e => (e.country && e.country !== "US")
? (() => { try { return countryName.of(e.country); } catch { return e.country; } })()
: e.state;
const where = e => e.virtual
? "Online"
: [e.venue, e.city, area(e)].filter(Boolean).join(", ");
const row = e => html`<li class="event">
<div class="event-date">${when(e)}${e.time_local ? html`<span class="event-time">${e.time_local}</span>` : ""}</div>
<div class="event-body">
<div class="event-who">${e.name}</div>
<div class="event-title">${e.url ? html`<a href=${e.url} target="_blank" rel="noopener">${e.title ?? "Event details"}</a>` : (e.title ?? "")}</div>
<div class="event-where">${where(e)}
${e.virtual ? html`<span class="tag tag-virtual">virtual</span>` : ""}
${e.public === null ? html`<span class="tag tag-check" title="The listing doesn't say whether it's open to the public">check</span>` : ""}
</div>
</div>
</li>`;
const months = d3.groups(events, e => e.start.slice(0, 7));
return html`${months.map(([ym, list]) => html`<section class="event-month">
<h2>${fmt(asDate(ym + "-01"), { month: "long", year: "numeric" })}</h2>
<ul class="event-list">${list.map(row)}</ul>
</section>`)}${updated}`;
}roster = fetch("authors.json", { cache: "no-store" })
.then(r => (r.ok ? r.json() : { authors: [] }))
.catch(() => ({ authors: [] })){
const todayIso = new Date().toLocaleDateString("en-CA");
const counts = d3.rollup((data.events ?? []).filter(e => (e.end ?? e.start) >= todayIso), v => v.length, e => e.slug);
const groups = [
["Writers", ["author"]],
["Musicians", ["musician"]],
["Comedy and talks", ["comedian", "speaker"]],
["Bookstores", ["venue"]],
];
const byName = (a, b) => a.name.split(" ").at(-1).localeCompare(b.name.split(" ").at(-1));
const item = a => {
const n = counts.get(a.slug) ?? 0;
const label = a.homepage ? html`<a href=${a.homepage} target="_blank" rel="noopener">${a.name}</a>` : a.name;
return html`<li>${label}${n ? html`<span class="roster-count">${n}</span>` : ""}</li>`;
};
const sections = groups
.map(([title, kinds]) => [title, (roster.authors ?? []).filter(a => kinds.includes(a.kind)).sort(byName)])
.filter(([, list]) => list.length);
if (!sections.length) return html``;
return html`<section class="roster">
<h2>Who's on the list</h2>
<div class="roster-groups">${sections.map(([title, list]) => html`<div>
<h3>${title}</h3>
<ul>${list.map(item)}</ul>
</div>`)}</div>
<p class="roster-note">Numbers are upcoming events found so far, anywhere.</p>
</section>`;
}