gitoria
All repositories: gitoria
10.8 KB
// components/main.hl — THE SHELL (gitoria#23): the WorldAPI theme's header and content-first shell (theme/shell/*, copied from// layouts.worldapi.org — never edited here, the way tracker.worldapi.org wears it) around the slot every page renders into, plus// the display-name prompt of a first login. The shell owns its Style block (the theme shells carry their own Style).// THE HEADER: phone — ☰ (the sidebar overlay with the main menu) · brand · ident's selector · the user icon far right (its dropdown:// your name, Access tokens, SSH keys, Log out); signed out the selector stands alone (no second "Log in" button — creator 2026-10-24).// From 60rem: brand · main menu · selector · user icon. IDENT'S SELECTOR STANDS IN THE HEADER, visible signed in and signed out, on the// phone and on the desktop (creator 2026-10-24: the theme move hid it behind an icon — never again; the gate checks it at 390 and 1280).// The main menu is the app's top level, on the main address: Repositories. The repo's own tabs stay in the repo head of the repo layout level (repo.hl).// THE SELECTOR (gitoria#14): `<ident-selector key=IDENT_API_KEY>` from <ident>/selector.js, as in tickets.// Choosing an identity fires `ident-login` (one-time code); /login.js hands it to the hidden input// #identcode, whose `change` goes to the face gitoriaLogin (server-side exchange, no reload). The element's// class is `in` / `out`; /login.js mirrors it into the selector's `loggedIn`. THE SAME SELECTOR STANDS ON EVERY ADDRESS: the main one and// every repo address (<repo>.<host>) — ident answers a repo address because the app's registered origins hold the wildcard origin// `https://*.<host>` (ident accepts `*.` as the first label of a registered origin). The login is the one session of the main// address and all repo addresses (the cookie's Domain, project.hl sessionDomain).// LOGIN: a plain link to <ident>/login?key=&return=<public url>/login/callback (lib/api.hl// loginCallback); /login.js adds `?next=<this page>` at the click so the login returns here.// FIRST LOGIN: no display name yet → the name prompt; creating a repo waits for it.import { siteName } from '../project.hl'import { publicUrl } from '../lib/util.hl'import { identKey, callbackUrl, selectorScript, infoOfSession, userOfLoginCode, userInfo, setUserName, userOfSession } from '../lib/users.hl'import { randomBytes } from 'hl:crypto'import AppHeader from '../theme/shell/app-header.hl'import MainMenu from '../theme/shell/main-menu.hl'import Sidebar from '../theme/shell/app-sidebar.hl'import ContentFirst from '../theme/shell/content-first.hl'// the main menu: the header from 60rem, the phone's sidebar below — one list (every repo address links back to the main one)// an INSTANCE property, not `static` (gitoria#23 reopened): a static is evaluated again in the browser after an in-page navigation, where `publicUrl` (hl:proc env) has no value — the link became a 404. The instance property is filled by the server.// `current = true` STAYS (hybriel#197 checked, mission 010): the route marker needs the item href to be the page path, but this item links to the MAIN address (absolute) and every page of the app (/code, /pulls …) lies under it, so the route cannot tell; it is marked on allmenu = [{ label = 'Repositories' href = publicUrl + '/' current = true }]slot = nullsession = nullme = infoOfSession(session)loggedIn = me != nullloggedOut = me == nullneedsName = me != null && !me.namedmyName = me != null && me.named ? me.name : 'you'selectorClass = me != null ? 'in' : 'out'tokensHref = publicUrl + '/#tokens'keysHref = publicUrl + '/#sshkeys'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 = falsenameDraft = ''nameError = ''// OFFLINE (mission 046, as 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 (styles.hl), and each `animationiteration` reads navigator.onLine — a// write only when it changed.offline = falseView {body {AppHeader { brand = siteNameMainMenu { 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 }// signed in, like before the theme missions: your name and Log out stand beside the selector (Access tokens and SSH keys are on the account pages)if (loggedIn) {span { id = "whoami" myName }button { id = "logout" type = "button" class = "quiet" "Log out" 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. Repositories and code need the network." } }netProbe { "aria-hidden" = "true" on animationiteration(e) { emit netTick(e) } }if (needsName) {namePrompt {form { id = "nameform"on submit(e) {e.preventDefault()emit saveName(e)}label { "Welcome! Choose the display name others see as the owner of your repositories"input { id = "displayname" name = "displayname" required = "required" maxlength = "60" value = nameDraft on input(e) { emit setNameDraft(e.target.value) } }}button { id = "namesave" type = "submit" "Save" }p { id = "nameerror" class = "message" nameError }}}}// the phone's overlay with the main menu (desktop = "false": the header shows the menu from 60rem), then the shell with the// page — `Sidebar` + `main { ContentFirst { slot } }`, as tracker does: the page slot must start its own line (hybriel#130)Sidebar { desktop = "false" MainMenu { items = menu } }main {ContentFirst { slot }}script { src = identScript }script { src = "/login.js" }}}showMe = (info) => {loggedIn = trueloggedOut = falseneedsName = !info.namedmyName = info.named ? info.name : 'you'selectorClass = 'in'loginError = ''hasLoginError = false}showOut = () => {loggedIn = falseloggedOut = trueneedsName = falsemyName = 'you'selectorClass = '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 gitoriaLogin(code)if (r == null || r.error != null) {loginError = r != null ? r.error : 'the login failed'hasLoginError = truereturn null}showMe(r)}on client gitoriaSignedIn(tag, info) { showMe(info) }on client gitoriaSignedOut(tag) { showOut() }on setNameDraft(v) { nameDraft = v }on netTick(e) {down = window.navigator.onLine == falseif (down != offline) { offline = down }}on saveName(e) {r = emit server gitoriaSaveName(nameDraft)if (r == null || r.error != null) {nameError = r != null ? r.error : 'could not save the name'return null}nameError = ''showMe(r)}on doLogout(e) {emit server gitoriaLogOut()showOut()}// ---- the faces (the trailing `session` is always the server's: hybriel #16) ----on server gitoriaLogin(code, session) {if (session == null) { return { error = 'no session — reload the page' } }x = userOfLoginCode(code)if (x.error != null) { return { error = x.error } }tag = randomBytes(16)session.user = { id = x.user.id }session.data.tag = taginfo = userInfo(x.user)emit client gitoriaSignedIn(tag, info)return info}on server gitoriaSaveName(name, session) {u = userOfSession(session)if (u == null) { return { error = 'log in with ident first' } }r = setUserName(u.id, name)if (r.error != null) { return { error = r.error } }info = userInfo(r.user)emit client gitoriaSignedIn(session.data.tag, info)return info}on server gitoriaLogOut(session) {if (session == null) { return { error = 'no session' } }emit client gitoriaSignedOut(session.data.tag)session.user = nullreturn { ok = true }}Style {#whoami {marginRight = '.5rem'fontWeight = '600'color = 'var(--color-text-strong)'fontSize = '.875rem'maxWidth = '6rem'overflow = 'hidden'textOverflow = 'ellipsis'whiteSpace = 'nowrap'flex = '0 1 auto'minWidth = '0'display = 'inline-flex'alignItems = 'center'minHeight = '2.75rem'}#logout {flex = 'none'whiteSpace = 'nowrap'padding = '.25rem .5rem'}identSelector {'--ident-accent' = 'var(--color-accent)''--ident-accent-text' = 'var(--color-accent-text)''--ident-background' = 'var(--color-surface)''--ident-border' = 'var(--color-surface)''--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)'}#loginerror {margin = '0'padding = '.5rem var(--layout-gutter)'background = 'var(--color-background-sunken)'}namePrompt {display = 'block'paddingInline = 'max(var(--layout-gutter), calc((100% - var(--layout-column)) / 2))'paddingTop = '1rem'form {display = 'grid'gap = '.6rem'padding = '1rem'background = 'var(--color-surface)'borderRadius = 'var(--radius-large)''> *' {margin = '0'}}}offlineNote {display = 'block'padding = '.5rem var(--layout-gutter)'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 = 'gitoria-net-tick 1s linear infinite'}'@keyframes gitoria-net-tick' {'from' {opacity = '0'}to {opacity = '0'}}}
Branches
- f1-broken-json
- f2-api-bugs
- gp-gate-ports
- heap-revert
- hl25-records
- ident-chooser-selector
- mainmain branch
- p51-public-pr-reads
- records-1112
- s25-no-session-on-login-error
- v59
- w52-person-approval
- w52b-approval-followup
- w52c-header-phone
- w53-pulls-speed-pr
- w54-repo-rename-pr
- w55-rename-org
- w56-owner-members
- w62-pr-close
- w63-force-push
- w64-org-slash
Latest commits
- d046940alog: vinzenz contract note sentmre
- db443456log: vinzenz note retry 2mre
- 802f229alog: kunibert repo ping provenmre
- 2d2eaa92log: Kunibert connected to kunibert repomre
- 65d5f80alogmre
- dab74b0dW49 report, logmre
- fd4fc028Exercise member status reads with a populated check statemre
- 536ca6f9Allow repository members to read pull workflow APIs with user tokensmre
- 705dd834W49 missionmre
- b554cd5flogmre
- f4c9440ddeploy.sh: tar --hard-dereference for the live data backupmre
- 1a687b15Merge branch 'w48-member-merge'mre
- 166c775fW48 report, logmre
- 1b4623f0Members merge pull requests: API route, button on /pulls and /pulls/N, one shared merge pathmre
- 1075c38cW48 mission, logmre
- 17bdd0d6V37/V39 missions, logmre
- 146de5f8Re-vendor gitoria to Hybriel set-day39 (51e921d7)mre
- e874e44dtests/status-keyed: app token lives 60 s so it outlives the gate's two restartsmre
- 270b8d61deploy.sh: DEPLOY_STOP_START=1 stops, waits for the old pid, then starts (mpackdb freeze, replaces the standby swap)mre
- 3f9235b8project.hl: drop the dummy /pulls/:n component route (hybriel#294 is fixed in day37)mre