From e6cfa74de7d063e7247c4c2ee8f787ab1793a063 Mon Sep 17 00:00:00 2001 From: Florian <45694132+flo-bit@users.noreply.github.com> Date: Tue, 5 May 2026 00:48:50 +0200 Subject: [PATCH] add event creation and event view pages --- src/lib/cards/social/EventCard/index.ts | 51 +++++---------- .../UpcomingEventsCard.svelte | 26 ++------ src/lib/embed/AtmoEmbed.svelte | 37 ++++++++++- .../event/create/+page.server.ts | 11 ++++ .../[[actor=actor]]/event/create/+page.svelte | 40 ++++++++++++ .../event/r/[rkey]/+page.server.ts | 11 ++++ .../event/r/[rkey]/+page.svelte | 63 +++++++++++++++++++ 7 files changed, 182 insertions(+), 57 deletions(-) create mode 100644 src/routes/[[actor=actor]]/event/create/+page.server.ts create mode 100644 src/routes/[[actor=actor]]/event/create/+page.svelte create mode 100644 src/routes/[[actor=actor]]/event/r/[rkey]/+page.server.ts create mode 100644 src/routes/[[actor=actor]]/event/r/[rkey]/+page.svelte diff --git a/src/lib/cards/social/EventCard/index.ts b/src/lib/cards/social/EventCard/index.ts index 3df1db7..caba18d 100644 --- a/src/lib/cards/social/EventCard/index.ts +++ b/src/lib/cards/social/EventCard/index.ts @@ -1,8 +1,6 @@ -import { parseUri, getRecord } from '$lib/atproto'; import type { CardDefinition } from '../../types'; import CreateEventCardModal from './CreateEventCardModal.svelte'; import EventCard from './EventCard.svelte'; -import type { Did } from '@atcute/lexicons'; const EVENT_COLLECTION = 'community.lexicon.calendar.event'; @@ -58,35 +56,20 @@ export const EventCardDefinition = { card.mobileH = 6; }, - loadData: async (items) => { - const eventDataMap: Record = {}; - - for (const item of items) { - const uri = item.cardData?.uri; - if (!uri) continue; - - const parsedUri = parseUri(uri); - if (!parsedUri || !parsedUri.rkey || !parsedUri.repo) continue; - - try { - const record = await getRecord({ - did: parsedUri.repo as Did, - collection: EVENT_COLLECTION, - rkey: parsedUri.rkey - }); - - if (record?.value) { - eventDataMap[item.id] = record.value as EventData; - } - } catch (error) { - console.error('Failed to fetch event data:', error); - } + onUrlHandler: (url, item) => { + // Match atmo.rsvp URLs: https://atmo.rsvp/p/{didOrHandle}/e/{rkey} + const atmoMatch = url.match(/^https?:\/\/atmo\.rsvp\/p\/([^/]+)\/e\/([^/?#]+)/); + if (atmoMatch) { + const [, repo, rkey] = atmoMatch; + item.w = 4; + item.h = 4; + item.mobileW = 8; + item.mobileH = 6; + item.cardType = 'event'; + item.cardData.uri = `at://${repo}/${EVENT_COLLECTION}/${rkey}`; + return item; } - return eventDataMap; - }, - - onUrlHandler: (url, item) => { // Match smokesignal.events URLs: https://smokesignal.events/{did}/{rkey} const smokesignalMatch = url.match(/^https?:\/\/smokesignal\.events\/(did:[^/]+)\/([^/?#]+)/); if (smokesignalMatch) { @@ -100,17 +83,17 @@ export const EventCardDefinition = { return item; } - // Match AT URIs: at://{did}/community.lexicon.calendar.event/{rkey} - const atUriMatch = url.match(/^at:\/\/(did:[^/]+)\/([^/]+)\/([^/?#]+)/); + // Match AT URIs: at://{didOrHandle}/community.lexicon.calendar.event/{rkey} + const atUriMatch = url.match(/^at:\/\/([^/]+)\/([^/]+)\/([^/?#]+)/); if (atUriMatch) { - const [, did, collection, rkey] = atUriMatch; + const [, repo, collection, rkey] = atUriMatch; if (collection === EVENT_COLLECTION) { item.w = 4; item.h = 4; item.mobileW = 8; item.mobileH = 6; item.cardType = 'event'; - item.cardData.uri = `at://${did}/${collection}/${rkey}`; + item.cardData.uri = `at://${repo}/${collection}/${rkey}`; return item; } } @@ -122,7 +105,7 @@ export const EventCardDefinition = { name: 'Event', - keywords: ['calendar', 'meetup', 'schedule', 'date', 'rsvp', 'smokesignal'], + keywords: ['calendar', 'meetup', 'schedule', 'date', 'rsvp', 'atmo', 'smokesignal'], groups: ['Social'], icon: `` } as CardDefinition & { type: 'event' }; diff --git a/src/lib/cards/social/UpcomingEventsCard/UpcomingEventsCard.svelte b/src/lib/cards/social/UpcomingEventsCard/UpcomingEventsCard.svelte index 3e49506..cd61ff2 100644 --- a/src/lib/cards/social/UpcomingEventsCard/UpcomingEventsCard.svelte +++ b/src/lib/cards/social/UpcomingEventsCard/UpcomingEventsCard.svelte @@ -1,13 +1,12 @@ + + + Create event · Blento + + +
+ +
diff --git a/src/routes/[[actor=actor]]/event/r/[rkey]/+page.server.ts b/src/routes/[[actor=actor]]/event/r/[rkey]/+page.server.ts new file mode 100644 index 0000000..58d5ff2 --- /dev/null +++ b/src/routes/[[actor=actor]]/event/r/[rkey]/+page.server.ts @@ -0,0 +1,11 @@ +import { error } from '@sveltejs/kit'; +import { getActor } from '$lib/actor'; + +export async function load({ params, request, platform }) { + if (!params.rkey) error(404, 'Event URL missing rkey'); + + const actor = await getActor({ request, paramActor: params.actor, platform }); + if (!actor) error(404, 'Could not resolve actor'); + + return { actor, rkey: params.rkey }; +} diff --git a/src/routes/[[actor=actor]]/event/r/[rkey]/+page.svelte b/src/routes/[[actor=actor]]/event/r/[rkey]/+page.svelte new file mode 100644 index 0000000..789c1a1 --- /dev/null +++ b/src/routes/[[actor=actor]]/event/r/[rkey]/+page.svelte @@ -0,0 +1,63 @@ + + + + Event · Blento + + + + + + + +
+ +
-- 2.51.2