gitoriaLog in with ident

gitoria

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit090a20c6090a20c6mission 002 (code order) 2/4: one lib/ file per topic — git.hl split into git (calls, branches, init, temp folder) / homepage / code / pulls / releases (+ git-helpers: paths, ids, |||PR/|||RL markers); repos-helpers, tickets-helpers, transport-helpers; util.hl = localtime + env, storage dir, addresses, lists, text checks, one newest-first sort (was 3 copies); the function routes out of project.hl into lib/api.hl (thin; plumbing in api-helpers.hl), sshgate.hl folded into api.hl + sshkeys.hl keyLine + repos.hl mayPush; 'Make main' and the merge answer out of the faces (code.hl makeMain, pulls.hl pullsView), one login helper (users.hl userOfLoginCode); project.hl is the map. Session-writing routes get &req + &server.sessions. gates 200/0, 46/0, 44/0; real-data identical except /login/failed now shows the parked reason for a browser that already had a session (the old copy-of-req lost it)mre090a20c6/project.hl

8.4 KB

  1. // project.hl — gitoria.worldapi.org: THE MAP. Config, routes and WHO HEARS WHAT; the logic lives in lib/. Hybriel on hl:web.
  2. //
  3. // WHERE THINGS ARE (one line per feature; README.md "Files" has the full list):
  4. // repos: create, list, owner, main-branch setting, push rule lib/repos.hl (slug rules, rows, Markdown view: lib/repos-helpers.hl)
  5. // users, login through ident, display names lib/users.hl
  6. // git on the server (calls, branches, init, temp folder) lib/git.hl (paths, ids, |||PR / |||RL markers: lib/git-helpers.hl)
  7. // the repo homepage (README.md / $docs) lib/homepage.hl (Markdown → blocks: lib/markdown.hl)
  8. // browsing code (/code, /branch, /commit), "Make main" lib/code.hl
  9. // pull requests, the Merge button lib/pulls.hl
  10. // releases lib/releases.hl
  11. // a repo's tickets, connecting tickets, `#12` links both ways lib/tickets.hl (lib/tickets-helpers.hl)
  12. // push and pull over HTTPS (the git protocol's routes) lib/transport.hl (lib/transport-helpers.hl)
  13. // access tokens / ssh keys lib/tokens.hl / lib/sshkeys.hl
  14. // function routes: API, /login/callback, /settings/connect…, /__git/… lib/api.hl (plumbing: lib/api-helpers.hl)
  15. // shared helpers (env, storage dir, addresses, lists, Vienna time) lib/util.hl
  16. // pages: shell, repo list, readme, code, pulls, releases, tickets, settings, tokens, keys components/*.hl; CSS components/styles.hl
  17. //
  18. // HOW A REPO GETS ITS ADDRESS (ticket #6, gitoria#16): nginx sends `gitoria.worldapi.org` AND every
  19. // `<slug>.gitoria.worldapi.org` to this one app. Every page component that declares `host = null` gets the
  20. // request's host (without port, hybriel#74) on the SERVER, on the first load and on every hl:web navigation:
  21. // the main address shows the repo list + "create" (components/index.hl → list.hl), `<slug>.` shows that repo —
  22. // each repo view is its own page component on its own route (readme, code, branch, commit, pulls, releases,
  23. // tickets), rendered on the server WITH its content: git is read with hl:proc run(), which waits (hybriel#80).
  24. // The session cookie carries `Domain=.<host>` (hl:web `sessionDomain`, hybriel#44) so one
  25. // login holds on every address; the login button always returns through the main address
  26. // (the only origin registered in ident) and then on to the repo the login started from.
  27. import WebFramework from 'hl:web'
  28. import { env } from 'hl:proc'
  29. import Styles from './components/styles.hl'
  30. import { dark, darker } from './shared/tokens.hl'
  31. import { hostOnly, domainFor } from './lib/util.hl'
  32. import { tagOf } from './lib/users.hl'
  33. import { apiRepos, apiRepo, loginCallback, connectStart, connectBack, gitKeys, gitAccess } from './lib/api.hl'
  34. import { gitTransport } from './lib/transport.hl'
  35. import Index from './components/index.hl'
  36. import Code from './components/code.hl'
  37. import Branch from './components/branch.hl'
  38. import Commit from './components/commit.hl'
  39. import Pulls from './components/pulls.hl'
  40. import Releases from './components/releases.hl'
  41. import Tickets from './components/tickets.hl'
  42. import Settings from './components/settings.hl'
  43. import LoginFailed from './components/loginfailed.hl'
  44. static siteName = "gitoria"
  45. appTitle = siteName
  46. styles = Styles
  47. // ---- THE INSTALLABLE APP (mission 046), the same way calendar.worldapi.org and tracker do it: hl:web's own web app
  48. // manifest (/__hl/manifest.webmanifest, linked from every head with the apple-touch-icon and theme-color) and service
  49. // worker (/__hl/sw.js) from these settings — no JavaScript of ours. Icons in icons/ (icon.svg is the source, the PNGs
  50. // are rendered from it with rsvg-convert, README "PWA"). The theme colour is the header's background (darker), the
  51. // splash background the page's (dark) — both off the tokens. Every repo address is its own origin, so each one gets
  52. // its own manifest and worker (start_url / = that repo's Readme).
  53. appThemeColor = darker.value
  54. appBackgroundColor = dark.value
  55. appIcons = [
  56. { src = '/icons/icon-192.png' sizes = '192x192' purpose = 'any' }
  57. { src = '/icons/icon-512.png' sizes = '512x512' purpose = 'any' }
  58. { src = '/icons/icon-192.png' sizes = '192x192' purpose = 'maskable' }
  59. { src = '/icons/icon-512.png' sizes = '512x512' purpose = 'maskable' }
  60. ]
  61. appTouchIcon = '/icons/apple-touch-icon.png'
  62. appFavicon = '/icons/favicon.svg'
  63. // OFFLINE: only the shell and `/` (components/main.hl says "You are offline" while the browser has no network). `/`
  64. // is kept as last seen (the worker is network-first and refreshes its copy on every online visit): the repo list on
  65. // the main address, the Readme on a repo address. Every other page (code, commits, pulls, …) needs the network and
  66. // gets hl:web's "Unavailable offline" page.
  67. offline = [ Index ]
  68. // EVERY REPO VIEW IS ITS OWN PAGE (gitoria#16); `/` is the list on the main address, the Readme on a repo address.
  69. routes = [
  70. { pattern = "/favicon.ico" file = "./icons/favicon.ico" headers = { 'Cache-Control' = 'no-cache' } }
  71. // the installable app (mission 046): the icons (manifest and service worker are hl:web's own, from appIcons / offline)
  72. { pattern = "/icons/icon-192.png" file = "./icons/icon-192.png" headers = { 'Cache-Control' = 'no-cache' } }
  73. { pattern = "/icons/icon-512.png" file = "./icons/icon-512.png" headers = { 'Cache-Control' = 'no-cache' } }
  74. { pattern = "/icons/apple-touch-icon.png" file = "./icons/apple-touch-icon.png" headers = { 'Cache-Control' = 'no-cache' } }
  75. { pattern = "/icons/favicon.svg" file = "./icons/favicon.svg" headers = { 'Cache-Control' = 'no-cache' } }
  76. // the login button's return and the tickets connection write the session: the request and the store go BY REFERENCE (lib/api.hl)
  77. { pattern = "/login/callback" function = (route, req) => { return loginCallback(route, &req, &server.sessions) } }
  78. { pattern = "/login/failed" component = LoginFailed }
  79. { pattern = "/login.js" file = "./login.js" headers = { 'Cache-Control' = 'no-cache' } }
  80. { pattern = "/api/repos" function = apiRepos }
  81. { pattern = "/api/repos/:slug" function = apiRepo }
  82. { pattern = "/" component = Index }
  83. { pattern = "/code" component = Code }
  84. { pattern = "/code/*path" component = Code }
  85. { pattern = "/branch/*path" component = Branch }
  86. { pattern = "/commit/*path" component = Commit }
  87. { pattern = "/pulls" component = Pulls }
  88. { pattern = "/releases" component = Releases }
  89. { pattern = "/tickets" component = Tickets }
  90. { pattern = "/settings" component = Settings }
  91. { pattern = "/settings/connect" function = (route, req) => { return connectStart(route, &req, &server.sessions) } }
  92. { pattern = "/settings/connected" function = (route, req) => { return connectBack(route, &req, &server.sessions) } }
  93. { pattern = "/__git/keys" function = gitKeys }
  94. { pattern = "/__git/access" function = gitAccess }
  95. { pattern = "/:repo/info/refs" function = gitTransport }
  96. { pattern = "/:repo/git-upload-pack" function = gitTransport }
  97. { pattern = "/:repo/git-receive-pack" function = gitTransport }
  98. ]
  99. // WHO GETS THE PUSH: a new repo reaches every open page (the list follows live)
  100. // `gitoriaSignedIn` / `gitoriaSignedOut` go to the tabs of ONE session: the one whose login carries
  101. // that random tag (session.data.tag, set at login, users.hl tagOf) — every open page of it switches without a reload.
  102. audience = {
  103. repoCreated = (row, session) => { return true }
  104. ticketOpened = (slug, row, session) => { return true }
  105. gitoriaSignedIn = (tag, info, session) => { return tag != null && tagOf(session) == tag }
  106. gitoriaSignedOut = (tag, session) => { return tag != null && tagOf(session) == tag }
  107. }
  108. sessionDir = env('GITORIA_SESSIONS') != null ? env('GITORIA_SESSIONS') : null
  109. port = env('GITORIA_PORT') != null ? toNumber(env('GITORIA_PORT')) : 8360
  110. // HL_HOST = the interface hl:web binds (hybriel #24, fixed upstream): 127.0.0.1 on Byrodin behind nginx;
  111. // unset = 0.0.0.0 (dev on Loreana). GITORIA_WATCH=0 = no dev watcher. The session cookie is `gitoriasid` (hybriel #10).
  112. watching = env('GITORIA_WATCH') != '0'
  113. sessionCookie = 'gitoriasid'
  114. // the cookie's Domain (hybriel#44): every <slug>.<host> shares the login (util.hl domainFor; '' = host-only → null)
  115. sessionDomain = domainFor(hostOnly) != '' ? domainFor(hostOnly) : null
  116. server = new WebFramework(routes = routes, styles = styles, minify = true, port = port, watchMode = watching, sessionCookie = sessionCookie, sessionDomain = sessionDomain)
  117. on Error(e) { console.log('error absorbed: ' + e.message) }

