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
- d0c083fbLog: usage stopmre
- c6d464e5Log: Apollo GO backlog, AP56 and BS1 startedmre
- 1eb6f1a1Missions AP56, BS1mre
- 4871f8adLog: AP52 live on day52, browser gate greenmre
- d9bf2988Merge ap52: day52, tracker#58 server argument, #51 modal close rule, #56 keyed season rowsmre
- c4a60ef2Log: RT52 retest passed, AP52 startedmre
- 83760a55Browser gate: search results belong to the address form of the typed text (tracker#52 navigate replace)mre
- 6e951d91AP52: show-page rows are keyed records; closing a season is one upsert and removes (tracker#56, hybriel#331)mre
- 3bb4ccddAP52: modal close button refers to its nested rule with Style.buttonModalX (tracker#51, hybriel#333)mre
- ba16933fAP52: login callback and title route are static handlers taking the server as third argument (tracker#58, hybriel#332)mre
- 85153900AP52: re-vendor Hybriel set day52 (source 77cfca31, bin 0a8ed496)mre
- 7c051eddLog: hybriel#338 answermre
- d049b8b8Log: HM50 live, #52 donemre
- 6d05fa37Log: HM50 Part A mergedmre
- 1c7dab74HM50: the shell reads the framework's online state, netProbe removed (tracker#55)mre
- e8b91697HM50: search address follows the text via navigate(path, replace = true) (tracker#52)mre
- 6fe1896cHM50: re-vendor Hybriel set day50 (source 0ae38232, bin d3ef9d16)mre
- 2f391aa9Log: HM50 startedmre
- 4b59c03dHM50 mission: doc pathmre
- ed526d67HM50 missionmre