tracker
All repositories: gitoria
11.4 KB
// components/main.hl — THE SHELL (tracker.worldapi.org#32, mission 031): the WorldAPI theme's header and content-first shell// (theme/shell/*, vendored from layouts.worldapi.org — never edited here) around the slot every page renders into.// The shell rules live in this file; the theme rules come with theme/theme.hl and its shell files.// THE HEADER (creator, tracker#32): desktop — brand left, the search field in the middle, the main menu// Series | Shows | Movies | Genres | People | Franchises (tracker#40), the user icon far right; its dropdown holds the personal lists and ends with// Settings, Logout. IDENT'S SELECTOR STANDS IN THE HEADER next to it, signed in and signed out (creator 2026-10-24: the theme move hid it// behind an icon — never again; the gate checks it at 390 and 1280); signed out the selector stands alone (no second "Log in" button — creator 2026-10-24). Phone — ☰ (the sidebar// overlay with the main menu), brand, the loupe (opens the search field under the bar), the selector, the user icon far right. The header's contents are flush with the content column (the theme's --layout-column).// THE MARKED MENU ENTRY: a shell is not told the page's path (hl:web gives it only the route params), so MainMenu gets no// `current`; the Style block marks the entry of the type the page's heading names ("Series | …" → Series) with :has().// THE SEARCH FIELD sends GET /find?q=… (project.hl findRoute → 302 /search/<text>, components/search.hl).// THE SELECTOR: `<ident-selector key=IDENT_API_KEY>` from <ident>/selector.js, as in calendar/gitoria. Choosing an// identity fires `ident-login` (one-time code); /login.js hands it to the hidden input #identcode, whose `change`// goes to the face trackerLogin (server-side exchange, no reload). The element's class is `in` / `out`; /login.js// mirrors it into the selector's `loggedIn`.// LOGIN: the selector (the plain link to <ident>/login?key=&return=<public url>/login/callback is the old way, still served)// (users.hl loginCallbackOf). After a login or logout in this tab the page is fetched again (navigate('/')).import { navigate } from 'hl:web'import { appTitle } from '../lib/app.hl'import { identKey, callbackUrl, selectorScript, userIdOfSession, userOfCode, loginPerMinute } from '../lib/users.hl'import { allowHit } from '../lib/security.hl'import { randomBytes } from 'hl:crypto'import AppHeader from '../theme/shell/app-header.hl'import MainMenu from '../theme/shell/main-menu.hl'import UserMenu from '../theme/shell/user-menu.hl'import Sidebar from '../theme/shell/app-sidebar.hl'import ContentFirst from '../theme/shell/content-first.hl'static menu = [{ label = 'Series' href = '/series' }{ label = 'Shows' href = '/shows' }{ label = 'Movies' href = '/movies' }{ label = 'Genres' href = '/genres' }{ label = 'People' href = '/people' }// tracker#40: the franchises and their timelines were only reachable by a title's widget{ label = 'Franchises' href = '/franchises' }]slot = nullsession = nullloggedIn = userIdOfSession(&session) != nullloggedOut = userIdOfSession(&session) == nullselectorClass = loggedIn ? 'in' : 'out'selectorKey = identKey// where the selector's sign-in panel (ident#31) sends the browser: the login button's callback, with the page the user is on as `next`// (the callback takes it back there). No route known (first paint) = no `next` = the start page.route = nullpath = route == null ? '' : route.pathselectorReturn = callbackUrl + (path == '' ? '' : '?next=' + encodeURIComponent(path))identScript = selectorScriptloginError = ''hasLoginError = false// OFFLINE (tracker.worldapi.org#10): the service worker opens `/` from its cache without a network; the shell then// says so. hl:web gives a page no connection state and no "mounted" hook, so a tick asks the browser: `netProbe` runs// an endless 1 s CSS animation (this file), and each `animationiteration` reads navigator.onLine — a write only when// it changed. (An `img` error or a socket event would race the hydration and be missed.)offline = false// HM49: component rules keep the existing selectors and shared theme variables.Style {'body:has(main h1.typed > type-word.type-series)' {mainMenu {'a[href="/series"]' {color = 'var(--color-accent)'}}appSidebar {mainMenu {'a[href="/series"]' {background = 'var(--color-surface)'}}}}'body:has(main h1.typed > type-word.type-show)' {mainMenu {'a[href="/shows"]' {color = 'var(--color-accent)'}}appSidebar {mainMenu {'a[href="/shows"]' {background = 'var(--color-surface)'}}}}'body:has(main h1.typed > type-word.type-movie)' {mainMenu {'a[href="/movies"]' {color = 'var(--color-accent)'}}appSidebar {mainMenu {'a[href="/movies"]' {background = 'var(--color-surface)'}}}}'body:has(main h1.typed > type-word.type-genre)' {mainMenu {'a[href="/genres"]' {color = 'var(--color-accent)'}}appSidebar {mainMenu {'a[href="/genres"]' {background = 'var(--color-surface)'}}}}'body:has(main h1.typed > type-word.type-person)' {mainMenu {'a[href="/people"]' {color = 'var(--color-accent)'}}appSidebar {mainMenu {'a[href="/people"]' {background = 'var(--color-surface)'}}}}'body:has(main h1.typed > type-word.type-franchise)' {mainMenu {'a[href="/franchises"]' {color = 'var(--color-accent)'}}appSidebar {mainMenu {'a[href="/franchises"]' {background = 'var(--color-surface)'}}}}'body:has(main h1.typed > type-word.type-timeline)' {mainMenu {'a[href="/franchises"]' {color = 'var(--color-accent)'}}appSidebar {mainMenu {'a[href="/franchises"]' {background = 'var(--color-surface)'}}}}identSelector {'--ident-accent' = 'var(--color-accent)''--ident-accent-text' = 'var(--color-accent-text)''--ident-background' = 'var(--color-surface)''--ident-border' = 'var(--color-border)''--ident-font' = '600 .9rem/1.3 system-ui, sans-serif'position = 'relative'flex = '0 1 auto'minWidth = '0'}'ident-selector::part(button)' {minHeight = '2.75rem'padding = '.25rem .6rem'border = 'none'whiteSpace = 'nowrap'}'ident-selector::part(status)' {minHeight = '2.75rem'padding = '.25rem .6rem'border = 'none'whiteSpace = 'nowrap'overflow = 'hidden'textOverflow = 'ellipsis'}'ident-selector::part(identity)' {minHeight = '2.75rem'border = 'none'}'ident-selector::part(panel)' {position = 'absolute'top = '100%'right = '0'zIndex = '30'width = 'min(20rem, calc(100vw - 2 * var(--layout-gutter)))'maxWidth = 'none'border = 'none'boxShadow = '0 .75rem 2rem ' + 'var(--color-background-sunken)'}'body:has(application-header > ident-selector.in)' {applicationHeader {@media {maxWidth = '29.99rem'gap = '0'paddingInline = '.25rem'}'>' {'button.menu-toggle' {@media {maxWidth = '29.99rem'marginLeft = '-.25rem'}}'a.brand' {@media {maxWidth = '29.99rem'fontSize = '1rem'}@media {maxWidth = '22.99rem'fontSize = '.85rem'flexShrink = '0'}}'button.search-toggle' {@media {maxWidth = '22.99rem'marginInline = '-.125rem'}}}userMenu {'>' {button {@media {maxWidth = '29.99rem'marginRight = '-.25rem'}}}}}}offlineNote {display = 'block'padding = '.5rem .75rem'color = 'var(--color-text-strong)'background = 'var(--color-surface)'}netProbe {position = 'fixed'left = '0'top = '0'width = '1px'height = '1px'opacity = '0'pointerEvents = 'none'animation = 'tracker-net-tick 1s linear infinite'}'@keyframes tracker-net-tick' {'from' {opacity = '0'}to {opacity = '0'}}}View {body {AppHeader { brand = appTitle search = "/find" searchPlaceholder = "Shows, movies, people"MainMenu { items = menu }// ident's selector stands in the header, visible signed in AND signed out, on the phone and on the desktop (signed in it shows the// chosen identity). /login.js mirrors its state from the class (`in` / `out`). Nothing else stands beside it: no second "Log in" button (creator 2026-10-24).identSelector { id = "selector" key = selectorKey return = selectorReturn class = selectorClass }if (loggedIn) {UserMenu {a { href = "/my/unwatched" "Unwatched" }a { href = "/my/schedule" "Schedule" }a { href = "/my/series" "My series" }a { href = "/my/shows" "My shows" }a { href = "/my/movies" "My movies" }a { id = "settingslink" href = "/settings" "Settings" }button { id = "logout" type = "button" "Logout" on click(e) { emit doLogout(e) } }}}}input { id = "identcode" type = "hidden" on change(e) { emit gotCode(e) } }if (hasLoginError) { p { id = "loginerror" class = "message banner" loginError } }if (offline) { offlineNote { id = "offline" "You are offline. Your shows and lists need the network." } }netProbe { "aria-hidden" = "true" on animationiteration(e) { emit netTick(e) } }// the phone's overlay with the main menu (desktop = "false": the header shows the menu from 60rem), then the shell with the// page. NOT the theme's `ContentFirst { Sidebar { … } main { slot } }`: hl:web renders a component's slot children on one// line, and a page slot that does not start its own line is rendered once per line of the page (WebFramework.hl// document(): the text before the marker is taken as the indent) — so `main` stands around the shell and the page is the// shell's slot itselfSidebar { desktop = "false" MainMenu { items = menu } }main {ContentFirst { slot }}script { src = identScript }script { src = "/login.js" }}}showIn = () => {loggedIn = trueloggedOut = falseselectorClass = 'in'loginError = ''hasLoginError = false}showOut = () => {loggedIn = falseloggedOut = trueselectorClass = 'out'}// the selector's code (via /login.js and the hidden input) → the server exchanges iton gotCode(e) {code = e.target.valuee.target.value = ''if (code == null || code == '') { return null }r = emit server trackerLogin(code)if (r == null || r.error != null) {loginError = r != null ? r.error : 'the login failed'hasLoginError = truereturn null}showIn()navigate('/')}on client trackerSignedIn(tag) {showIn()navigate('/')}on client trackerSignedOut(tag) {showOut()navigate('/')}on netTick(e) {down = window.navigator.onLine == falseif (down != offline) { offline = down }}on doLogout(e) {emit server trackerLogOut()showOut()navigate('/')}// ---- the faces (the trailing `session` is always the server's: hybriel #16) ----on server trackerLogin(code, session) {if (session == null) { return { error = 'no session — reload the page' } }if (!allowHit('login-face', &session.id, &loginPerMinute, 60000)) { return { error = 'too many login attempts — wait a minute' } }x = userOfCode(code)if (x.error != null) { return { error = x.error } }tag = randomBytes(16)session.user = { id = x.user.id }session.data.tag = tagemit client trackerSignedIn(tag)return { ok = true }}on server trackerLogOut(session) {if (session == null) { return { error = 'no session' } }emit client trackerSignedOut(session.data.tag)session.user = nullreturn { ok = true }}
Branches
Latest commits
- b32b8440Merge hm66-catalogindex: packed catalog indexmre
- 2db0f7adReport HM66 heap measurements and validationmre
- 6ce15623Pack catalog lists and membership maps in UTF-8 bytesmre
- 71134e21HM66 briefmre
- ed4cbab2status timemre
- e982c26dlog: HM65 mergedmre
- 6e72f9d1Merge hm65-fields: episode boot scan reads three fieldsmre
- 07a5c883HM65 report measured field projection and complete validationmre
- 0eab858fRead only catalog date fields during the episode boot scanmre
- d3179273log: HM65 hl:heap vendoringmre
- cb78a1a0HM65 report missing heap diagnostic package with repromre
- 89606a5cHM65 briefmre
- 096ce0d4log: DP69 live on day48mre
- b3d8a80bDP69 brief, RV48 mergedmre
- ce6d7d32Merge rv48: Hybriel day48mre
- 3da2ea86RV48: report day48 cold starts, gates and cleanupmre
- 8d9ecdfeRV48: re-vendor Hybriel set day48 (source b6a8f429, bin 660a9524)mre
- 4a802ae7status: RV48 runningmre
- 0a5412b6RV48 brief, day48 outmre
- 56665efelog: CB69 mergedmre