Branches

Latest commits

  • 090a20c6mission 002 (code order) 2/4: one lib/ file per topic — git.hl split into git (calls, branches, init, temp folder) / homepage / code / pulls / releases (+ git-helpers: paths, ids, |||PR/|||RL markers); repos-helpers, tickets-helpers, transport-helpers; util.hl = localtime + env, storage dir, addresses, lists, text checks, one newest-first sort (was 3 copies); the function routes out of project.hl into lib/api.hl (thin; plumbing in api-helpers.hl), sshgate.hl folded into api.hl + sshkeys.hl keyLine + repos.hl mayPush; 'Make main' and the merge answer out of the faces (code.hl makeMain, pulls.hl pullsView), one login helper (users.hl userOfLoginCode); project.hl is the map. Session-writing routes get &req + &server.sessions. gates 200/0, 46/0, 44/0; real-data identical except /login/failed now shows the parked reason for a browser that already had a session (the old copy-of-req lost it)mre
  • 110c2799mission 002 (code order) 1/4: .hl files out of the root — lib/ (api, git, localtime, markdown, repos, sshgate, sshkeys, tickets, tokens, transport, users), components/styles.hl; jsoncheck.hl removed (imported nowhere); import paths only. gates 200/0, 46/0, 44/0; real-data reads + writes identicalmre
  • fdfb4b1bgitoria: Hybriel master 06617221 (plugin allocators 3a781359 + 413f60e4, mpackdb 2cb7ae5e, http1 773de63e); gates 200/0, 46/0, 44/0mre
  • 5b46ac84antcolony#40: LOG.md — missions 069/072 are antcolony missions (report paths on Byrodin)mre
  • 5602ff41gitoria: Hybriel master 190aa11d (fc838894 GC correctness, #127 mountKids by reference, #126, #48) — tracker README flat; gates 200/0, 46/0, 44/0mre
  • e85eaf01gitoria: 069 round 2 — hybriel 1a096ad3 not adopted (Markdown SSR still grows); browser gate waits for the server-side logout before restartmre
  • 09ce4f3fgitoria: mission 069 re-vendor hybriel 8efba065 stopped (big SSR pages grow + slow down); lambda audit clean; old vendor keptmre
  • 3dc43108antcolony#40: mission references point to the moved missionsmre
  • 8d9450fdantcolony#40: history (LOG.md), worker briefs (missions/) and reports moved here from antcolony, numbered per project; old numbers in antcolony docs/mission-map.mdmre
  • 205d5fe4gitoria: Hybriel master ff51cf46; ssh keys/tokens no double rows (session sync); gates follow #20mre
  • 9b27cb26gitoria#21: installable app (manifest, service worker, offline start page), own iconmre
  • 68dcb603deploy.sh: back up live storage/.sessions/.env before every deploy (newest 5 kept)mre
  • e2deed6dgitoria#20: "Add code" only on the Code page of an empty repository, no collapsiblemre
  • 8bb97ffddeploy.sh: never send .git or .gitignore to Byrodinmre
  • fd981932State of 2026-09-27; bin/ no longer tracked (Hybriel commit is in README)mre
  • 4a2d7125initial commitmre