gitoria

ident

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit147744bf147744bftests/migration: the fixture app origin follows MIGRATION_GATE_TESTAPP_PORT (oldstore-009 OLD_TESTAPP)mre147744bf/components/main.hl

4.0 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 { siteName } from '../project.hl'
  4. import { accountOfSession } from '../lib/accounts.hl'
  5. import AppHeader from '../theme/shell/app-header.hl'
  6. import MainMenu from '../theme/shell/main-menu.hl'
  7. import UserMenu from '../theme/shell/user-menu.hl'
  8. import Sidebar from '../theme/shell/app-sidebar.hl'
  9. import ContentFirst from '../theme/shell/content-first.hl'
  10. slot = null
  11. // OFFLINE (mission 046): true while the shell's probe cannot reach ident (the note under the header says so)
  12. noNetwork = false
  13. // the main menu marks the current page from the route (hybriel#197, in the server's HTML too): `route = null` is the declaration,
  14. // MainMenu reads {path, params, pattern} itself — no `current` is passed
  15. route = null
  16. session = null
  17. shellEmail = accountOfSession(session) != null ? accountOfSession(session).email : ''
  18. shellIn = shellEmail != ''
  19. // the main menu: the header from 60rem, the phone's sidebar below — one list (signed in only: every page needs the account)
  20. static menu = [ { label = 'Identities' href = '/' } { label = 'Inbox' href = '/inbox' } { label = 'Apps' href = '/apps' } ]
  21. // THE SHELL (mission 012, phone first on the WorldAPI theme): ContentFirst for every page — ident has no list/detail
  22. // structure; a sign-in page is just the centred column without a sidebar. Signed in: theme AppHeader (brand · main menu ·
  23. // user menu) + the phone's Sidebar (☰ → the main menu). Signed out: the brand only (the page is the sign-in).
  24. View {
  25. body {
  26. AppHeader { brand = siteName
  27. if (shellIn) { MainMenu { items = menu } }
  28. if (shellIn) {
  29. UserMenu {
  30. p { id = "whoami" class = "who" shellEmail }
  31. button { id = "menusignout" type = "button" "Sign out" on click(e) { emit shellSignOut(e) } }
  32. }
  33. }
  34. }
  35. if (noNetwork) { offlineNote { id = "offline" "Offline — ident needs the network to sign in and to save" } }
  36. // THE NETWORK PROBE: a CSS animation (components/styles.hl `ident-net-probe`) starts half a second
  37. // after the page is up and repeats every 20 s; each start and repeat asks /api/online.
  38. // A View has no "mounted" event, and a probe that fired before the page is hydrated
  39. // would be lost, so the delayed animation is the trigger. No JavaScript of ours.
  40. netProbe { on animationstart(e) { emit probe(e) } on animationiteration(e) { emit probe(e) } }
  41. if (shellIn) { Sidebar { desktop = "false" MainMenu { items = menu } } }
  42. // `Sidebar` + `main { ContentFirst { slot } }` (hybriel#130: the page slot must start its own line)
  43. main {
  44. ContentFirst { slot }
  45. }
  46. script { src = "/avatar.js" }
  47. }
  48. }
  49. // a page's in-place sign-in / sign-out (home.hl verify, doSignOut, doSignOutAll): its emit reaches this shell (hybriel#193),
  50. // so the user menu follows at once, no reload
  51. on shellSession(email) {
  52. shellEmail = email
  53. shellIn = email != ''
  54. }
  55. // the user menu's Sign out: the session forgets the account, the page reloads into the sign-in
  56. on shellSignOut(e) {
  57. emit server shellSignOutNow()
  58. window.location.assign('/')
  59. }
  60. on server shellSignOutNow(session) {
  61. if (session != null) { session.user = null }
  62. return true
  63. }
  64. // the probe: no answer (or not ident's 204) = offline; the next repeat clears it again.
  65. // On `/start` (the installed app's start page, start.hl) an answer means: go on to `/`.
  66. on probe(e) {
  67. r = window.__hlAttempt(() => { return fetch('/api/online', { cache = 'no-store' }) })
  68. noNetwork = !r.ok || r.value.status != 204
  69. if (!noNetwork && window.location.pathname == '/start') { window.location.replace('/') }
  70. }
  71. // "SIGN OUT EVERYWHERE" from another device or tab (home.hl signOutAll): the server pushes
  72. // this to every open page of the account (project.hl audience), which reloads into the
  73. // signed-out state at once — no click needed.
  74. on client signedOutAll(accountId) {
  75. // the page that asked for it has already set the shell signed out (home.hl doSignOutAll) and shows its notice: no reload
  76. if (shellEmail != '') { window.location.reload() }
  77. }

Branches

Latest commits

  • 147744bftests/migration: the fixture app origin follows MIGRATION_GATE_TESTAPP_PORT (oldstore-009 OLD_TESTAPP)mre
  • 48cd36bctests/migration: ports from env (MIGRATION_GATE_PORT, MIGRATION_GATE_TESTAPP_PORT); 8395/8396 were taken by a foreign servermre
  • 3d9b2fd8docker-compose: nofile 65536 (Hybriel int 6+ boot opened >1024 files in the tracker)mre
  • 19b7e3c3deploy: backup copies index files first and *.mpack data last (hot-copy skew, hybriel #203)mre
  • c8a596f4re-vendor Hybriel 66c3db71 (web batch 4); e2e: main menu marked after in-place sign-in is a normal check; report 014mre
  • 8f3dc1ectests: delivery allow-list for the stopped server's network errors uses the gate port, not 8700mre
  • 9cc8eddftests: notify and iplimit gate Chrome ports from env (NOTIFY_GATE_CHROME, IPLIMIT_GATE_CHROME_A/B)mre
  • d6da2d02tests: delivery and migration gate ports from env (DELIVERY_GATE_PORT, DELIVERY_GATE_CHROME, MIGRATION_GATE_CHROME) — hard-coded 8700-8719 collided with a worker during deploymre
  • 7276a008ident mission 013: re-vendor Hybriel master f9614007 (#200, #202 mpackdb copy fix); gates and e2e rerunmre
  • e13e30c3ident mission 013: report, mission, repro, LOGmre
  • eff734f3ident mission 013: in-place sign-out also closes the code step (no leftover code form); checksmre
  • b7a61546ident mission 013: e2e — in-place main-menu mark kept as a known gapmre
  • 59b43d81ident mission 013: sign out everywhere keeps this browser's own (signed-out) session so the page goes on in placemre
  • 716e14ffident mission 013: browser gate — Bob signs out everywhere (no second code request)mre
  • 5885f1c9ident mission 013 step 2: stopgap reload removed (in-place sign-in/out reach the shell via emit, notices back, route-marked main menu), gates updatedmre
  • 734ac0a9ident mission 013 step 1: re-vendor Hybriel ce6f2e0a (plugins whole; bin/ is git-ignored)mre
  • b37875ccident mission 012 part 3: real-Chrome fixes (brand 44 px, identity form width), e2e walk, report, logmre
  • f989c2ebident mission 012: stopgap reload after in-place sign-in/sign-out (until hybriel#193), gates wait for cold start, welcome end reloadsmre
  • 443291d4ident mission 012: /start on its own shell (no account), browser gate 152/0, reportmre
  • 021dd0fcident mission 012: browser gate waits cold start (IDENT_COLD_MS), header selectors, e2e checks; shell events from a page do not reach it (probe), current not marked, account-bar link 44 pxmre