gitoria

notes

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitd860dc2dd860dc2dnotes#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).mred860dc2d/components/main.hl

7.3 KB

  1. // components/main.hl — THE SHELL (mission 011, phone first on the WorldAPI theme): the theme's AppHeader (brand · main menu ·
  2. // user icon), the phone's Sidebar (☰ → the main menu) and the slot every page renders into; the page chooses its shell (the
  3. // notes page ListFirst, /login/failed and the signed-out hint ContentFirst). The theme's shell files theme/shell/*.hl are never
  4. // 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.
  5. // 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
  6. // 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
  7. // user icon beside it opens the UserMenu (Log out). Nothing else stands beside the selector: no second "Log in" button (creator 2026-10-24).
  8. // THE SELECTOR: `<ident-selector key=IDENT_API_KEY>` from <ident>/selector.js, as in gitoria. Choosing an identity
  9. // fires `ident-login` (one-time code); /login.js hands it to the hidden input #identcode, whose `change` goes to the
  10. // face notesLogin (server-side exchange, lib/users.hl userOfLoginCode; no reload). The element's class is `in` / `out`; /login.js mirrors it into
  11. // the selector's `loggedIn`.
  12. // LOGIN: a plain link to <ident>/login?key=&return=<public url>/login/callback (lib/api.hl loginCallback).
  13. // After a login or logout in this tab the page is fetched again (navigate('/')): the notes of the session show.
  14. import { navigate } from 'hl:web'
  15. import { siteName } from '../project.hl'
  16. import { identKey, callbackUrl, selectorScript, userIdOfSession, userOfLoginCode } from '../lib/users.hl'
  17. import { randomBytes } from 'hl:crypto'
  18. import { messageLook } from '../lib/looks.hl'
  19. import AppHeader from '../theme/shell/app-header.hl'
  20. import MainMenu from '../theme/shell/main-menu.hl'
  21. import Sidebar from '../theme/shell/app-sidebar.hl'
  22. slot = null
  23. session = null
  24. loggedIn = userIdOfSession(session) != null
  25. loggedOut = userIdOfSession(session) == null
  26. selectorClass = loggedIn ? 'in' : 'out'
  27. selectorKey = identKey
  28. // 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`
  29. // (the callback takes it back there). No route known (first paint) = no `next` = the start page.
  30. route = null
  31. path = route == null ? '' : route.path
  32. selectorReturn = callbackUrl + (path == '' ? '' : '?next=' + encodeURIComponent(path))
  33. identScript = selectorScript
  34. loginError = ''
  35. hasLoginError = false
  36. // 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)
  37. // `current = true` STAYS (mission 015, hybriel#197): the menu now marks an item from the route, but only the page '/' itself (an item
  38. // with href '/' is not "above" other pages, by design) — on /note/:id and /login/failed the route marks nothing (server HTML checked in
  39. // tests/browser.mjs "server html …"; without current = true those two fail), and the one item is the whole app
  40. menu = [ { label = 'Notes' href = '/' current = true } ]
  41. Style {
  42. pMessage = messageLook + { }
  43. // ---- 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
  44. // 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
  45. // 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
  46. // under it, as wide as a phone allows.
  47. '#loginerror' { margin = '0' padding = '.5rem var(--layout-gutter)' background = 'var(--color-background-sunken)' }
  48. 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' }
  49. 'ident-selector::part(button)' { minHeight = 'var(--layout-tap)' padding = '.25rem .6rem' whiteSpace = 'nowrap' }
  50. 'ident-selector::part(status)' { minHeight = 'var(--layout-tap)' padding = '.25rem .6rem' whiteSpace = 'nowrap' overflow = 'hidden' textOverflow = 'ellipsis' }
  51. 'ident-selector::part(identity)' { minHeight = 'var(--layout-tap)' }
  52. '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)' }
  53. '#logout' { flex = 'none' whiteSpace = 'nowrap' padding = '.25rem .5rem' }
  54. }
  55. View {
  56. body {
  57. AppHeader { brand = siteName
  58. MainMenu { items = menu }
  59. // 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
  60. // 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).
  61. identSelector { id = "selector" key = selectorKey return = selectorReturn class = selectorClass }
  62. // signed in, like before the theme missions: Log out stands beside the selector
  63. if (loggedIn) {
  64. button { id = "logout" type = "button" class = "quiet" "Log out" on click(e) { emit doLogout(e) } }
  65. }
  66. }
  67. input { id = "identcode" type = "hidden" on change(e) { emit gotCode(e) } }
  68. if (hasLoginError) { p { id = "loginerror" Style.pMessage class = "banner" loginError } }
  69. // the phone's overlay with the main menu (desktop = "false": the header shows the menu from 60rem); the page (its own
  70. // shell: list-first for the notes, content-first for the rest) follows — hybriel#130: the page slot starts its own line
  71. Sidebar { desktop = "false" MainMenu { items = menu } }
  72. slot
  73. script { src = identScript }
  74. script { src = "/login.js" }
  75. }
  76. }
  77. showIn = () => {
  78. loggedIn = true
  79. loggedOut = false
  80. selectorClass = 'in'
  81. loginError = ''
  82. hasLoginError = false
  83. }
  84. showOut = () => {
  85. loggedIn = false
  86. loggedOut = true
  87. selectorClass = 'out'
  88. }
  89. // the selector's code (via /login.js and the hidden input) → the server exchanges it
  90. on gotCode(e) {
  91. code = e.target.value
  92. e.target.value = ''
  93. if (code == null || code == '') { return null }
  94. r = emit server notesLogin(code)
  95. if (r == null || r.error != null) {
  96. loginError = r != null ? r.error : 'the login failed'
  97. hasLoginError = true
  98. return null
  99. }
  100. showIn()
  101. navigate('/')
  102. }
  103. on client notesSignedIn(tag) {
  104. showIn()
  105. navigate('/')
  106. }
  107. on client notesSignedOut(tag) {
  108. showOut()
  109. navigate('/')
  110. }
  111. on doLogout(e) {
  112. emit server notesLogOut()
  113. showOut()
  114. navigate('/')
  115. }
  116. // ---- the faces (the trailing `session` is always the server's: hybriel #16) ----
  117. on server notesLogin(code, session) {
  118. if (session == null) { return { error = 'no session — reload the page' } }
  119. x = userOfLoginCode(code)
  120. if (x.error != null) { return { error = x.error } }
  121. tag = randomBytes(16)
  122. session.user = { id = x.user.id }
  123. session.data.tag = tag
  124. emit client notesSignedIn(tag)
  125. return { ok = true }
  126. }
  127. on server notesLogOut(session) {
  128. if (session == null) { return { error = 'no session' } }
  129. emit client notesSignedOut(session.data.tag)
  130. session.user = null
  131. session.data.tag = null
  132. return { ok = true }
  133. }

Branches

Latest commits

  • 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
  • 8762115cnotes: take the components e54f83a (paste as Markdown, text typed before the editor is built is kept, Table button); table lines come from the notes thememre
  • ac23e194ident#31: the selector's sign-in returns to the page the user started on (return attribute = the login callback with next), gate checkmre