package web import ( "strings" "gitea.d-ma.be/mathias/tapir/internal/adapters/store" ) // Layout is the shared HTML shell. HTMX drives the progressive interactions // (filters, action toggles); every interaction also degrades to a plain form // POST/GET when JS is absent (ui-spec.md §4). templ Layout(title string) { { title } @templ.Raw(styleTag)
Tapir
{ children... }
} // flashBanner renders a one-shot notification for a flash code (connect success/ // failure, disconnect, delete, registration). An empty or unknown code renders // nothing, so it is safe to drop into any page unconditionally. Reused across the // app — not per-page ad-hoc markup. templ flashBanner(code string) { if f, ok := flashFor(code); ok {
{ f.Message }
} } // ListPage is the full summary list with the filter form. HTMX swaps only the // #summary-list region; a non-HTMX request renders the whole page. flash carries // a one-shot notification (e.g. "connected", "registered") surfaced on arrival // after a POST→redirect. templ ListPage(rows []store.SummaryRow, f Filter, flash string) { @Layout("Tapir — Summaries") { @flashBanner(flash) @filterForm(f)
@summaryList(rows)
} } templ filterForm(f Filter) {
filtering…
} // summaryList is the swappable list fragment: one card per summary (title link, // channel · date meta, provider chip, fallback badge, action state). Cards // reflow to a single column on mobile; an empty list shows a friendly first-run // state instead of a blank table. templ summaryList(rows []store.SummaryRow) { if len(rows) == 0 {
No summaries yet Summaries appear here as your subscriptions are processed — run tapir run to fetch and summarize new videos.
} else { } } // DetailPage is the full summary view: text, highlights, takeaways, metadata, // and the action button group. templ DetailPage(r store.SummaryRow) { @Layout("Tapir — " + displayTitle(r)) {

{ displayTitle(r) }

if detailMeta(r) != "" { { detailMeta(r) } } if r.FallbackUsed { fallback }

if url, ok := embedURL(r.ProviderVideoID); ok {
} if r.URL != "" {

watch on source ↗

} @ActionButtons(r.VideoID, actionSet(r.Actions))

Summary

{ r.Summary }

if len(r.Highlights) > 0 {

Highlights

} if len(r.Takeaways) > 0 {

Takeaways

}
} } // RegisterPage is the explicit registration step (ADR-012): an authenticated Dex // subject with no tapir user picks a display name and accepts the terms to create // their account. errMsg, when set, reports a validation problem on the prior POST. templ RegisterPage(email, errMsg string) { @Layout("Tapir — Register") {

Complete your registration

if email != "" {

Signed in as { email }.

}

Choose a display name to finish setting up your Tapir account.

if errMsg != "" { }
} } // AccountPage is the account-management view: the registered display name and // signed-in email, the user's connected video accounts (each with a Disconnect // control), a Connect-YouTube link when none is connected, and the delete-account // danger zone. flash surfaces a one-shot notification (disconnect/connect). templ AccountPage(displayName, email string, conns []store.Connection, flash string) { @Layout("Tapir — Account") { @flashBanner(flash)

Account

Display name
{ displayNameOr(displayName) }
if email != "" {
Signed in as
{ email }
}

Connected accounts

if len(conns) == 0 {

No connected video accounts yet.

} else { } if !hasYouTube(conns) {

Connect YouTube

}

Delete account

Permanently remove your Tapir account and all of its data — summaries, watch/skip/save actions, and connected accounts. This cannot be undone.

Delete account…

This permanently deletes your account and all data. Are you sure?

} } // ActionButtons is the toggle group fragment returned by POST /v/{id}/action. // Each button submits its verb; HTMX swaps this element in place (outerHTML), // and without JS the form POSTs and the handler redirects back to the detail // page. active marks the verbs currently set for (user, video). templ ActionButtons(videoID string, active map[string]bool) {
for _, v := range actionVerbs { }
}