gitoria

gitoria

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commita81abdc9a81abdc9gitoria#34: org page via function route, member-reachable orgs, selects, reportmrea81abdc9/lib/repos-helpers.hl

5.2 KB

  1. // lib/repos-helpers.hl — what lib/repos.hl looks up: the slug's rules, the row a page shows, a whole record with some
  2. // fields changed, the tab title, the Markdown read view of the API. Statics only, no table access.
  3. import { NL, localStamp, repoOrigin } from './util.hl'
  4. import { nameOfUser } from './users.hl'
  5. // names that are addresses of the system itself, or that would read as one (never a repo)
  6. // only technical host names; the creator's own apps (ident, tickets, hybriel, …) are repos here too (creator 2026-09-25)
  7. static reserved = ['www' 'api' 'git' 'ssh' 'http' 'https' 'ftp' 'mail' 'smtp' 'imap' 'admin' 'root' 'cdn' 'static' 'assets' 'login' 'logout' 'new' 'repos']
  8. static isLower = (c) => { return c >= 97 && c <= 122 }
  9. static isDigit = (c) => { return c >= 48 && c <= 57 }
  10. // the slug's rules → null (fine) or the complaint. A DNS label: 2–40 characters, a–z 0–9 and
  11. // single hyphens, starting and ending with a letter or digit ("--" is refused: xn-- is punycode)
  12. static slugError = (slug) => {
  13. if (slug == null || hlTypeName(slug) != 'String') { return 'the address must be text' }
  14. if (slug.length < 2 || slug.length > 40) { return 'the address must have 2–40 characters' }
  15. let i = 0
  16. while (i < slug.length) {
  17. let c = slug.charCodeAt(i)
  18. let ok = isLower(c) || isDigit(c) || (c == 45 && i > 0 && i < slug.length - 1)
  19. if (!ok) { return 'the address may only have lowercase letters a–z, digits and hyphens, and starts and ends with a letter or digit' }
  20. i = i + 1
  21. }
  22. if (slug.includes('--')) { return 'the address must not have two hyphens in a row' }
  23. if (reserved.includes(slug)) { return "'" + slug + "' is reserved for the system" }
  24. return null
  25. }
  26. // names an organization's repo may not have: its address would collide with a page of the organization's address
  27. static orgReserved = ['code' 'branch' 'commit' 'pulls' 'releases' 'tickets' 'settings' 'api' 'login' 'icons' '__git' '__hl' 'favicon' 'favicon.ico']
  28. // the rules for a repo's full name: `name` (slugError) or `org/name` (both parts valid, the repo name not a page word)
  29. static fullNameError = (full) => {
  30. if (full == null || hlTypeName(full) != 'String') { return 'the address must be text' }
  31. i = full.indexOf('/')
  32. if (i < 0) { return slugError(full) }
  33. bad = slugError(full.slice(0, i))
  34. if (bad != null) { return bad }
  35. name = full.slice(i + 1)
  36. bad2 = slugError(name)
  37. if (bad2 != null) { return bad2 }
  38. if (orgReserved.includes(name)) { return "'" + name + "' is reserved inside an organization" }
  39. return null
  40. }
  41. // what a page and the API show of a repo (never the tickets key); `eff` = the repo is private (its own flag or its organization's)
  42. static rowOf = (r, eff) => {
  43. org = r.org != null ? r.org : ''
  44. return { id = r.id slug = r.slug org = org inOrg = org != '' isPrivate = eff isPublic = !eff description = r.description described = r.description != '' owner = nameOfUser(r.owner) branch = r.branch != null ? r.branch : '' ticketsOn = r.tktKey != null && r.tktKey != '' ticketsOff = r.tktKey == null || r.tktKey == '' ticketsProject = r.tktProject != null ? r.tktProject : '' ticketsTitle = r.tktTitle != null ? r.tktTitle : '' created = localStamp(r.created) createdMs = r.created address = repoOrigin(r.slug) + '/' }
  45. }
  46. // a repo's whole record with some fields changed (update() replaces the record: every field must be given again)
  47. static withChange = (r, change) => {
  48. o = { id = r.id slug = r.slug description = r.description owner = r.owner created = r.created branch = r.branch != null ? r.branch : '' tktKey = r.tktKey != null ? r.tktKey : '' tktProject = r.tktProject != null ? r.tktProject : '' tktTitle = r.tktTitle != null ? r.tktTitle : '' tktApi = r.tktApi != null ? r.tktApi : '' org = r.org != null ? r.org : '' priv = r.priv == true }
  49. for (k of change.keys()) { o[k] = change[k] }
  50. return o
  51. }
  52. // the repo tab a path belongs to (components/repo.hl marks it): '/' readme · code/branch/commit pages 'code' · pulls · releases ·
  53. // tickets · settings, else ''
  54. static tabOfPath = (path) => {
  55. if (path == '' || path == '/') { return 'readme' }
  56. if (path == '/code' || path.startsWith('/code/') || path.startsWith('/branch/') || path.startsWith('/commit/')) { return 'code' }
  57. if (path == '/pulls') { return 'pulls' }
  58. if (path == '/releases') { return 'releases' }
  59. if (path == '/tickets') { return 'tickets' }
  60. if (path == '/settings') { return 'settings' }
  61. return ''
  62. }
  63. // a tab title: 'Code · alpha · gitoria', 'alpha · gitoria', 'gitoria'
  64. static pageTitle = (site, slug, what) => {
  65. t = slug != null && slug != '' ? slug + ' · ' + site : site
  66. return what != null && what != '' ? what + ' · ' + t : t
  67. }
  68. // ---- the Markdown read view (Accept: text/markdown) — for LLM readers ---------------------------
  69. static repoDocument = (row) => {
  70. let out = '# ' + row.slug + NL + NL
  71. if (row.described) { out = out + row.description + NL + NL }
  72. out = out + '- address: ' + row.address + NL + '- owner: ' + row.owner + NL + '- created: ' + row.created + NL
  73. return out
  74. }
  75. static listDocument = (rows) => {
  76. let out = '# Repositories (' + rows.length + ')' + NL + NL
  77. if (rows.length == 0) { out = out + 'No repository yet.' + NL }
  78. for (r of rows) { out = out + '- [' + r.slug + '](' + r.address + ')' + (r.described ? ' — ' + r.description : '') + NL }
  79. return out
  80. }

