gitoria

ident

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit07d1717c07d1717c|||PR ident#40 home.hl is split into components, one per area: email step, identity form, identity list, app identity choice, time zone; each moves its faces with it, the email step is shared with embed.hl (#40.3, rest of #40.2)mre07d1717c/components/main.hl

6.6 KB

  1. // components/main.hl — THE SHELL: the application header and the slot the page renders
  2. // into. All CSS is in components/styles.hl.
  3. import { navigate } from 'hl:web'
  4. import { siteName } from '../project.hl'
  5. import { accountOfSession, signOutEverywhere } from '../lib/accounts.hl'
  6. import AppHeader from '../theme/shell/app-header.hl'
  7. import MainMenu from '../theme/shell/main-menu.hl'
  8. import UserMenu from '../theme/shell/user-menu.hl'
  9. import Sidebar from '../theme/shell/app-sidebar.hl'
  10. import ContentFirst from '../theme/shell/content-first.hl'
  11. slot = null
  12. // OFFLINE (mission 046): true while the shell's probe cannot reach ident (the note under the header says so)
  13. noNetwork = false
  14. // the main menu marks the current page from the route (hybriel#197, in the server's HTML too): `route = null` is the declaration,
  15. // MainMenu reads {path, params, pattern} itself — no `current` is passed
  16. route = null
  17. session = null
  18. // `/start` (start.hl, the page the service worker keeps offline) is this same shell with the account part switched off: it must
  19. // never read or ship the account, so `startPage` keeps the session unread and the menu, bell, user menu and avatar.js out of it.
  20. startPage = route != null && route.path == '/start'
  21. accountPage = !startPage
  22. shellEmail = startPage ? '' : accountOfSession(&session) != null ? accountOfSession(&session).email : ''
  23. shellIn = shellEmail != ''
  24. // the main menu: the header from 60rem, the phone's sidebar below — one list (signed in only: every page needs the account)
  25. static menu = [ { label = 'Identities' href = '/' } { label = 'Inbox' href = '/inbox' } { label = 'Apps' href = '/apps' } { label = 'Access' href = '/access' } { label = 'Docs' href = '/docs' } ]
  26. Style {
  27. inboxBell { display = 'block' flex = 'none'
  28. a { display = 'flex' alignItems = 'center' justifyContent = 'center' width = 'var(--layout-tap)' height = 'var(--layout-tap)' color = 'var(--color-text)'
  29. hover { color = 'var(--color-accent)' textDecoration = 'none' }
  30. svg { width = '1.5rem' height = '1.5rem' }
  31. }
  32. }
  33. }
  34. // THE SHELL (mission 012, phone first on the WorldAPI theme): ContentFirst for every page — ident has no list/detail
  35. // structure; a sign-in page is just the centred column without a sidebar. Signed in: theme AppHeader (brand · main menu ·
  36. // user menu) + the phone's Sidebar (☰ → the main menu). Signed out: the brand only (the page is the sign-in).
  37. View {
  38. body {
  39. AppHeader { brand = siteName
  40. if (shellIn) { MainMenu { items = menu } }
  41. // the inbox shortcut of the approved screens (ident#27 mockups showed a coloured bell emoji; he asked for our monochrome icon style):
  42. // the same outline as the header's other icons (24 grid, currentColor, 1.8 stroke, round caps)
  43. if (shellIn) {
  44. inboxBell {
  45. a { class = "inboxlink" href = "/inbox" title = "Inbox" 'aria-label' = "Inbox"
  46. svg { viewBox = "0 0 24 24" fill = "none" stroke = "currentColor" 'stroke-width' = "1.8" 'stroke-linecap' = "round" 'stroke-linejoin' = "round" 'aria-hidden' = "true"
  47. path { d = "M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9" }
  48. path { d = "M10.3 21a1.94 1.94 0 0 0 3.4 0" }
  49. }
  50. }
  51. }
  52. }
  53. if (shellIn) {
  54. UserMenu {
  55. p { id = "whoami" class = "who" shellEmail }
  56. button { id = "menusignout" type = "button" "Sign out" on click(e) { emit shellSignOut(e) } }
  57. button { id = "menusignoutall" type = "button" "Sign out everywhere" on click(e) { emit shellSignOutAll(e) } }
  58. }
  59. }
  60. }
  61. if (noNetwork) { offlineNote { id = "offline" "Offline — ident needs the network to sign in and to save" } }
  62. // THE NETWORK PROBE: a CSS animation (components/styles.hl `ident-net-probe`) starts half a second
  63. // after the page is up and repeats every 20 s; each start and repeat asks /api/online.
  64. // A View has no "mounted" event, and a probe that fired before the page is hydrated
  65. // would be lost, so the delayed animation is the trigger. No JavaScript of ours.
  66. netProbe { on animationstart(e) { emit probe(e) } on animationiteration(e) { emit probe(e) } }
  67. if (shellIn) { Sidebar { desktop = "false" MainMenu { items = menu } } }
  68. // `Sidebar` + `main { ContentFirst { slot } }` (hybriel#130: the page slot must start its own line)
  69. main {
  70. ContentFirst { slot }
  71. }
  72. if (accountPage) { script { src = "/avatar.js" } }
  73. }
  74. }
  75. // a page's in-place sign-in (home.hl verify): its emit reaches this shell (hybriel#193), so the user menu follows at once, no reload
  76. on shellSession(email) {
  77. shellEmail = email
  78. shellIn = email != ''
  79. }
  80. // the user menu's Sign out: the session forgets the account, the page reloads into the sign-in
  81. on shellSignOut(e) {
  82. r = emit server shellSignOutNow()
  83. navigate('/')
  84. }
  85. on server shellSignOutNow(session) {
  86. if (session != null) { session.user = null }
  87. return true
  88. }
  89. // the user menu's Sign out everywhere (the home page has no sign-out buttons of its own any more): every device is signed out
  90. // (the audience pushes `signedOutAll` to the other open pages), this browser's session too; then the sign-in form
  91. on shellSignOutAll(e) {
  92. if (!confirm('Sign out of ident on every device?')) { return null }
  93. r = emit server shellSignOutAllNow()
  94. if (r != null && r.error == null) { navigate('/') }
  95. }
  96. on server shellSignOutAllNow(session) {
  97. me = accountOfSession(&session)
  98. if (me == null) { return { error = 'you are not signed in' } }
  99. emit client signedOutAll(me.id)
  100. session.user = null
  101. return signOutEverywhere(me.id)
  102. }
  103. // the probe: no answer (or not ident's 204) = offline; the next repeat clears it again.
  104. // On `/start` (the installed app's start page, start.hl) an answer means: go on to `/`.
  105. on probe(e) {
  106. r = window.__hlAttempt(() => { return fetch('/api/online', { cache = 'no-store' }) })
  107. noNetwork = !r.ok || r.value.status != 204
  108. if (!noNetwork && route.path == '/start') {
  109. // the shell stays mounted when `/start` goes on to `/` (navigate): only now, online, it learns the account — never in `/start`'s own HTML
  110. email = emit server shellAccountNow()
  111. shellEmail = email
  112. shellIn = email != ''
  113. startPage = false
  114. accountPage = true
  115. navigate('/', replace = true)
  116. }
  117. }
  118. on server shellAccountNow(session) {
  119. me = accountOfSession(&session)
  120. return me != null ? me.email : ''
  121. }
  122. // "SIGN OUT EVERYWHERE" from another device or tab (home.hl signOutAll): the server pushes
  123. // this to every open page of the account (project.hl audience), which reloads into the
  124. // signed-out state at once — no click needed.
  125. on client signedOutAll(accountId) {
  126. // the page that asked for it (the user menu's own sign-out, above) has already left for the sign-in: nothing to reload there
  127. if (shellEmail != '') {
  128. shellEmail = ''
  129. shellIn = false
  130. navigate(route.path, replace = true)
  131. }
  132. }

