Something went wrong. Try again.
A single hub to check all of my ATProto activity
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144// at.diego.codes — one chronological timeline of my own ATProto records.// Every service contributes dated "events" that intertwine into a single// reverse-chronological stream, each tagged with a verb. No auth, no writes.
import "./style.css";import { applyVerbColors, COL } from "./config";import { listRecords, resolveBeaconPhotos, resolveWinePhotos } from "./atproto";import { notNull } from "./format";import { buildCovers, fromBeacons, fromCulture, fromDocuments, fromEducation, fromGalleries, fromIntervalMilestones, fromPositions, fromPosts, fromPublications, fromWinesky,} from "./sources";import { renderLoading, renderProfile, renderTimeline } from "./timeline";import { setupContextBar } from "./contextBar";import { setupRail } from "./rail";import { setupFilter } from "./filter";import type { SourceKey } from "./config";import type { ActorProfile, BeaconRecord, BskyPost, GrainGallery, GrainGalleryItem, GrainPhoto, PopfeedItem, SifaEducation, SifaPosition, SifaPublication, StandardDocument, StandardPublication, TimelineEvent, WineskyReview,} from "./types";
// Stamp every event in a source group with the service it came from, so the// filter menu can select by service (kept out of the source builders, which// stay service-agnostic).const tag = (list: (TimelineEvent | null)[], source: SourceKey): (TimelineEvent | null)[] => list.map((e) => (e ? { ...e, source } : e));
async function main(): Promise<void> { applyVerbColors(); // seed --verb-* CSS vars (so the visiting picker can recolour live) renderLoading(); // shimmer placeholders until every collection has streamed in
const [ profile, documents, galleries, galleryItems, photos, reviews, notes, beacons, positions, education, publications, sitePubs, posts, wines, ] = await Promise.all([ listRecords<ActorProfile>(COL.profile, 1), listRecords<StandardDocument>(COL.document), listRecords<GrainGallery>(COL.gallery), listRecords<GrainGalleryItem>(COL.galleryItem), listRecords<GrainPhoto>(COL.photo), listRecords<PopfeedItem>(COL.review), listRecords<PopfeedItem>(COL.note), listRecords<BeaconRecord>(COL.beacon), listRecords<SifaPosition>(COL.sifaPosition), listRecords<SifaEducation>(COL.sifaEducation), listRecords<SifaPublication>(COL.sifaPublication), listRecords<StandardPublication>(COL.publication), listRecords<BskyPost>(COL.post), listRecords<WineskyReview>(COL.wine), ]);
const profileValue = profile[0]?.value; renderProfile(profileValue);
const covers = buildCovers(galleries, galleryItems, photos); const beaconPhotos = await resolveBeaconPhotos(beacons); const winePhotos = await resolveWinePhotos(wines); const pubUrlByUri: Record<string, string | undefined> = Object.fromEntries(sitePubs.map((p) => [p.uri, p.value.url]));
// Bluesky posts that other apps auto-created (BeaconBits check-ins, Winesky // reviews) — excluded from "posting" so they don't duplicate those entries. const linkedPostUris = new Set<string>( [ ...beacons.map((b) => b.value.post?.uri), ...wines.map((w) => w.value.post?.atUri), ].filter(notNull), );
const intervals = [...fromPositions(positions), ...fromEducation(education)];
const events: TimelineEvent[] = [ ...tag(fromDocuments(documents, pubUrlByUri), "blog"), ...tag(fromGalleries(galleries, covers), "grain"), ...tag(fromCulture(reviews), "popfeed"), ...tag(fromCulture(notes), "popfeed"), ...tag(fromBeacons(beacons, beaconPhotos), "beaconbits"), ...tag(fromPosts(posts, linkedPostUris), "bluesky"), ...tag(fromWinesky(wines, winePhotos), "winesky"), ...tag(fromPublications(publications), "sifa"), ...tag(fromIntervalMilestones(intervals), "sifa"), ] .filter(notNull) .sort((a, b) => b.date.getTime() - a.date.getTime());
const name = (profileValue?.displayName || "Diego").split(" ")[0]; const empty = document.querySelector<HTMLElement>("#empty"); const toolbar = document.querySelector<HTMLElement>("#toolbar"); const timeline = document.querySelector<HTMLElement>("#timeline");
// Pin the search/filter toggle to the vertical centre of the current-year // separator (the topmost one), so it sits on that line over the thumbnail // column. Falls back to the top of the stream when a filter leaves no years. const positionToolbar = (): void => { if (!toolbar || !timeline) return; const toggleH = toolbar.querySelector<HTMLElement>("#toolbar-toggle")?.offsetHeight ?? 34; const firstYear = timeline.querySelector<HTMLElement>(".year-sep"); const center = firstYear ? firstYear.offsetTop + firstYear.offsetHeight / 2 : timeline.offsetTop + toggleH / 2; toolbar.style.top = `${center - toggleH / 2}px`; toolbar.style.visibility = "visible"; };
// Re-render the whole stream from a (filtered) list, rebuilding the rail and // context bar off the fresh DOM. Tearing the previous ones down first keeps // their scroll/resize listeners from piling up across filter changes. let teardownRail = (): void => {}; let teardownCtx = (): void => {}; const render = (list: TimelineEvent[]): void => { renderTimeline(list); teardownRail(); teardownCtx(); teardownRail = setupRail(); teardownCtx = setupContextBar(intervals, name); if (empty) empty.hidden = list.length > 0; positionToolbar(); };
// Keep the toggle glued to the year separator. Its offset shifts not only on // resize/avatar-load but whenever the sticky context bar expands or collapses // (it reserves flow space), so recompute on scroll and when that bar finishes // its height transition too — otherwise the button drifts off the separator. let repositionQueued = false; const reposition = (): void => { if (repositionQueued) return; repositionQueued = true; requestAnimationFrame(() => { repositionQueued = false; positionToolbar(); }); }; window.addEventListener("scroll", reposition, { passive: true }); window.addEventListener("resize", positionToolbar); window.addEventListener("load", positionToolbar); document.querySelector("#contextbar")?.addEventListener("transitionend", (e) => { if ((e as TransitionEvent).propertyName === "max-height") positionToolbar(); });
setupFilter(events, render); // paints the unfiltered stream on setup}
main().catch(console.error);