gitoria
All repositories: gitoria
8.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. All CSS is in styles.hl (the shell files carry their own Style).// THE HEADER: phone — ☰ (the sidebar overlay with the main menu) · brand · the user icon far right (its dropdown: your name,// Access tokens, SSH keys, Log out); signed out the ident icon stands there, its dropdown holds ident's selector and "Log in with// ident". From 60rem: brand · main menu · user icon; signed out the selector and the login button stand in the header themselves.// 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`. ident only answers a REGISTERED// origin (the main address), so on a repo address (the request's host, `host = null`, hybriel#74) the selector// carries the class `onrepo` and styles.hl hides it — the button stays there.// 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 { slugOfHost, publicUrl } from '../lib/util.hl'import { identKey, selectorScript, loginHref, 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 UserMenu from '../theme/shell/user-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)// `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 allstatic menu = [{ label = 'Repositories' href = publicUrl + '/' current = true }]slot = nullsession = nullhost = nullme = infoOfSession(session)loggedIn = me != nullloggedOut = me == nullneedsName = me != null && !me.namedmyName = me != null && me.named ? me.name : 'you'buttonHref = loginHrefonRepoHost = slugOfHost(host) != ''selectorClass = (me != null ? 'in' : 'out') + (onRepoHost ? ' onrepo' : '')tokensHref = publicUrl + '/#tokens'keysHref = publicUrl + '/#sshkeys'selectorKey = identKeyidentScript = 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 }if (loggedIn) {UserMenu {p { id = "whoami" class = "who" myName }a { id = "tokenslink" href = tokensHref "Access tokens" }a { id = "keyslink" href = keysHref "SSH keys" }button { id = "logout" type = "button" "Log out" on click(e) { emit doLogout(e) } }}}// signed out: the ident icon (phone) and its dropdown — from 60rem the dropdown stands open in the header. Signed in it// is hidden (class `in`), the selector element stays: /login.js mirrors its state (gitoria#14)identMenu { class = selectorClassbutton { type = "button" class = "ident-toggle" popovertarget = "ident-panel" title = "Log in with ident" "aria-label" = "Log in with ident"// the ident icon (as tracker's): a small i standing beside a big D lying on the floor; the D's lower face is its thicknesssvg { class = "ident-icon" viewBox = "1 10 20 13.2" "aria-hidden" = "true"path { class = "ident-d-side" d = "M5 22.6 L7.8 14.2 C15.1 14.2 19 16.6 19.6 18.4 C20.2 20.2 16.2 22.6 5 22.6 Z" }path { class = "ident-d" "fill-rule" = "evenodd" d = "M5 21 L7.8 12.6 C15.1 12.6 19 15 19.6 16.8 C20.2 18.6 16.2 21 5 21 Z M10.7 14.4 C13.6 14.4 15.4 15.3 15.6 16.8 C15.8 18.3 13.7 19.2 10 19.2 Z" }rect { class = "ident-i" x = "1.6" y = "14.2" width = "1.9" height = "6.8" rx = ".5" }circle { class = "ident-i" cx = "2.55" cy = "11.6" r = "1.15" }}}identPanel { id = "ident-panel" popover = "auto"identSelector { id = "selector" key = selectorKey class = selectorClass }if (loggedOut) {a { id = "loginbutton" class = "button primary" href = buttonHref "Log in with ident" }}}}}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 = onRepoHost ? 'in onrepo' : 'in'loginError = ''hasLoginError = false}showOut = () => {loggedIn = falseloggedOut = trueneedsName = falsemyName = 'you'selectorClass = onRepoHost ? 'out onrepo' : '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 }}
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
- 63cfa21ereports/G2-repotabs.mdmre
- 9b0516fdgitoria#22: mark the tab underline functional (check-theme), chain E2E: serve/measure split, bring the lisbeth tab to frontmre
- 19bc1df8gitoria#22: all repo pages under ONE layout level (components/repo.hl, hl:web D-CHAIN): a tab click replaces only the page in the slot; head and tab nav stay the same DOM nodesmre
- 40658417tests/browser.mjs: wait for the page to be live (hydrated) before clicking Merge — a click on the server-rendered button before the client mounted was lost (flaky 'Clashing change' under load)mre
- 48a6154bre-vendor Hybriel 5406d146 (hl:web batches 9+10: #72 emits while the socket is closed delivered after reconnect, browser boot linear, faster list appends; contains int 6–14 + m406)mre
- e972e8d7tests: short-id-switch (GITORIA_SWITCH_IDENT_PORT/_PORT) and ssh tunnel (GITORIA_GATE_TUNNEL_PORT) ports from env, defaults unchangedmre
- f06f5349re-vendor Hybriel 6f8a0689 (int 6–11: streaming cursors, #203 index heal + close() fix, fd403 listDir/cursor fds, hl:time browser side, hl:web batches 5+6)mre
- c7d3cc87docker-compose: nofile 65536 (Hybriel int 6+ boot opened >1024 files in the tracker)mre
- f0e7ff8cdeploy: backup copies index files first and *.mpack data last (hot-copy skew, hybriel #203)mre
- fe5f707cgitoria 010: report, mission, comment on why current = true staysmre
- 9705ca86gitoria 010: gate: menu marker in the server HTMLmre
- 8cff663agitoria 010: main-menu.hl from layouts 0bcc629 (route marker)mre
- 359c79f7gitoria 010: re-vendor Hybriel master f9614007 (plugins whole, bin/ git-ignored)mre
- 6bd7fb3cgitoria 009: theme re-copied from layouts 76f99f6 (menu marks the current page), current = true on the menu item, e2e marker checks, reportmre
- 44de915cidentkit: refuse a taken ident port, cold-start deadline, abort on dead ident, clear no-code error (as notes)mre
- 2bf5343egitoria 007: theme re-copied from layouts dbe3de7 (44 px taps), redundant tap overrides dropped, crumbs class, real-browser walk test, reportmre
- 18843648deploy.sh: a gate without a 'passed,' line (check-theme) no longer ends the script silently (grep under pipefail) — print check-theme's summary, as layouts doesmre
- e6dff0cbgitoria#23: report 005, STATUS, LOGmre
- 7f992d62gitoria#23: phone first on the shared theme — brand, branch and pull links 44 px, readme code 14 px; gate block "phone first" (15 pages at 390 + the three dropdowns, fails 20 on old), dropdown-aware login/logout clicks, check-theme in GATESmre
- a2a840a5gitoria#23 WIP (quota stop): theme from layouts, styles inherit it, shell on the theme's header/menus/sidebar, phone measurement script; gates not runmre