gitoria

calendar

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit6eee4b5a6eee4b5acalendar header: the selector alone top right plus Log out as before the theme missions; Reminder settings back on the month page (WIP: the settings test still fails)mre6eee4b5a/components/main.hl

4.9 KB

  1. // components/main.hl — THE SHELL (mission 006, 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 pages render
  3. // in the theme's ContentFirst shell (a month is one big content area, no list beside it; ContentFirst without a desktop sidebar
  4. // gives it the whole 72rem column). The theme's shell files theme/shell/*.hl are never
  5. // edited here. App CSS is in components/styles.hl.
  6. // 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
  7. // 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
  8. // user icon beside it opens the UserMenu (Log out, Reminder settings). Nothing else stands beside the selector: no second "Log in" button (creator 2026-10-24).
  9. // THE SELECTOR: `<ident-selector key=IDENT_API_KEY>` from <ident>/selector.js, as in gitoria. Choosing an identity
  10. // fires `ident-login` (one-time code); /login.js hands it to the hidden input #identcode, whose `change` goes to the
  11. // face calendarLogin (server-side exchange, lib/users.hl userOfLoginCode; no reload). The element's class is `in` / `out`; /login.js mirrors it into
  12. // the selector's `loggedIn`.
  13. // LOGIN: a plain link to <ident>/login?key=&return=<public url>/login/callback (lib/api.hl loginCallback).
  14. // After a login or logout in this tab the page is fetched again (navigate('/')): the calendar of the session show.
  15. import { navigate } from 'hl:web'
  16. import { siteName } from '../project.hl'
  17. import { identKey, selectorScript, userIdOfSession, userOfLoginCode } from '../lib/users.hl'
  18. import { randomBytes } from 'hl:crypto'
  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. import ContentFirst from '../theme/shell/content-first.hl'
  23. slot = null
  24. session = null
  25. loggedIn = userIdOfSession(session) != null
  26. loggedOut = userIdOfSession(session) == null
  27. selectorClass = loggedIn ? 'in' : 'out'
  28. selectorKey = identKey
  29. identScript = selectorScript
  30. loginError = ''
  31. hasLoginError = false
  32. // 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)
  33. menu = [ { label = 'Calendar' href = '/' } ]
  34. View {
  35. body {
  36. AppHeader { brand = siteName
  37. MainMenu { items = menu }
  38. // 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
  39. // 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).
  40. identSelector { id = "selector" key = selectorKey class = selectorClass }
  41. // signed in, like before the theme missions: Log out stands beside the selector (Reminder settings is on the month page)
  42. if (loggedIn) {
  43. button { id = "logout" type = "button" class = "quiet" "Log out" on click(e) { emit doLogout(e) } }
  44. }
  45. }
  46. input { id = "identcode" type = "hidden" on change(e) { emit gotCode(e) } }
  47. if (hasLoginError) { p { id = "loginerror" class = "message banner" loginError } }
  48. // the phone's overlay with the main menu (desktop = "false": the header shows the menu from 60rem); then the page in the
  49. // content-first shell — hybriel#130: the page slot starts its own line
  50. Sidebar { desktop = "false" MainMenu { items = menu } }
  51. main {
  52. ContentFirst { slot }
  53. }
  54. script { src = identScript }
  55. script { src = "/login.js" }
  56. }
  57. }
  58. showIn = () => {
  59. loggedIn = true
  60. loggedOut = false
  61. selectorClass = 'in'
  62. loginError = ''
  63. hasLoginError = false
  64. }
  65. showOut = () => {
  66. loggedIn = false
  67. loggedOut = true
  68. selectorClass = 'out'
  69. }
  70. // the selector's code (via /login.js and the hidden input) → the server exchanges it
  71. on gotCode(e) {
  72. code = e.target.value
  73. e.target.value = ''
  74. if (code == null || code == '') { return null }
  75. r = emit server calendarLogin(code)
  76. if (r == null || r.error != null) {
  77. loginError = r != null ? r.error : 'the login failed'
  78. hasLoginError = true
  79. return null
  80. }
  81. showIn()
  82. navigate('/')
  83. }
  84. on client calendarSignedIn(tag) {
  85. showIn()
  86. navigate('/')
  87. }
  88. on client calendarSignedOut(tag) {
  89. showOut()
  90. navigate('/')
  91. }
  92. on doLogout(e) {
  93. emit server calendarLogOut()
  94. showOut()
  95. navigate('/')
  96. }
  97. // ---- the faces (the trailing `session` is always the server's: hybriel #16) ----
  98. on server calendarLogin(code, session) {
  99. if (session == null) { return { error = 'no session — reload the page' } }
  100. x = userOfLoginCode(code)
  101. if (x.error != null) { return { error = x.error } }
  102. tag = randomBytes(16)
  103. session.user = { id = x.user.id }
  104. session.data.tag = tag
  105. emit client calendarSignedIn(tag)
  106. return { ok = true }
  107. }
  108. on server calendarLogOut(session) {
  109. if (session == null) { return { error = 'no session' } }
  110. emit client calendarSignedOut(session.data.tag)
  111. session.user = null
  112. return { ok = true }
  113. }

Branches

Latest commits

  • 6eee4b5acalendar header: the selector alone top right plus Log out as before the theme missions; Reminder settings back on the month page (WIP: the settings test still fails)mre
  • 0b909decident selector back in the header (creator 2026-10-24): selector top right signed in and out on phone and desktop, no second Log in button, new gate checks (WIP: gates not re-run after the last edits)mre
  • 0c8f9364Merge branch 'sy-sync'mre
  • 9fab1c8fsync components.hybriel 4922f9c into the month view: prev / next 44 px targets, names formatted in UTC (a UTC+12 zone showed the wrong first weekday); the calendar keeps its own language handling (Accept-Language / browser) and the P1/C13 reminder code; gate: 44 px check (SY)mre
  • 27d3e294theme: sync from layouts 4994037 (list rows stack, td word-keep, heading code, edited tap target)mre
  • 2ac9c1bbdeploy: security gate (tests/security.mjs)mre
  • 6b0a2571merge sc-sec (calendar security) with 99-year sessionsmre
  • 92001e52sessions last 99 years (creator 2026-10-23: logins never expire; only sign out ends them)mre
  • 0f76c99dSecurity audit SC: push endpoint SSRF guard, uploadMax 0, Secure cookie, login session rotation + rate limit, event cap, nosniff, security gatemre
  • 2dd53dccP1: one reminder shows once: arm() one at a time, the page skips reminders the server already pushed; push-twice gatemre
  • 3a29760aC13 report (handoff)mre
  • 33ab66ffCalendar: notification controls move from the month view into Reminder settings (user menu), one consistent state, state read when the dialog opensmre
  • 682a5b43reports: calendar gate countsmre
  • 876d22b2reports/H1-hydrate.mdmre
  • ef0cae45tests/dst.mjs: wait for hydration instead of a fixed 2.5 s sleep before clicking #gomre
  • d9cadecatests/cdp.mjs: HL_CPU_THROTTLE=<rate> optional CPU throttling for gate runsmre
  • efa61227re-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
  • 7808adbecalendar#12: report 011, LOG, STATUS, push-shots-testmre
  • df2e4fa0calendar#12: test push rate limit (1 per 30 s per device), owner-only gate checksmre
  • acb957cfcalendar#12: Send a test notification on a subscribed device (one push in ~10 s, owner's own device), push gate part 4mre