notes
All repositories: gitoria
7.3 KB
// components/main.hl — THE SHELL (mission 011, phone first on the WorldAPI theme): the theme's AppHeader (brand · main menu ·// user icon), the phone's Sidebar (☰ → the main menu) and the slot every page renders into; the page chooses its shell (the// notes page ListFirst, /login/failed and the signed-out hint ContentFirst). The theme's shell files theme/shell/*.hl are never// edited here. Its own CSS (the header's selector, the login error, Log out) is its Style block; components/styles.hl keeps only the theme inherit, the accent and the message colour.// 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 and replaced it by the user menu — never again; the gate checks it at 390 and 1280). Signed in the// user icon beside it opens the UserMenu (Log out). Nothing else stands beside the selector: no second "Log in" button (creator 2026-10-24).// THE SELECTOR: `<ident-selector key=IDENT_API_KEY>` from <ident>/selector.js, as in 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 notesLogin (server-side exchange, lib/users.hl userOfLoginCode; no reload). The element's class is `in` / `out`; /login.js mirrors it into// the selector's `loggedIn`.// LOGIN: a plain link to <ident>/login?key=&return=<public url>/login/callback (lib/api.hl loginCallback).// After a login or logout in this tab the page is fetched again (navigate('/')): the notes of the session show.import { navigate } from 'hl:web'import { siteName } from '../project.hl'import { identKey, callbackUrl, selectorScript, userIdOfSession, userOfLoginCode } from '../lib/users.hl'import { randomBytes } from 'hl:crypto'import { messageLook } from '../lib/looks.hl'import AppHeader from '../theme/shell/app-header.hl'import MainMenu from '../theme/shell/main-menu.hl'import Sidebar from '../theme/shell/app-sidebar.hl'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// the main menu: the header from 60rem, the phone's sidebar below — one list (one page so far; the menu is the shell's place for more)// `current = true` STAYS (mission 015, hybriel#197): the menu now marks an item from the route, but only the page '/' itself (an item// with href '/' is not "above" other pages, by design) — on /note/:id and /login/failed the route marks nothing (server HTML checked in// tests/browser.mjs "server html …"; without current = true those two fail), and the one item is the whole appmenu = [ { label = 'Notes' href = '/' current = true } ]Style {pMessage = messageLook + { }// ---- ident's selector in the header (creator 2026-10-24, "you removed the ident widget from all sites"): it stands top right, signed in AND// signed out, on the phone and on the desktop — never behind an icon or a popover. Its shadow DOM is in ident's design, restyled to the accent// through its custom properties and parts; the pill is kept compact so brand, selector and the user icon fit one row at 390 px. Its dropdown opens// under it, as wide as a phone allows.'#loginerror' { margin = '0' padding = '.5rem var(--layout-gutter)' background = 'var(--color-background-sunken)' }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 = 'var(--layout-tap)' padding = '.25rem .6rem' whiteSpace = 'nowrap' }'ident-selector::part(status)' { minHeight = 'var(--layout-tap)' padding = '.25rem .6rem' whiteSpace = 'nowrap' overflow = 'hidden' textOverflow = 'ellipsis' }'ident-selector::part(identity)' { minHeight = 'var(--layout-tap)' }'ident-selector::part(panel)' { position = 'absolute' top = '100%' right = '0' zIndex = '30' width = 'min(20rem, calc(100vw - 2 * var(--layout-gutter)))' maxWidth = 'none' boxShadow = '0 .75rem 2rem var(--color-background-sunken)' }'#logout' { flex = 'none' whiteSpace = 'nowrap' padding = '.25rem .5rem' }}View {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: Log out stands beside the selectorif (loggedIn) {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" Style.pMessage class = "banner" loginError } }// the phone's overlay with the main menu (desktop = "false": the header shows the menu from 60rem); the page (its own// shell: list-first for the notes, content-first for the rest) follows — hybriel#130: the page slot starts its own lineSidebar { desktop = "false" MainMenu { items = menu } }slotscript { 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 notesLogin(code)if (r == null || r.error != null) {loginError = r != null ? r.error : 'the login failed'hasLoginError = truereturn null}showIn()navigate('/')}on client notesSignedIn(tag) {showIn()navigate('/')}on client notesSignedOut(tag) {showOut()navigate('/')}on doLogout(e) {emit server notesLogOut()showOut()navigate('/')}// ---- the faces (the trailing `session` is always the server's: hybriel #16) ----on server notesLogin(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 = tagemit client notesSignedIn(tag)return { ok = true }}on server notesLogOut(session) {if (session == null) { return { error = 'no session' } }emit client notesSignedOut(session.data.tag)session.user = nullsession.data.tag = nullreturn { ok = true }}
Branches
Latest commits
- d7366702Check session cookie flags after login and assert anonymous GET stays cookielessmre
- 16bc8fd8Re-vendor Hybriel day38b with the mpackdb store-open race fixmre
- d860dc2dnotes#12: the markup names its own rules instead of hand-written class strings: the selected row is `aria-current="page"` (the list-first theme rule styles it, no class), the delete question is `Style.pAsk` and follows its own `open` attribute (bound to `asking`), the error line is `Style.pMessage` (body once in lib/looks.hl, rule in notes.hl, main.hl and loginfailed.hl). The CSS declarations are the same, only selectors changed (.ask -> p.ask, .ask.open -> p.ask[open], .message -> p.message); the pages look the same (AE 0 at 4 sizes). main.hl's selectorClass in/out stays (login.js reads it).mre
- 2e7f8664notes#13: the list and back links pass the note key from the loop (emit pick(e, r.key)) instead of writing data-note into the View and reading it back with getAttribute; the two window.history.replaceState calls and the identcode e.target.value read stay (hl:web has no replace-navigation, a bound hidden input is not adopted on a script's change event), see NO13 reportmre
- 4dc98282notes#15: a deleted note made in this tab leaves the list at once (the delete now removes this tab's edit under every key the row has: local id, server id); gate: browser.mjs notes#15 section, red on the old codemre
- e4e7402fnotes#11: plain declarations instead of let for variables never reassigned (components/notes.hl 3, lib/jsoncheck.hl 5, lib/util.hl 2, tools/migrate-short-ids.hl 8)mre
- 27b6a09enotes#8: Style blocks in the nested form (note-list, note-editor, .ask with their children nested, :empty as a nested pseudo-class); the same CSS rules, the pages look the samemre
- 71a9538bnotes: B27W report, log linemre
- 78ba0073notes: an ident access key (Authorization: Bearer idt_…) reads and writes its identity's notes through /api/me and /api/notes; gate tests/ident-access-notes.mjs (ident#27)mre
- 3de46dacnotes: the sign-in callback keeps the session it finds and signs it in (same cookie, nothing signed out; ident#28); security gate 73+5 failing → 78 passedmre
- 5909d458notes: MdEditor from components 59704ce (text on the clipboard always pastes, a file manager copy still attaches; pipe rows without a delimiter row; tickets#49, notes#5)mre
- 98bd6a98N5b: pipe rows without a delimiter row are a table (MdEditor ad4e929, plain copy); gate tests/dashboard-table.mjs; reportmre
- dbf93319N5 report: components gate rerun 613 passed, 0 failedmre
- 3a8bc0d2N5: empty Table-button table is written as a real pipe table (MdEditor 4bd1112, plain copy); gate tests/table-button.mjs; reportmre
- c16bd443N5: step 1 report (tables pass locally; his DASHBOARD note has no delimiter row)mre
- 6091320anotes: MdEditor 7437e32 (surface drawn at once when the page is claimed); gate measures claim-to-text on 5 note loads at 1280 and 390mre
- 0aa9277enotes: move each component's styles into its own Style block (shell and header selector in main.hl, list, editor frame and delete question in notes.hl); styles.hl keeps the theme inherit, the accent and the message colour; .gitignore ignores a bin symlink too; tests/shots.mjs for the pixel comparemre
- 9ba01de3notes: write the standby service out in full so the boot gate can read the main servicemre
- 98cab40anotes: standby service on its port plus 10 and a deploy that hands over through it without a gapmre
- 1fadb473notes gate: the editor table now has 1 px cell lines from the notes thememre