gitoria

gitoria

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit9da65b429da65b42tests/browser.mjs: 404 checks (host, no hydration wait)MG9da65b42/project.hl

9.1 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, scheme } from './lib/util.hl'
  32. import { tagOf } from './lib/users.hl'
  33. import { notFoundPage, notFoundApi, 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. import NotFound from './components/notfound.hl'
  45. static siteName = "gitoria"
  46. appTitle = siteName
  47. styles = Styles
  48. // ---- THE INSTALLABLE APP (mission 046), the same way calendar.worldapi.org and tracker do it: hl:web's own web app
  49. // manifest (/__hl/manifest.webmanifest, linked from every head with the apple-touch-icon and theme-color) and service
  50. // worker (/__hl/sw.js) from these settings — no JavaScript of ours. Icons in icons/ (icon.svg is the source, the PNGs
  51. // are rendered from it with rsvg-convert, README "PWA"). The theme colour is the header's background (darker), the
  52. // splash background the page's (dark) — both off the tokens. Every repo address is its own origin, so each one gets
  53. // its own manifest and worker (start_url / = that repo's Readme).
  54. appThemeColor = darker.value
  55. appBackgroundColor = dark.value
  56. appIcons = [
  57. { src = '/icons/icon-192.png' sizes = '192x192' purpose = 'any' }
  58. { src = '/icons/icon-512.png' sizes = '512x512' purpose = 'any' }
  59. { src = '/icons/icon-192.png' sizes = '192x192' purpose = 'maskable' }
  60. { src = '/icons/icon-512.png' sizes = '512x512' purpose = 'maskable' }
  61. ]
  62. appTouchIcon = '/icons/apple-touch-icon.png'
  63. appFavicon = '/icons/favicon.svg'
  64. // OFFLINE: only the shell and `/` (components/main.hl says "You are offline" while the browser has no network). `/`
  65. // is kept as last seen (the worker is network-first and refreshes its copy on every online visit): the repo list on
  66. // the main address, the Readme on a repo address. Every other page (code, commits, pulls, …) needs the network and
  67. // gets hl:web's "Unavailable offline" page.
  68. offline = [ Index ]
  69. // EVERY REPO VIEW IS ITS OWN PAGE (gitoria#16); `/` is the list on the main address, the Readme on a repo address.
  70. routes = [
  71. { pattern = "/favicon.ico" file = "./icons/favicon.ico" headers = { 'Cache-Control' = 'no-cache' } }
  72. // the installable app (mission 046): the icons (manifest and service worker are hl:web's own, from appIcons / offline)
  73. { pattern = "/icons/icon-192.png" file = "./icons/icon-192.png" headers = { 'Cache-Control' = 'no-cache' } }
  74. { pattern = "/icons/icon-512.png" file = "./icons/icon-512.png" headers = { 'Cache-Control' = 'no-cache' } }
  75. { pattern = "/icons/apple-touch-icon.png" file = "./icons/apple-touch-icon.png" headers = { 'Cache-Control' = 'no-cache' } }
  76. { pattern = "/icons/favicon.svg" file = "./icons/favicon.svg" headers = { 'Cache-Control' = 'no-cache' } }
  77. // the login button's return and the tickets connection write the session: the request and the store go BY REFERENCE (lib/api.hl)
  78. { pattern = "/login/callback" function = (route, req) => { return loginCallback(route, &req, &server.sessions) } }
  79. { pattern = "/login/failed" component = LoginFailed }
  80. { pattern = "/login.js" file = "./login.js" headers = { 'Cache-Control' = 'no-cache' } }
  81. { pattern = "/api/repos" function = apiRepos }
  82. { pattern = "/api/repos/:slug" function = apiRepo }
  83. { pattern = "/" component = Index }
  84. { pattern = "/code" component = Code }
  85. { pattern = "/code/*path" component = Code }
  86. { pattern = "/branch/*path" component = Branch }
  87. { pattern = "/commit/*path" component = Commit }
  88. { pattern = "/pulls" component = Pulls }
  89. { pattern = "/releases" component = Releases }
  90. { pattern = "/tickets" component = Tickets }
  91. { pattern = "/settings" component = Settings }
  92. { pattern = "/settings/connect" function = (route, req) => { return connectStart(route, &req, &server.sessions) } }
  93. { pattern = "/settings/connected" function = (route, req) => { return connectBack(route, &req, &server.sessions) } }
  94. { pattern = "/__git/keys" function = gitKeys }
  95. { pattern = "/__git/access" function = gitAccess }
  96. { pattern = "/:repo/info/refs" function = gitTransport }
  97. { pattern = "/:repo/git-upload-pack" function = gitTransport }
  98. { pattern = "/:repo/git-receive-pack" function = gitTransport }
  99. // THE LAST ROUTES: any other path → the shell's 404 page (the API: a JSON 404)
  100. { pattern = "/api/*" function = notFoundApi }
  101. { pattern = "/*" function = (route, req) => { return notFoundPage(route, req, &server, NotFound) } }
  102. ]
  103. // WHO GETS THE PUSH: a new repo reaches every open page (the list follows live)
  104. // `gitoriaSignedIn` / `gitoriaSignedOut` go to the tabs of ONE session: the one whose login carries
  105. // that random tag (session.data.tag, set at login, users.hl tagOf) — every open page of it switches without a reload.
  106. audience = {
  107. repoCreated = (row, session) => { return true }
  108. ticketOpened = (slug, row, session) => { return true }
  109. gitoriaSignedIn = (tag, info, session) => { return tag != null && tagOf(session) == tag }
  110. gitoriaSignedOut = (tag, session) => { return tag != null && tagOf(session) == tag }
  111. }
  112. sessionDir = env('GITORIA_SESSIONS') != null ? env('GITORIA_SESSIONS') : null
  113. port = env('GITORIA_PORT') != null ? toNumber(env('GITORIA_PORT')) : 8360
  114. // HL_HOST = the interface hl:web binds (hybriel #24, fixed upstream): 127.0.0.1 on Byrodin behind nginx;
  115. // unset = 0.0.0.0 (dev on Loreana). GITORIA_WATCH=0 = no dev watcher. The session cookie is `gitoriasid` (hybriel #10).
  116. watching = env('GITORIA_WATCH') != '0'
  117. sessionCookie = 'gitoriasid'
  118. // the cookie's Domain (hybriel#44): every <slug>.<host> shares the login (util.hl domainFor; '' = host-only → null)
  119. sessionDomain = domainFor(hostOnly) != '' ? domainFor(hostOnly) : null
  120. // SECURITY (mission SG): the session cookie is `Secure` when the public address is https (the proxy speaks http to us, so the app says so);
  121. // no face of ours takes a file, so /__hl/upload (open to anyone, held in memory) refuses every file with a size (uploadMax = 0)
  122. sessionSecure = scheme == 'https'
  123. uploadMax = 0
  124. server = new WebFramework(routes = routes, styles = styles, minify = true, port = port, watchMode = watching, sessionCookie = sessionCookie, sessionDomain = sessionDomain, sessionSecure = sessionSecure, uploadMax = uploadMax)
  125. on Error(e) { console.log('error absorbed: ' + e.message) }

Branches

Latest commits

  • 9da65b42tests/browser.mjs: 404 checks (host, no hydration wait)MG
  • 00517fafgitoria: shell 404 page for unknown paths (catch-all route, status 404, JSON 404 under /api), 390 gate checksMG
  • d9e977f0reports/MG-mobile.md, LOGMG
  • 2f2725actests/browser.mjs: commit-row check (one row, centred date)MG
  • 4df1ea01tests/browser.mjs: MG phone checks (list first, no dead strip, one branch heading, tab grid, commit rows, PR title row, ticket columns, wrapping commands)MG
  • c52424e9gitoria mobile: repo list before the forms, 3x2 tab grid, no duplicate branch heading, ordered commit rows, aligned ticket rows, pull title on its own row, wrapping clone commands, no dead strip under formsMG
  • 3a95252dG3: cache parsed README blocks by sha256 of the text (bounded LRU), reportmre
  • 570138cddeploy: security gate (tests/security.mjs)mre
  • da6b20fcgitoria SG: security audit fixes (uploadMax 0, Secure cookie on https, session rotation at login, nosniff on function routes, no identity in page data) + tests/security.mjs gate + reportmre
  • f98c981fgitoria B1: report wordingmre
  • c6364cedgitoria B1: compact Markdown blocks (one kind flag per block/span, empty and false fields omitted); same rendered HTML, page values -67%mre
  • cd99d2feWIP gitoria#22: always render the repo level's slot (missing-repo boot hang), pages render nothing without a repo; hydration diagnosis in reports/G2-hydrate.mdmre
  • e5404b9breport: commit idsmre
  • 63cfa21ereports/G2-repotabs.mdmre
  • 9b0516fdgitoria#22: mark the tab underline functional (check-theme), chain E2E: serve/measure split, bring the lisbeth tab to frontmre
  • 19bc1df8gitoria#22: all repo pages under ONE layout level (components/repo.hl, hl:web D-CHAIN): a tab click replaces only the page in the slot; head and tab nav stay the same DOM nodesmre
  • 40658417tests/browser.mjs: wait for the page to be live (hydrated) before clicking Merge — a click on the server-rendered button before the client mounted was lost (flaky 'Clashing change' under load)mre
  • 48a6154bre-vendor Hybriel 5406d146 (hl:web batches 9+10: #72 emits while the socket is closed delivered after reconnect, browser boot linear, faster list appends; contains int 6–14 + m406)mre
  • e972e8d7tests: short-id-switch (GITORIA_SWITCH_IDENT_PORT/_PORT) and ssh tunnel (GITORIA_GATE_TUNNEL_PORT) ports from env, defaults unchangedmre
  • f06f5349re-vendor Hybriel 6f8a0689 (int 6–11: streaming cursors, #203 index heal + close() fix, fd403 listDir/cursor fds, hl:time browser side, hl:web batches 5+6)mre