@vermeulen.solutions/eventual 0.18.6 → 0.19.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 +10 -10
- package/astro/EventList.astro +124 -5
- package/astro/blueprint.d.mts +2 -0
- package/astro/blueprint.mjs +1 -1
- package/astro/events/EventBrowser.astro +261 -0
- package/astro/events/EventDetail.astro +113 -0
- package/astro/events/description.ts +183 -0
- package/astro/events/grid.ts +199 -0
- package/astro/events/i18n.ts +122 -0
- package/astro/events/index.ts +301 -0
- package/astro/events/links.ts +54 -0
- package/astro/events/parts/AgendaItem.astro +74 -0
- package/astro/events/parts/DateTile.astro +24 -0
- package/astro/events/parts/EventCard.astro +63 -0
- package/astro/events/parts/Icon.astro +26 -0
- package/astro/events/parts/StatusBadge.astro +23 -0
- package/astro/events/parts/Styles.astro +1453 -0
- package/astro/events/state.ts +82 -0
- package/dist/index.mjs +1 -11
- package/dist/plugin.mjs +7 -7
- package/docs/collection-setup.md +2 -2
- package/docs/developer-guide.md +76 -2
- package/docs/registry-installation.md +2 -2
- package/docs/release-notes-0.18.7.md +13 -0
- package/docs/release-notes-0.19.0.md +12 -0
- package/docs/user-guide.md +1 -1
- package/emdash-plugin.jsonc +0 -2
- package/package.json +8 -3
- package/scripts/export-native-schema.mjs +7 -3
- package/src/domain/calendar-links.ts +3 -1
- package/src/domain/invocation-budget.ts +12 -7
- package/src/domain/native-calendar.ts +12 -3
- package/src/schema/blueprint.ts +3 -1
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event pages for EmDash sites: loaders that run in the site's page, and the data the
|
|
3
|
+
* EventBrowser and EventDetail components render. A page sets `Astro.response.status` from the
|
|
4
|
+
* loader (502 when the feed fails, 404 for an unknown event), which a component cannot do.
|
|
5
|
+
*
|
|
6
|
+
* const data = await loadEventBrowser(Astro.url, { pluginId: "r_…", locale: "fr" });
|
|
7
|
+
* Astro.response.status = data.status;
|
|
8
|
+
*/
|
|
9
|
+
import { fetchPublicFeed, serializeJsonLd, eventToJsonLd, type PublicEvent } from "../feed";
|
|
10
|
+
import { safeWebUrl, type CalendarLinks } from "../event-details";
|
|
11
|
+
import { eventPageUrl } from "../event-list";
|
|
12
|
+
import { buildCalendar, calendarRange, displayDate, eventEndDate, eventStartDate, eventTimeRange, monthDateRange, monthLabel, monthOf, normalizeLocale, normalizeTimeZone, weekdayHeadings, type CalendarCell } from "./grid";
|
|
13
|
+
import { EVENT_VIEWS, adjacentMonth, eventBrowserHref, eventBrowserState, eventRange, offeredViews, type EventBrowserState, type EventView } from "./state";
|
|
14
|
+
import { absoluteCalendarLinks, calendarSubscriptionUrl, decodeRouteParam, safeImageUrl } from "./links";
|
|
15
|
+
import { descriptionExcerpt, descriptionHtml } from "./description";
|
|
16
|
+
import { eventPageText, type EventPageText } from "./i18n";
|
|
17
|
+
|
|
18
|
+
export * from "./grid";
|
|
19
|
+
export * from "./state";
|
|
20
|
+
export * from "./links";
|
|
21
|
+
export { descriptionExcerpt, descriptionHtml } from "./description";
|
|
22
|
+
export { eventPageText, EVENT_PAGES_EN, type EventPageText } from "./i18n";
|
|
23
|
+
export type { PublicEvent } from "../feed";
|
|
24
|
+
|
|
25
|
+
export interface EventPagesOptions {
|
|
26
|
+
/** Installed plugin ID: `eventual` for a config install, `r_…` for a Registry install. */
|
|
27
|
+
pluginId?: string;
|
|
28
|
+
/** Origin of the EmDash site that serves the feed (default: the page's own). */
|
|
29
|
+
origin?: string;
|
|
30
|
+
/** Page language: texts, dates and the feed's content language (default "en"). */
|
|
31
|
+
locale?: string;
|
|
32
|
+
/** Content language for the feed when it differs from `locale` (default: its language part). */
|
|
33
|
+
contentLocale?: string;
|
|
34
|
+
/** Only events translated into the content language (default false: others show with a language prefix). */
|
|
35
|
+
strict?: boolean;
|
|
36
|
+
/** Time zone for "this month" and "today" (default UTC). Event times use each event's own zone. */
|
|
37
|
+
timeZone?: string;
|
|
38
|
+
/** Address of the events page; detail pages are `<basePath>/<slug>` (default "/events"). */
|
|
39
|
+
basePath?: string;
|
|
40
|
+
/** "detail" links to the package's detail page; "cms" to the entry's own public URL when it has one. */
|
|
41
|
+
linkTo?: "detail" | "cms";
|
|
42
|
+
/** Views offered, in order, and the default one. */
|
|
43
|
+
views?: readonly EventView[];
|
|
44
|
+
defaultView?: EventView;
|
|
45
|
+
/** Fixed values instead of the query string. */
|
|
46
|
+
view?: EventView;
|
|
47
|
+
month?: string;
|
|
48
|
+
category?: string;
|
|
49
|
+
/** For tests: the current time. */
|
|
50
|
+
now?: Date;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface DateGroup {
|
|
54
|
+
date: string;
|
|
55
|
+
id: string;
|
|
56
|
+
label: string;
|
|
57
|
+
weekday: string;
|
|
58
|
+
day: string;
|
|
59
|
+
events: PublicEvent[];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface LocationGroup {
|
|
63
|
+
location: string;
|
|
64
|
+
directionsUrl: string;
|
|
65
|
+
events: PublicEvent[];
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface EventBrowserData {
|
|
69
|
+
status: 200 | 502;
|
|
70
|
+
pageTitle: string;
|
|
71
|
+
description: string;
|
|
72
|
+
text: EventPageText;
|
|
73
|
+
lang: string;
|
|
74
|
+
dir: "ltr" | "rtl";
|
|
75
|
+
locale: string;
|
|
76
|
+
origin: string;
|
|
77
|
+
pluginId: string;
|
|
78
|
+
basePath: string;
|
|
79
|
+
linkTo: "detail" | "cms";
|
|
80
|
+
state: EventBrowserState;
|
|
81
|
+
views: Array<{ view: EventView; label: string; href: string; current: boolean }>;
|
|
82
|
+
monthTitle: string;
|
|
83
|
+
previous: { href: string; label: string };
|
|
84
|
+
next: { href: string; label: string };
|
|
85
|
+
current: { href: string; label: string; isCurrent: boolean };
|
|
86
|
+
clearHref: string;
|
|
87
|
+
categories: string[];
|
|
88
|
+
events: PublicEvent[];
|
|
89
|
+
weeks: CalendarCell[][];
|
|
90
|
+
weekdays: { short: string[]; long: string[] };
|
|
91
|
+
dateGroups: DateGroup[];
|
|
92
|
+
locationGroups: LocationGroup[];
|
|
93
|
+
today: string;
|
|
94
|
+
subscriptionUrl: string;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export interface EventDetailData {
|
|
98
|
+
status: 200 | 404 | 502;
|
|
99
|
+
pageTitle: string;
|
|
100
|
+
description: string;
|
|
101
|
+
text: EventPageText;
|
|
102
|
+
lang: string;
|
|
103
|
+
dir: "ltr" | "rtl";
|
|
104
|
+
locale: string;
|
|
105
|
+
origin: string;
|
|
106
|
+
pluginId: string;
|
|
107
|
+
backHref: string;
|
|
108
|
+
event?: PublicEvent;
|
|
109
|
+
jsonLd?: string;
|
|
110
|
+
dateText?: string;
|
|
111
|
+
timeText?: string;
|
|
112
|
+
imageUrl?: string;
|
|
113
|
+
websiteUrl?: string;
|
|
114
|
+
directionsUrl?: string;
|
|
115
|
+
onlineUrl?: string;
|
|
116
|
+
descriptionHtml?: string;
|
|
117
|
+
calendarLinks?: CalendarLinks;
|
|
118
|
+
subscriptionUrl?: string;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
interface Resolved {
|
|
122
|
+
locale: string;
|
|
123
|
+
contentLocale: string;
|
|
124
|
+
timeZone: string;
|
|
125
|
+
origin: string;
|
|
126
|
+
pluginId: string;
|
|
127
|
+
basePath: string;
|
|
128
|
+
linkTo: "detail" | "cms";
|
|
129
|
+
now: Date;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function resolve(url: URL, options: EventPagesOptions): Resolved {
|
|
133
|
+
const locale = normalizeLocale(options.locale ?? "en");
|
|
134
|
+
return {
|
|
135
|
+
locale,
|
|
136
|
+
contentLocale: options.contentLocale ?? locale.split("-")[0]!,
|
|
137
|
+
timeZone: normalizeTimeZone(options.timeZone ?? "UTC"),
|
|
138
|
+
origin: safeWebUrl(options.origin ?? "") || url.origin,
|
|
139
|
+
pluginId: options.pluginId || "eventual",
|
|
140
|
+
basePath: (options.basePath ?? "/events").replace(/\/+$/, "") || "/events",
|
|
141
|
+
linkTo: options.linkTo ?? "detail",
|
|
142
|
+
now: options.now ?? new Date(),
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** The events page: fetches one month (or the weeks around it for the month view). */
|
|
147
|
+
export async function loadEventBrowser(url: URL, options: EventPagesOptions = {}): Promise<EventBrowserData> {
|
|
148
|
+
const settings = resolve(url, options);
|
|
149
|
+
const state = eventBrowserState(url.searchParams, monthOf(settings.now, settings.timeZone), options);
|
|
150
|
+
const range = state.view === "month" ? calendarRange(state.month, settings.locale) : monthDateRange(state.month);
|
|
151
|
+
let events: PublicEvent[] | null = null;
|
|
152
|
+
try {
|
|
153
|
+
const feed = await fetchPublicFeed(settings.origin, range.from, range.through, state.category, {
|
|
154
|
+
locale: settings.contentLocale,
|
|
155
|
+
strict: options.strict ?? false,
|
|
156
|
+
publicUrls: settings.linkTo === "cms",
|
|
157
|
+
pluginId: settings.pluginId,
|
|
158
|
+
});
|
|
159
|
+
events = feed.events;
|
|
160
|
+
} catch {
|
|
161
|
+
events = null;
|
|
162
|
+
}
|
|
163
|
+
return buildEventBrowserData(events, url, { ...options, ...settings, view: state.view, month: state.month, category: state.category });
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/** Pure part of loadEventBrowser: `events` null means the feed failed. */
|
|
167
|
+
export async function buildEventBrowserData(events: PublicEvent[] | null, url: URL, options: EventPagesOptions = {}): Promise<EventBrowserData> {
|
|
168
|
+
const settings = resolve(url, options);
|
|
169
|
+
const { text, lang, dir } = await eventPageText(settings.locale);
|
|
170
|
+
const state = eventBrowserState(url.searchParams, monthOf(settings.now, settings.timeZone), options);
|
|
171
|
+
const all = events ?? [];
|
|
172
|
+
const visible = monthDateRange(state.month);
|
|
173
|
+
const inMonth = all.filter((event) => eventStartDate(event) <= visible.through && eventEndDate(event) >= visible.from);
|
|
174
|
+
const monthTitle = monthLabel(state.month, settings.locale);
|
|
175
|
+
const thisMonth = monthOf(settings.now, settings.timeZone);
|
|
176
|
+
const fullDate = new Intl.DateTimeFormat(settings.locale, { dateStyle: "full", timeZone: "UTC" });
|
|
177
|
+
const weekday = new Intl.DateTimeFormat(settings.locale, { weekday: "short", timeZone: "UTC" });
|
|
178
|
+
const day = new Intl.DateTimeFormat(settings.locale, { day: "numeric", timeZone: "UTC" });
|
|
179
|
+
const byDate = new Map<string, PublicEvent[]>();
|
|
180
|
+
for (const event of inMonth) {
|
|
181
|
+
const date = eventStartDate(event);
|
|
182
|
+
byDate.set(date, [...(byDate.get(date) ?? []), event]);
|
|
183
|
+
}
|
|
184
|
+
const byLocation = new Map<string, PublicEvent[]>();
|
|
185
|
+
for (const event of inMonth) {
|
|
186
|
+
const location = event.location.trim() || text.event.locationToConfirm;
|
|
187
|
+
byLocation.set(location, [...(byLocation.get(location) ?? []), event]);
|
|
188
|
+
}
|
|
189
|
+
const previousMonth = adjacentMonth(state, -1);
|
|
190
|
+
const nextMonth = adjacentMonth(state, 1);
|
|
191
|
+
return {
|
|
192
|
+
status: events ? 200 : 502,
|
|
193
|
+
pageTitle: text.pageTitle(monthTitle),
|
|
194
|
+
description: text.intro,
|
|
195
|
+
text,
|
|
196
|
+
lang,
|
|
197
|
+
dir,
|
|
198
|
+
locale: settings.locale,
|
|
199
|
+
origin: settings.origin,
|
|
200
|
+
pluginId: settings.pluginId,
|
|
201
|
+
basePath: settings.basePath,
|
|
202
|
+
linkTo: settings.linkTo,
|
|
203
|
+
state,
|
|
204
|
+
views: offeredViews(options).map((view) => ({ view, label: text.views[view], href: eventBrowserHref(state, { view }), current: view === state.view })),
|
|
205
|
+
monthTitle,
|
|
206
|
+
previous: { href: eventBrowserHref(state, { month: previousMonth }), label: text.month.previous(monthLabel(previousMonth, settings.locale)) },
|
|
207
|
+
next: { href: eventBrowserHref(state, { month: nextMonth }), label: text.month.next(monthLabel(nextMonth, settings.locale)) },
|
|
208
|
+
current: { href: eventBrowserHref(state, { month: thisMonth }), label: text.month.current, isCurrent: state.month === thisMonth },
|
|
209
|
+
clearHref: eventBrowserHref({ ...state, category: "" }),
|
|
210
|
+
categories: [...new Set(inMonth.flatMap((event) => event.categories))].sort((a, b) => a.localeCompare(b, settings.locale)),
|
|
211
|
+
events: inMonth,
|
|
212
|
+
weeks: state.view === "month" ? buildCalendar(state.month, settings.locale, all) : [],
|
|
213
|
+
weekdays: { short: weekdayHeadings(settings.locale), long: weekdayHeadings(settings.locale, "long") },
|
|
214
|
+
dateGroups: [...byDate].map(([date, grouped]) => {
|
|
215
|
+
const value = new Date(`${date}T12:00:00Z`);
|
|
216
|
+
return { date, id: `eventual-date-${date}`, label: fullDate.format(value), weekday: weekday.format(value), day: day.format(value), events: grouped };
|
|
217
|
+
}),
|
|
218
|
+
locationGroups: [...byLocation].map(([location, grouped]) => ({
|
|
219
|
+
location,
|
|
220
|
+
directionsUrl: grouped.map((event) => safeWebUrl(event.directionsUrl)).find(Boolean) ?? "",
|
|
221
|
+
events: grouped,
|
|
222
|
+
})),
|
|
223
|
+
today: settings.now.toISOString().slice(0, 10),
|
|
224
|
+
subscriptionUrl: calendarSubscriptionUrl(settings.origin, settings.pluginId, { locale: options.strict ? settings.contentLocale : undefined, category: state.category || undefined }),
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/** The address of an event's detail page (or its own public URL with `linkTo: "cms"`). */
|
|
229
|
+
export function eventHref(event: PublicEvent, data: Pick<EventBrowserData, "basePath" | "linkTo">): string {
|
|
230
|
+
return eventPageUrl(data.linkTo === "cms" ? event : { ...event, publicUrl: undefined }, data.basePath);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/** The detail page: `id` is the route parameter (an event's slug or ID). */
|
|
234
|
+
export async function loadEventDetail(url: URL, id: string | undefined, options: EventPagesOptions = {}): Promise<EventDetailData> {
|
|
235
|
+
const settings = resolve(url, options);
|
|
236
|
+
const range = eventRange(url.searchParams, settings.now);
|
|
237
|
+
if (!range) return buildEventDetailData([], undefined, url, options);
|
|
238
|
+
try {
|
|
239
|
+
const feed = await fetchPublicFeed(settings.origin, range.from, range.through, "", {
|
|
240
|
+
locale: settings.contentLocale,
|
|
241
|
+
strict: options.strict ?? false,
|
|
242
|
+
publicUrls: false,
|
|
243
|
+
pluginId: settings.pluginId,
|
|
244
|
+
});
|
|
245
|
+
return buildEventDetailData(feed.events, id, url, options);
|
|
246
|
+
} catch {
|
|
247
|
+
return buildEventDetailData(null, id, url, options);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/** The content entry behind a feed event (a recurring date's ID ends in `#<date>`): the `eventId` for RsvpForm and TicketCheckout. */
|
|
252
|
+
export function eventContentId(event: PublicEvent): string {
|
|
253
|
+
return event.id.split("#")[0] ?? event.id;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/** The event's start as an ISO instant: the `occurrenceStart` for RsvpForm and TicketCheckout. */
|
|
257
|
+
export function occurrenceStart(event: PublicEvent): string {
|
|
258
|
+
const time = Date.parse(event.start);
|
|
259
|
+
return Number.isNaN(time) ? "" : new Date(time).toISOString();
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/** Finds the event by ID, slug or series ID, preferring the date the address names. */
|
|
263
|
+
export function findEvent(events: PublicEvent[], param: string, from?: string): PublicEvent | undefined {
|
|
264
|
+
if (!param) return undefined;
|
|
265
|
+
const matches = events.filter((event) => event.id === param || event.slug === param || event.id.split("#")[0] === param);
|
|
266
|
+
return matches.find((event) => event.id === param)
|
|
267
|
+
?? matches.find((event) => from && eventStartDate(event) === from)
|
|
268
|
+
?? matches[0];
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/** Pure part of loadEventDetail: `events` null means the feed failed. */
|
|
272
|
+
export async function buildEventDetailData(events: PublicEvent[] | null, id: string | undefined, url: URL, options: EventPagesOptions = {}): Promise<EventDetailData> {
|
|
273
|
+
const settings = resolve(url, options);
|
|
274
|
+
const { text, lang, dir } = await eventPageText(settings.locale);
|
|
275
|
+
const base = { text, lang, dir, locale: settings.locale, origin: settings.origin, pluginId: settings.pluginId, backHref: settings.basePath };
|
|
276
|
+
if (!events) return { ...base, status: 502, pageTitle: text.notice.unavailable, description: text.notice.unavailableDetail };
|
|
277
|
+
const event = findEvent(events, decodeRouteParam(id), url.searchParams.get("from") ?? undefined);
|
|
278
|
+
if (!event) return { ...base, status: 404, pageTitle: text.event.details, description: text.notice.notFound };
|
|
279
|
+
const sameDay = eventStartDate(event) === eventEndDate(event);
|
|
280
|
+
const start = displayDate(event.start, settings.locale, event.timezone, event.allDay, "full");
|
|
281
|
+
const end = displayDate(event.end, settings.locale, event.timezone, event.allDay, "full");
|
|
282
|
+
return {
|
|
283
|
+
...base,
|
|
284
|
+
status: 200,
|
|
285
|
+
pageTitle: event.title,
|
|
286
|
+
description: descriptionExcerpt(event.description, 160),
|
|
287
|
+
event,
|
|
288
|
+
jsonLd: serializeJsonLd(eventToJsonLd(event, { siteUrl: settings.origin })),
|
|
289
|
+
dateText: sameDay ? start : `${start} – ${end}`,
|
|
290
|
+
timeText: event.allDay ? text.event.allDay : eventTimeRange(event, settings.locale),
|
|
291
|
+
imageUrl: safeImageUrl(event.imageMedia?.src || event.imageUrl, settings.origin),
|
|
292
|
+
websiteUrl: safeWebUrl(event.externalUrl) || undefined,
|
|
293
|
+
directionsUrl: safeWebUrl(event.directionsUrl) || undefined,
|
|
294
|
+
onlineUrl: event.locationType === "virtual" || event.locationType === "hybrid" ? safeWebUrl(event.virtualUrl ?? "") || undefined : undefined,
|
|
295
|
+
descriptionHtml: descriptionHtml(event.descriptionBlocks, event.description, { headingBase: 2, newTabText: text.newTab }),
|
|
296
|
+
calendarLinks: absoluteCalendarLinks(event.calendarLinks, settings.origin),
|
|
297
|
+
subscriptionUrl: calendarSubscriptionUrl(settings.origin, settings.pluginId),
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
export { EVENT_VIEWS };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Addresses the event pages show: calendar subscription, the feed's per-event links made absolute,
|
|
3
|
+
* and safe image URLs. Every address that reaches the plugin carries the installed plugin ID
|
|
4
|
+
* (`eventual` for a config install, `r_…` for a Registry install).
|
|
5
|
+
*/
|
|
6
|
+
import type { CalendarLinks } from "../event-details";
|
|
7
|
+
|
|
8
|
+
/** `webcal://…/_emdash/api/plugins/<pluginId>/calendar`, optionally for one language or category. */
|
|
9
|
+
export function calendarSubscriptionUrl(origin: string | URL, pluginId = "eventual", options: { locale?: string; category?: string } = {}): string {
|
|
10
|
+
try {
|
|
11
|
+
const url = new URL(`/_emdash/api/plugins/${encodeURIComponent(pluginId)}/calendar`, origin);
|
|
12
|
+
if (options.locale) url.searchParams.set("locale", options.locale);
|
|
13
|
+
if (options.category) url.searchParams.set("category", options.category);
|
|
14
|
+
return url.href.replace(/^https?:/i, "webcal:");
|
|
15
|
+
} catch {
|
|
16
|
+
return "";
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The feed's calendar links with the `.ics` download made absolute against the API origin
|
|
22
|
+
* (the feed gives a site-relative path, which breaks when pages and API are on different hosts).
|
|
23
|
+
*/
|
|
24
|
+
export function absoluteCalendarLinks(links: CalendarLinks | undefined, origin: string | URL): CalendarLinks | undefined {
|
|
25
|
+
if (!links) return undefined;
|
|
26
|
+
let ics = links.ics;
|
|
27
|
+
try {
|
|
28
|
+
ics = new URL(links.ics, origin).href;
|
|
29
|
+
} catch {}
|
|
30
|
+
return { ...links, ics };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** https images anywhere; http only from the API origin itself (local development). */
|
|
34
|
+
export function safeImageUrl(value: string | undefined, origin: string | URL): string {
|
|
35
|
+
if (!value || !value.trim()) return "";
|
|
36
|
+
try {
|
|
37
|
+
const url = new URL(value, origin);
|
|
38
|
+
const site = new URL(origin);
|
|
39
|
+
if (url.protocol === "https:") return url.href;
|
|
40
|
+
if (url.protocol === "http:" && site.protocol === "http:" && url.origin === site.origin) return url.href;
|
|
41
|
+
return "";
|
|
42
|
+
} catch {
|
|
43
|
+
return "";
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function decodeRouteParam(value: string | undefined): string {
|
|
48
|
+
if (!value) return "";
|
|
49
|
+
try {
|
|
50
|
+
return decodeURIComponent(value);
|
|
51
|
+
} catch {
|
|
52
|
+
return "";
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { PublicEvent } from "../../feed";
|
|
3
|
+
import type { EventBrowserData } from "../index";
|
|
4
|
+
import { eventHref } from "../index";
|
|
5
|
+
import { eventStartDate, eventTimeParts, eventTimeRange } from "../grid";
|
|
6
|
+
import { safeImageUrl } from "../links";
|
|
7
|
+
import { safeWebUrl } from "../../event-details";
|
|
8
|
+
import { descriptionExcerpt } from "../description";
|
|
9
|
+
import DateTile from "./DateTile.astro";
|
|
10
|
+
import Icon from "./Icon.astro";
|
|
11
|
+
import StatusBadge from "./StatusBadge.astro";
|
|
12
|
+
|
|
13
|
+
interface Props {
|
|
14
|
+
event: PublicEvent;
|
|
15
|
+
data: EventBrowserData;
|
|
16
|
+
level: number;
|
|
17
|
+
/** Show the date (off inside a list already grouped by date). */
|
|
18
|
+
showDate?: boolean;
|
|
19
|
+
/** A row in a grouped list: time column, title and place. */
|
|
20
|
+
compact?: boolean;
|
|
21
|
+
/** Show the place (off inside a list already grouped by place). */
|
|
22
|
+
showPlace?: boolean;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const { event, data, level, showDate = true, compact = false, showPlace = true } = Astro.props;
|
|
26
|
+
const { text, locale } = data;
|
|
27
|
+
const Heading = `h${Math.min(6, level)}` as "h3";
|
|
28
|
+
const dateKey = eventStartDate(event);
|
|
29
|
+
const imageUrl = compact ? "" : safeImageUrl(event.imageMedia?.src || event.imageUrl, data.origin);
|
|
30
|
+
const directionsUrl = safeWebUrl(event.directionsUrl);
|
|
31
|
+
const contentLang = event.locale && event.locale.split("-")[0] !== data.lang.split("-")[0] ? event.locale : undefined;
|
|
32
|
+
const time = eventTimeParts(event, locale);
|
|
33
|
+
const shortDate = new Intl.DateTimeFormat(locale, { weekday: "short", day: "numeric", month: "short", timeZone: "UTC" }).format(new Date(`${dateKey}T12:00:00Z`));
|
|
34
|
+
const fullDate = new Intl.DateTimeFormat(locale, { dateStyle: "full", timeZone: "UTC" }).format(new Date(`${dateKey}T12:00:00Z`));
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
{compact ? (
|
|
38
|
+
<article class:list={["eventual-row", event.status === "cancelled" && "eventual-is-cancelled"]} lang={contentLang}>
|
|
39
|
+
<p class="eventual-row__when">
|
|
40
|
+
{showDate && <time class="eventual-row__date" datetime={dateKey}><span aria-hidden="true">{shortDate}</span><span class="eventual-sr-only">{fullDate}</span></time>}
|
|
41
|
+
{time ? (
|
|
42
|
+
<>
|
|
43
|
+
<span class="eventual-row__start">{time.start}</span>
|
|
44
|
+
<span class="eventual-row__end">– {time.end} {time.zone}</span>
|
|
45
|
+
</>
|
|
46
|
+
) : <span class="eventual-row__start">{text.event.allDay}</span>}
|
|
47
|
+
</p>
|
|
48
|
+
<div class="eventual-row__body">
|
|
49
|
+
<Heading class="eventual-row__title"><a class="eventual-cover" href={eventHref(event, data)}>{event.title}</a> <StatusBadge event={event} text={text} locale={locale} /></Heading>
|
|
50
|
+
{showPlace && event.location && (
|
|
51
|
+
<p class="eventual-meta">
|
|
52
|
+
<Icon name="pin" /><span>{event.location}{directionsUrl && <> · <a class="eventual-raise" href={directionsUrl} target="_blank" rel="noopener noreferrer">{text.event.directions}<span class="eventual-sr-only"> {text.newTab}</span></a></>}</span>
|
|
53
|
+
</p>
|
|
54
|
+
)}
|
|
55
|
+
</div>
|
|
56
|
+
</article>
|
|
57
|
+
) : (
|
|
58
|
+
<article class:list={["eventual-agenda", imageUrl && "eventual-agenda--media", event.status === "cancelled" && "eventual-is-cancelled"]} lang={contentLang}>
|
|
59
|
+
{showDate && <DateTile date={dateKey} locale={locale} class="eventual-agenda__date" />}
|
|
60
|
+
<div class="eventual-agenda__body">
|
|
61
|
+
<Heading class="eventual-agenda__title"><a class="eventual-cover" href={eventHref(event, data)}>{event.title}</a> <StatusBadge event={event} text={text} locale={locale} /></Heading>
|
|
62
|
+
<div class="eventual-meta-group">
|
|
63
|
+
<p class="eventual-meta"><Icon name="clock" /><span>{event.allDay ? text.event.allDay : eventTimeRange(event, locale)}</span></p>
|
|
64
|
+
{event.location && (
|
|
65
|
+
<p class="eventual-meta">
|
|
66
|
+
<Icon name="pin" /><span>{event.location}{directionsUrl && <> · <a class="eventual-raise" href={directionsUrl} target="_blank" rel="noopener noreferrer">{text.event.directions}<span class="eventual-sr-only"> {text.newTab}</span></a></>}</span>
|
|
67
|
+
</p>
|
|
68
|
+
)}
|
|
69
|
+
</div>
|
|
70
|
+
{event.description && <p class="eventual-agenda__excerpt">{descriptionExcerpt(event.description)}</p>}
|
|
71
|
+
</div>
|
|
72
|
+
{imageUrl && <div class="eventual-agenda__media"><img src={imageUrl} alt="" width={event.imageMedia?.width} height={event.imageMedia?.height} loading="lazy" decoding="async" /></div>}
|
|
73
|
+
</article>
|
|
74
|
+
)}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
---
|
|
2
|
+
/** A calendar date shown as a tile (weekday, day number, month). The visible parts are hidden from
|
|
3
|
+
screen readers; the full date is read instead unless `labelled` is false (a heading says it). */
|
|
4
|
+
interface Props {
|
|
5
|
+
/** YYYY-MM-DD */
|
|
6
|
+
date: string;
|
|
7
|
+
locale: string;
|
|
8
|
+
/** "stack": weekday, day, month. "short": day over month. */
|
|
9
|
+
layout?: "stack" | "short";
|
|
10
|
+
labelled?: boolean;
|
|
11
|
+
class?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const { date, locale, layout = "stack", labelled = true, class: className } = Astro.props;
|
|
15
|
+
const value = new Date(`${date}T12:00:00Z`);
|
|
16
|
+
const format = (options: Intl.DateTimeFormatOptions) => new Intl.DateTimeFormat(locale, { ...options, timeZone: "UTC" }).format(value);
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
<time class:list={["eventual-tile", `eventual-tile--${layout}`, className]} datetime={date}>
|
|
20
|
+
{layout === "stack" && <span class="eventual-tile__weekday" aria-hidden="true">{format({ weekday: "short" })}</span>}
|
|
21
|
+
<span class="eventual-tile__day" aria-hidden="true">{format({ day: "numeric" })}</span>
|
|
22
|
+
<span class="eventual-tile__month" aria-hidden="true">{format({ month: "short" })}</span>
|
|
23
|
+
{labelled && <span class="eventual-sr-only">{format({ dateStyle: "full" })}</span>}
|
|
24
|
+
</time>
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { PublicEvent } from "../../feed";
|
|
3
|
+
import type { EventBrowserData } from "../index";
|
|
4
|
+
import { eventHref } from "../index";
|
|
5
|
+
import { displayDate, eventEndDate, eventStartDate, eventTimeRange } from "../grid";
|
|
6
|
+
import { safeImageUrl } from "../links";
|
|
7
|
+
import { safeWebUrl } from "../../event-details";
|
|
8
|
+
import { descriptionExcerpt } from "../description";
|
|
9
|
+
import DateTile from "./DateTile.astro";
|
|
10
|
+
import Icon from "./Icon.astro";
|
|
11
|
+
import StatusBadge from "./StatusBadge.astro";
|
|
12
|
+
|
|
13
|
+
interface Props {
|
|
14
|
+
event: PublicEvent;
|
|
15
|
+
data: EventBrowserData;
|
|
16
|
+
level: number;
|
|
17
|
+
/** "grid": image on top, date tile beside the title. "timeline": text beside a thumbnail, no date (the timeline shows it). */
|
|
18
|
+
variant?: "grid" | "timeline";
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const { event, data, level, variant = "grid" } = Astro.props;
|
|
22
|
+
const { text, locale } = data;
|
|
23
|
+
const Heading = `h${Math.min(6, level)}` as "h3";
|
|
24
|
+
const href = eventHref(event, data);
|
|
25
|
+
const imageUrl = safeImageUrl(event.imageMedia?.src || event.imageUrl, data.origin);
|
|
26
|
+
const directionsUrl = safeWebUrl(event.directionsUrl);
|
|
27
|
+
const startDate = eventStartDate(event);
|
|
28
|
+
const sameDay = startDate === eventEndDate(event);
|
|
29
|
+
const time = event.allDay ? (sameDay ? text.event.allDay : "") : eventTimeRange(event, locale);
|
|
30
|
+
const contentLang = event.locale && event.locale.split("-")[0] !== data.lang.split("-")[0] ? event.locale : undefined;
|
|
31
|
+
const grid = variant === "grid";
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
<article class:list={["eventual-card", `eventual-card--${variant}`, imageUrl && "eventual-card--media", event.status === "cancelled" && "eventual-is-cancelled"]} lang={contentLang}>
|
|
35
|
+
{imageUrl && <div class="eventual-card__media"><img src={imageUrl} alt="" width={event.imageMedia?.width} height={event.imageMedia?.height} loading="lazy" decoding="async" /></div>}
|
|
36
|
+
<div class="eventual-card__body">
|
|
37
|
+
<div class="eventual-card__head">
|
|
38
|
+
{grid && <DateTile date={startDate} locale={locale} layout="short" class="eventual-card__tile" />}
|
|
39
|
+
<Heading class="eventual-card__title"><a class="eventual-cover" href={href}>{event.title}</a> <StatusBadge event={event} text={text} locale={locale} /></Heading>
|
|
40
|
+
</div>
|
|
41
|
+
<div class="eventual-meta-group">
|
|
42
|
+
<p class="eventual-meta">
|
|
43
|
+
<Icon name="clock" />
|
|
44
|
+
<span>
|
|
45
|
+
{!sameDay && <><time datetime={event.start}>{displayDate(event.start, locale, event.timezone, event.allDay)}</time> – <time datetime={event.end}>{displayDate(event.end, locale, event.timezone, event.allDay)}</time>{time && " · "}</>}
|
|
46
|
+
{time}
|
|
47
|
+
</span>
|
|
48
|
+
</p>
|
|
49
|
+
{event.location && (
|
|
50
|
+
<p class="eventual-meta">
|
|
51
|
+
<Icon name="pin" /><span>{event.location}{directionsUrl && <> · <a class="eventual-raise" href={directionsUrl} target="_blank" rel="noopener noreferrer">{text.event.directions}<span class="eventual-sr-only"> {text.newTab}</span></a></>}</span>
|
|
52
|
+
</p>
|
|
53
|
+
)}
|
|
54
|
+
{grid && event.organizer && <p class="eventual-meta"><Icon name="user" /><span>{text.event.organizer(event.organizer)}</span></p>}
|
|
55
|
+
</div>
|
|
56
|
+
{event.description && <p class="eventual-card__excerpt">{descriptionExcerpt(event.description)}</p>}
|
|
57
|
+
{grid && event.categories.length > 0 && (
|
|
58
|
+
<ul class="eventual-tags" aria-label={text.event.categories}>
|
|
59
|
+
{event.categories.map((category) => <li>{category}</li>)}
|
|
60
|
+
</ul>
|
|
61
|
+
)}
|
|
62
|
+
</div>
|
|
63
|
+
</article>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
---
|
|
2
|
+
/** One line-icon set for the event pages: 24px grid, 1.75 stroke, round caps. Always decorative. */
|
|
3
|
+
interface Props {
|
|
4
|
+
name: "clock" | "pin" | "calendar" | "calendar-plus" | "external" | "chevron-left" | "chevron-right" | "chevron-down" | "user" | "globe" | "tag" | "rss";
|
|
5
|
+
class?: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const { name, class: className } = Astro.props;
|
|
9
|
+
const paths: Record<Props["name"], string> = {
|
|
10
|
+
clock: '<circle cx="12" cy="12" r="9"/><path d="M12 7v5l3 2"/>',
|
|
11
|
+
pin: '<path d="M12 21s7-6.1 7-11.5A7 7 0 0 0 5 9.5C5 14.9 12 21 12 21z"/><circle cx="12" cy="9.5" r="2.5"/>',
|
|
12
|
+
calendar: '<rect x="3.5" y="5" width="17" height="15.5" rx="2.5"/><path d="M3.5 10h17M8 3v4M16 3v4"/>',
|
|
13
|
+
"calendar-plus": '<rect x="3.5" y="5" width="17" height="15.5" rx="2.5"/><path d="M3.5 10h17M8 3v4M16 3v4M12 13v5M9.5 15.5h5"/>',
|
|
14
|
+
external: '<path d="M14 4h6v6M20 4l-9 9M18 14v4.5a1.5 1.5 0 0 1-1.5 1.5h-11A1.5 1.5 0 0 1 4 18.5v-11A1.5 1.5 0 0 1 5.5 6H10"/>',
|
|
15
|
+
"chevron-left": '<path d="m15 18-6-6 6-6"/>',
|
|
16
|
+
"chevron-right": '<path d="m9 18 6-6-6-6"/>',
|
|
17
|
+
"chevron-down": '<path d="m6 9 6 6 6-6"/>',
|
|
18
|
+
user: '<circle cx="12" cy="8" r="3.5"/><path d="M5 20a7 7 0 0 1 14 0"/>',
|
|
19
|
+
globe: '<circle cx="12" cy="12" r="9"/><path d="M3 12h18M12 3a14 14 0 0 1 0 18M12 3a14 14 0 0 0 0 18"/>',
|
|
20
|
+
tag: '<path d="M3.5 12.6V4.5a1 1 0 0 1 1-1h8.1l8 8a1.5 1.5 0 0 1 0 2.1l-7 7a1.5 1.5 0 0 1-2.1 0z"/><circle cx="8" cy="8" r="1.25"/>',
|
|
21
|
+
rss: '<path d="M5 11a8 8 0 0 1 8 8M5 5a14 14 0 0 1 14 14"/><circle cx="6" cy="18" r="1.25"/>',
|
|
22
|
+
};
|
|
23
|
+
const flip = name === "chevron-left" || name === "chevron-right";
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
<svg class:list={["eventual-icon", flip && "eventual-flip", className]} viewBox="0 0 24 24" aria-hidden="true" focusable="false" set:html={paths[name]} />
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { PublicEvent } from "../../feed";
|
|
3
|
+
import type { EventPageText } from "../i18n";
|
|
4
|
+
import { displayDate } from "../grid";
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
event: PublicEvent;
|
|
8
|
+
text: EventPageText;
|
|
9
|
+
locale: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const { event, text, locale } = Astro.props;
|
|
13
|
+
const status = event.status === "cancelled" || event.status === "postponed" || event.status === "rescheduled" ? event.status : null;
|
|
14
|
+
const previous = status === "rescheduled" && event.previousStartDate
|
|
15
|
+
? text.event.originally(displayDate(event.previousStartDate, locale, event.timezone, event.allDay))
|
|
16
|
+
: "";
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
{status && (
|
|
20
|
+
<span class={`eventual-badge eventual-badge--${status}`}>
|
|
21
|
+
{text.status[status]}{previous && <span class="eventual-badge__detail"> · {previous}</span>}
|
|
22
|
+
</span>
|
|
23
|
+
)}
|