Branches

Latest commits

  • 07d1717c|||PR ident#40 home.hl is split into components, one per area: email step, identity form, identity list, app identity choice, time zone; each moves its faces with it, the email step is shared with embed.hl (#40.3, rest of #40.2)mre
  • 59e8fcc1ident#40.3: the app's identity choice is one component (components/chooseidentity.hl); its face chooseIdentity moves with itmre
  • e23efdfcident#40.3: the identity list is one component (components/identitylist.hl); its delete and face dropIdentity move with itmre
  • e24b59a6ident#40.3: the time zone is one component (components/timezone.hl); its face changeTimeZone moves with itmre
  • 8cbc5717ident#40.3: the email step is one component (components/emailstep.hl) placed by home.hl and embed.hlmre
  • 6fad3bd2Merge branch 'f3-codestep' into mainIdent
  • 51e387f2|||PR ident#40 the code step is one component (components/codestep.hl) placed by home.hl and embed.hl; its verify face, setCode, browserZone and verify call exist once (#40.2)mre
  • c28bddeeMerge branch 'f2-shell' into mainIdent
  • c3a40ff6|||PR ident#40 one shell for the app and /start (account part off on /start, #40.1); startshell.hl removed; unused signOut faces gone (#40.4)mre
  • 060f3870ident#40.4: use the shell sign-out faces in regression gatesmre
  • 9b94aa6aMerge branch 'f1b-cleanup' into mainIdent
  • edcfce3f|||PR ident#41 ident#43 ident#44 login error page as a component (same status codes and text, pixel-identical), declarations and route wiring cleaned upmre
  • 3ac85995ident#43 ident#44: plain declarations for never-reassigned lets, one envString helper, named route functions and audience rule out of project.hlmre
  • c7eef14aMerge branch 'nv1-navigate' into mainIdent
  • 644f9775|||PR ident#36 navigate() instead of window.location in the shell, start shell and homemre
  • 4ca2f921deploy.sh: tar --hard-dereference so backups hold no hard linksmre
  • 23971fb7ident#49: media queries in the language's @media formmre
  • 73f4f97dident: re-vendor to hybriel day38b (mpackdb store-open fix)mre
  • aa056c03ident: a startup error prints its message before exit 1 (hybriel#247)mre
  • ee37a861ident#G48: gitoria's registration gets the wildcard origin of its repo addresses at load (gate tests/gitoria-origin.mjs)mre