gitoria

notes

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit4dc982824dc98282notes#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 codemre4dc98282/components/main.hl

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

Branches

Latest commits

  • 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
  • 2804f0d3Merge branch 'iw-ident-widget'mre
  • 52d8d242notes: e2e script checks Log out and the selector in the header instead of the user menumre