gitoria

gitoria

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit53ca42b253ca42b2log: W60 merged, W61 W62 startedmre53ca42b2/components/main.hl

10.7 KB

  1. // components/main.hl — THE SHELL (gitoria#23): the WorldAPI theme's header and content-first shell (theme/shell/*, copied from
  2. // layouts.worldapi.org — never edited here, the way tracker.worldapi.org wears it) around the slot every page renders into, plus
  3. // the display-name prompt of a first login. The shell owns its Style block (the theme shells carry their own Style).
  4. // THE HEADER: phone — ☰ (the sidebar overlay with the main menu) · brand · ident's selector · the user icon far right (its dropdown:
  5. // your name, Access tokens, SSH keys, Log out); signed out the selector stands alone (no second "Log in" button — creator 2026-10-24).
  6. // From 60rem: brand · main menu · selector · user icon. IDENT'S SELECTOR STANDS IN THE HEADER, visible signed in and signed out, on the
  7. // phone and on the desktop (creator 2026-10-24: the theme move hid it behind an icon — never again; the gate checks it at 390 and 1280).
  8. // The main menu is the app's top level, on the main address: Repositories. The repo's own tabs stay in the repo head of the repo layout level (repo.hl).
  9. // THE SELECTOR (gitoria#14): `<ident-selector key=IDENT_API_KEY>` from <ident>/selector.js, as in tickets.
  10. // Choosing an identity fires `ident-login` (one-time code); /login.js hands it to the hidden input
  11. // #identcode, whose `change` goes to the face gitoriaLogin (server-side exchange, no reload). The element's
  12. // class is `in` / `out`; /login.js mirrors it into the selector's `loggedIn`. THE SAME SELECTOR STANDS ON EVERY ADDRESS: the main one and
  13. // every repo address (<repo>.<host>) — ident answers a repo address because the app's registered origins hold the wildcard origin
  14. // `https://*.<host>` (ident accepts `*.` as the first label of a registered origin). The login is the one session of the main
  15. // address and all repo addresses (the cookie's Domain, project.hl sessionDomain).
  16. // LOGIN: a plain link to <ident>/login?key=&return=<public url>/login/callback (lib/api.hl
  17. // loginCallback); /login.js adds `?next=<this page>` at the click so the login returns here.
  18. // FIRST LOGIN: no display name yet → the name prompt; creating a repo waits for it.
  19. import { siteName } from '../project.hl'
  20. import { publicUrl } from '../lib/util.hl'
  21. import { identKey, callbackUrl, selectorScript, infoOfSession, login, userInfo, setUserName, userOfSession } from '../lib/users.hl'
  22. import AppHeader from '../theme/shell/app-header.hl'
  23. import MainMenu from '../theme/shell/main-menu.hl'
  24. import Sidebar from '../theme/shell/app-sidebar.hl'
  25. import ContentFirst from '../theme/shell/content-first.hl'
  26. // the main menu: the header from 60rem, the phone's sidebar below — one list (every repo address links back to the main one)
  27. // an INSTANCE property, not `static` (gitoria#23 reopened): a static is evaluated again in the browser after an in-page navigation, where `publicUrl` (hl:proc env) has no value — the link became a 404. The instance property is filled by the server.
  28. // `current = true` STAYS (hybriel#197 checked, mission 010): the route marker needs the item href to be the page path, but this item links to the MAIN address (absolute) and every page of the app (/code, /pulls …) lies under it, so the route cannot tell; it is marked on all
  29. menu = [
  30. { label = 'Repositories' href = publicUrl + '/' current = true }
  31. ]
  32. slot = null
  33. session = null
  34. me = infoOfSession(session)
  35. loggedIn = me != null
  36. loggedOut = me == null
  37. needsName = me != null && !me.named
  38. myName = me != null && me.named ? me.name : 'you'
  39. selectorClass = me != null ? 'in' : 'out'
  40. tokensHref = publicUrl + '/#tokens'
  41. keysHref = publicUrl + '/#sshkeys'
  42. selectorKey = identKey
  43. // 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`
  44. // (the callback takes it back there). No route known (first paint) = no `next` = the start page.
  45. route = null
  46. path = route == null ? '' : route.path
  47. selectorReturn = callbackUrl + (path == '' ? '' : '?next=' + encodeURIComponent(path))
  48. identScript = selectorScript
  49. identCode = ''
  50. loginError = ''
  51. hasLoginError = false
  52. nameDraft = ''
  53. nameError = ''
  54. // OFFLINE (mission 046, as tracker.worldapi.org#10): the service worker opens `/` from its cache without a network; the
  55. // shell then says so. The vendored __hlOnline updates only the routed page, not this shell (W60 repro), so a tick asks the browser:
  56. // `netProbe` runs an endless 1 s CSS animation (styles.hl), and each `animationiteration` reads navigator.onLine — a
  57. // write only when it changed.
  58. offline = false
  59. View {
  60. body {
  61. AppHeader { brand = siteName
  62. MainMenu { items = menu }
  63. // 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
  64. // 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).
  65. identSelector { id = "selector" key = selectorKey return = selectorReturn class = selectorClass }
  66. // signed in, like before the theme missions: your name and Log out stand beside the selector (Access tokens and SSH keys are on the account pages)
  67. if (loggedIn) {
  68. span { id = "whoami" myName }
  69. button { id = "logout" type = "button" class = "quiet" "Log out" on click(e) { emit doLogout(e) } }
  70. }
  71. }
  72. input { id = "identcode" type = "hidden" value = identCode on change(e) { identCode = e.target.value emit gotCode(e) } }
  73. if (hasLoginError) { p { id = "loginerror" class = "message banner" loginError } }
  74. if (offline) { offlineNote { id = "offline" "You are offline. Repositories and code need the network." } }
  75. netProbe { "aria-hidden" = "true" on animationiteration(e) { emit netTick(e) } }
  76. if (needsName) {
  77. namePrompt {
  78. form { id = "nameform"
  79. on submit(e) {
  80. e.preventDefault()
  81. emit saveName(e)
  82. }
  83. label { "Welcome! Choose the display name others see as the owner of your repositories"
  84. input { id = "displayname" name = "displayname" required = "required" maxlength = "60" value = nameDraft on input(e) { emit setNameDraft(e.target.value) } }
  85. }
  86. button { id = "namesave" type = "submit" "Save" }
  87. p { id = "nameerror" class = "message" nameError }
  88. }
  89. }
  90. }
  91. // the phone's overlay with the main menu (desktop = "false": the header shows the menu from 60rem), then the shell with the
  92. // page — `Sidebar` + `main { ContentFirst { slot } }`, as tracker does: the page slot must start its own line (hybriel#130)
  93. Sidebar { desktop = "false" MainMenu { items = menu } }
  94. main {
  95. ContentFirst { slot }
  96. }
  97. script { src = identScript }
  98. script { src = "/login.js" }
  99. }
  100. }
  101. showMe = (info) => {
  102. loggedIn = true
  103. loggedOut = false
  104. needsName = !info.named
  105. myName = info.named ? info.name : 'you'
  106. selectorClass = 'in'
  107. loginError = ''
  108. hasLoginError = false
  109. }
  110. showOut = () => {
  111. loggedIn = false
  112. loggedOut = true
  113. needsName = false
  114. myName = 'you'
  115. selectorClass = 'out'
  116. }
  117. // the selector's code (via /login.js and the hidden input) → the server exchanges it
  118. on gotCode(e) {
  119. code = identCode
  120. identCode = ''
  121. if (code == null || code == '') { return null }
  122. r = emit server gitoriaLogin(code)
  123. if (r == null || r.error != null) {
  124. loginError = r != null ? r.error : 'the login failed'
  125. hasLoginError = true
  126. return null
  127. }
  128. showMe(r)
  129. }
  130. on client gitoriaSignedIn(tag, info) { showMe(info) }
  131. on client gitoriaSignedOut(tag) { showOut() }
  132. on setNameDraft(v) { nameDraft = v }
  133. on netTick(e) {
  134. down = window.navigator.onLine == false
  135. if (down != offline) { offline = down }
  136. }
  137. on saveName(e) {
  138. r = emit server gitoriaSaveName(nameDraft)
  139. if (r == null || r.error != null) {
  140. nameError = r != null ? r.error : 'could not save the name'
  141. return null
  142. }
  143. nameError = ''
  144. showMe(r)
  145. }
  146. on doLogout(e) {
  147. emit server gitoriaLogOut()
  148. showOut()
  149. }
  150. // ---- the faces (the trailing `session` is always the server's: hybriel #16) ----
  151. on server gitoriaLogin(code, session) {
  152. if (session == null) { return { error = 'no session — reload the page' } }
  153. x = login(code, session, null)
  154. if (x.error != null) { return { error = x.error } }
  155. emit client gitoriaSignedIn(x.tag, x.info)
  156. return x.info
  157. }
  158. on server gitoriaSaveName(name, session) {
  159. u = userOfSession(session)
  160. if (u == null) { return { error = 'log in with ident first' } }
  161. r = setUserName(u.id, name)
  162. if (r.error != null) { return { error = r.error } }
  163. info = userInfo(r.user)
  164. emit client gitoriaSignedIn(session.data.tag, info)
  165. return info
  166. }
  167. on server gitoriaLogOut(session) {
  168. if (session == null) { return { error = 'no session' } }
  169. emit client gitoriaSignedOut(session.data.tag)
  170. session.user = null
  171. return { ok = true }
  172. }
  173. Style {
  174. #whoami {
  175. marginRight = '.5rem'
  176. fontWeight = '600'
  177. color = 'var(--color-text-strong)'
  178. fontSize = '.875rem'
  179. maxWidth = '6rem'
  180. overflow = 'hidden'
  181. textOverflow = 'ellipsis'
  182. whiteSpace = 'nowrap'
  183. flex = '0 1 auto'
  184. minWidth = '0'
  185. display = 'inline-flex'
  186. alignItems = 'center'
  187. minHeight = '2.75rem'
  188. }
  189. #logout {
  190. flex = 'none'
  191. whiteSpace = 'nowrap'
  192. padding = '.25rem .5rem'
  193. }
  194. identSelector {
  195. '--ident-accent' = 'var(--color-accent)'
  196. '--ident-accent-text' = 'var(--color-accent-text)'
  197. '--ident-background' = 'var(--color-surface)'
  198. '--ident-border' = 'var(--color-surface)'
  199. '--ident-font' = '600 .9rem/1.3 system-ui, sans-serif'
  200. position = 'relative'
  201. flex = '0 1 auto'
  202. minWidth = '0'
  203. }
  204. 'ident-selector::part(button)' {
  205. minHeight = '2.75rem'
  206. padding = '.25rem .6rem'
  207. border = 'none'
  208. whiteSpace = 'nowrap'
  209. }
  210. 'ident-selector::part(status)' {
  211. minHeight = '2.75rem'
  212. padding = '.25rem .6rem'
  213. border = 'none'
  214. whiteSpace = 'nowrap'
  215. overflow = 'hidden'
  216. textOverflow = 'ellipsis'
  217. }
  218. 'ident-selector::part(identity)' {
  219. minHeight = '2.75rem'
  220. border = 'none'
  221. }
  222. 'ident-selector::part(panel)' {
  223. position = 'absolute'
  224. top = '100%'
  225. right = '0'
  226. zIndex = '30'
  227. width = 'min(20rem, calc(100vw - 2 * var(--layout-gutter)))'
  228. maxWidth = 'none'
  229. border = 'none'
  230. boxShadow = '0 .75rem 2rem ' + 'var(--color-background-sunken)'
  231. }
  232. #loginerror {
  233. margin = '0'
  234. padding = '.5rem var(--layout-gutter)'
  235. background = 'var(--color-background-sunken)'
  236. }
  237. namePrompt {
  238. display = 'block'
  239. paddingInline = 'max(var(--layout-gutter), calc((100% - var(--layout-column)) / 2))'
  240. paddingTop = '1rem'
  241. form {
  242. display = 'grid'
  243. gap = '.6rem'
  244. padding = '1rem'
  245. background = 'var(--color-surface)'
  246. borderRadius = 'var(--radius-large)'
  247. '> *' {
  248. margin = '0'
  249. }
  250. }
  251. }
  252. offlineNote {
  253. display = 'block'
  254. padding = '.5rem var(--layout-gutter)'
  255. color = 'var(--color-text-strong)'
  256. background = 'var(--color-surface)'
  257. }
  258. netProbe {
  259. position = 'fixed'
  260. left = '0'
  261. top = '0'
  262. width = '1px'
  263. height = '1px'
  264. opacity = '0'
  265. pointerEvents = 'none'
  266. animation = 'gitoria-net-tick 1s linear infinite'
  267. }
  268. '@keyframes gitoria-net-tick' {
  269. 'from' {
  270. opacity = '0'
  271. }
  272. to {
  273. opacity = '0'
  274. }
  275. }
  276. }