Branches

Latest commits

  • a81abdc9gitoria#34: org page via function route, member-reachable orgs, selects, reportmre
  • 17f031f0gitoria#34: private repos, organizations, members, move tool, gatemre
  • 71b69343gitoria#23: the sidebar's Repositories link was a 404 after any in-page navigation (static menu re-evaluated publicUrl in the browser); the menu is an instance property now; gate taps it after a tab, folder, filemre
  • 90b4f728gitoria#25: restore the homepage cache and the parsed-blocks cache (they store data under immutable keys, no HTML); the page key, the framework readme key and the textHash key stay removedmre
  • a487248cgitoria#25: remove every cache that hid the page build (page key, Markdown render key, homepage cache, parsed-blocks cache) and the gate that only tested themmre
  • 12f2f4fegitoria: re-vendor Hybriel set-day27b, a startup fault in on Error exits 1mre
  • c21c084egitoria: write the standby service out in full so the boot gate can read the main servicemre
  • e307d69agitoria: say what is per process during the hand-overmre
  • f0cbe6a6gitoria: standby service on port 45014 and a deploy that hands over through it without a gapmre
  • 727cd083gitoria#25: README: vendor notes for Hybriel c1b1010f and the page cachemre
  • 61b72dedgitoria#25: re-vendor Hybriel master c1b1010f (W149 page cache), key the repo Readme page by slug and main commit, extend the readme-cache gatemre
  • 5b0b4b9ereadme-cache gate: use the security gate's ports when no own ports are givenmre
  • bc8f20d9gitoria#25: re-vendor Hybriel c09538bb with the W141 render cache, cache the homepage per commit, add the readme-cache gatemre
  • 9feebbd3Re-vendor Hybriel to ded47c13 (W145: Firefox start script fix)mre
  • 28ed41e5gitoria#24: one sign-in comes from hl:web batch 20, the /session/share workaround is gonemre
  • 3b2669e4gs: drop the unbuildable legacy check, fix pwa fetchmre
  • 2a2fdd77gs: C2 check before cookie experimentsmre
  • 76e0587aWIP gs 2mre
  • a80da7bdWIP gs: security gate for lazy sessions, g24 browser checksmre
  • 23fb05d8re-vendor Hybriel aaa39e69 (hl:web batch 20: login emit and Sessions.mint, tab follows a login, signed-in session cookie wins among duplicates and is re-issued with the Domain, W85 faster render, lazy sessions)mre