tracker
All repositories: gitoria
10.9 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, #55): the service worker opens `/` from its cache without a network; the shell then// says so. hl:web keeps `__hlOnline` equal to the browser's connection (navigator.onLine and the online/offline events)// for the shell and its kids; `offline` is derived from it for the View's `if`.__hlOnline = trueoffline = !__hlOnline// 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)'}}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." } }// 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 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
- 792b9652README: search results come from the routeTracker
- fd8570b1|||PR search: one server exchange per keystrokeTracker
- f5a06a0fLog: gitoria push setup, SR1Tracker
- d6b109baMission SR1mre
- 608b7558Log: FF1 merged via PR #1mre
- 2939d94cMerge branch 'ff1-gate-failfast' into mainTracker
- c934361a|||PR tests: gates fail fast when the app exits during startmre
- d714ae42Log/status: AP56 closed out, FF1mre
- a429d088Mission FF1mre
- 03bbfba3Log: AP56c causemre
- 24845fe3Log: AP56b result, AP56cmre
- 6a6d71eaLog: gitoria membershipmre
- 8b842dc8Log + CONDUCTOR: gitoria PR switch-onmre
- 6bb7c20estatus: window 2026-11-09mre
- 5db84974Log: Apollo window GO, AP56b started, BS1 copy removedmre
- e84586a7Mission AP56bmre
- 15917f03Record PR workflow rule (gitoria#50)mre
- 942ac995status: paused workers statemre
- 44b934e5log: respawn cleanupmre
- 03a80097Log: Anton GC A/Bmre