Branches

Latest commits

  • 53ca42b2log: W60 merged, W61 W62 startedmre
  • 80870a33mission W61: style passmre
  • 560fd208Merge W60: helpers, bound forms, login in topics, two form fixes (gitoria#28 #32 #33)mre
  • ac5ba6a4log: W60, #25 measuredmre
  • 220f6342W60: record corrected form proof, full AE and remaining gapsmre
  • 7e31cac5gitoria#28: restrict reply form layout to reply formsmre
  • ae373cfdgitoria#28: keep each reply draft in its thread componentmre
  • eeeebd5agitoria: insert a newly created organization oncemre
  • 34d2d5cagitoria: clear the bound public-key textarea after creationmre
  • 119e54c0W60: restore conductor-owned tracking filesmre
  • 24b479e7W60: record final gates, Chrome failures and AE evidencemre
  • 5e11184cW60: record partial validation, framework gaps and cleanupmre
  • 20fe13fagitoria#33: centralize login and tickets connection statemre
  • 859754c0gitoria#29: retain the offline note and record the framework gapmre
  • d140bc04gitoria#30: reproduce the upsert ordering constraintmre
  • 6960e8f8gitoria#28: keep form values in bound component membersmre
  • 0db27200gitoria#32: share character checks and environment lookupmre
  • 452f6a1amission W60: logic clean-upsmre
  • 1448c899log: cleanup, #49 GPTBot, tracker mentions on #36mre
  • fcf95936log: v1.5.1 provenmre