gitoria

calendar

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitf2fcdc6df2fcdc6dcalendar: a standby container (port 45015, profile standby, reminder clock off) and a /health page; deploy hands over through standby-swap.sh without a gapmref2fcdc6d/components/main.hl

5.3 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, callbackUrl, 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. // 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`
  30. // (the callback takes it back there). No route known (first paint) = no `next` = the start page.
  31. route = null
  32. path = route == null ? '' : route.path
  33. selectorReturn = callbackUrl + (path == '' ? '' : '?next=' + encodeURIComponent(path))
  34. identScript = selectorScript
  35. loginError = ''
  36. hasLoginError = false
  37. // 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)
  38. menu = [ { label = 'Calendar' href = '/' } ]
  39. View {
  40. body {
  41. AppHeader { brand = siteName
  42. MainMenu { items = menu }
  43. // 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
  44. // 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).
  45. identSelector { id = "selector" key = selectorKey return = selectorReturn class = selectorClass }
  46. // signed in, like before the theme missions: Log out stands beside the selector (Reminder settings is on the month page)
  47. if (loggedIn) {
  48. button { id = "logout" type = "button" class = "quiet" "Log out" on click(e) { emit doLogout(e) } }
  49. }
  50. }
  51. input { id = "identcode" type = "hidden" on change(e) { emit gotCode(e) } }
  52. if (hasLoginError) { p { id = "loginerror" class = "message banner" loginError } }
  53. // the phone's overlay with the main menu (desktop = "false": the header shows the menu from 60rem); then the page in the
  54. // content-first shell — hybriel#130: the page slot starts its own line
  55. Sidebar { desktop = "false" MainMenu { items = menu } }
  56. main {
  57. ContentFirst { slot }
  58. }
  59. script { src = identScript }
  60. script { src = "/login.js" }
  61. }
  62. }
  63. showIn = () => {
  64. loggedIn = true
  65. loggedOut = false
  66. selectorClass = 'in'
  67. loginError = ''
  68. hasLoginError = false
  69. }
  70. showOut = () => {
  71. loggedIn = false
  72. loggedOut = true
  73. selectorClass = 'out'
  74. }
  75. // the selector's code (via /login.js and the hidden input) → the server exchanges it
  76. on gotCode(e) {
  77. code = e.target.value
  78. e.target.value = ''
  79. if (code == null || code == '') { return null }
  80. r = emit server calendarLogin(code)
  81. if (r == null || r.error != null) {
  82. loginError = r != null ? r.error : 'the login failed'
  83. hasLoginError = true
  84. return null
  85. }
  86. showIn()
  87. navigate('/')
  88. }
  89. on client calendarSignedIn(tag) {
  90. showIn()
  91. navigate('/')
  92. }
  93. on client calendarSignedOut(tag) {
  94. showOut()
  95. navigate('/')
  96. }
  97. on doLogout(e) {
  98. emit server calendarLogOut()
  99. showOut()
  100. navigate('/')
  101. }
  102. // ---- the faces (the trailing `session` is always the server's: hybriel #16) ----
  103. on server calendarLogin(code, session) {
  104. if (session == null) { return { error = 'no session — reload the page' } }
  105. x = userOfLoginCode(code)
  106. if (x.error != null) { return { error = x.error } }
  107. tag = randomBytes(16)
  108. session.user = { id = x.user.id }
  109. session.data.tag = tag
  110. emit client calendarSignedIn(tag)
  111. return { ok = true }
  112. }
  113. on server calendarLogOut(session) {
  114. if (session == null) { return { error = 'no session' } }
  115. emit client calendarSignedOut(session.data.tag)
  116. session.user = null
  117. return { ok = true }
  118. }

Branches

Latest commits

  • f2fcdc6dcalendar: a standby container (port 45015, profile standby, reminder clock off) and a /health page; deploy hands over through standby-swap.sh without a gapmre
  • 229643f7Merge branch 'cal-14'mre
  • 1110b26fcalendar#14: the month name no longer breaks into two lines on a phone (Reminder settings drops to its own row when the header is too narrow), gate checks for one-line title and all header controls on screenmre
  • 490c658aident#31: the selector's sign-in returns to the page the user started on (return attribute = the login callback with next), gate checkmre
  • 18095868calendar: Reminder settings button opens its dialog again (the dialog's open handler still closed the removed user menu and stopped); old e2e and gate scripts use the new headermre
  • 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