gitoria

gitoria

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit1185f6861185f686gitoria#36: a failed return from tickets shows a note on the settings page and leaves one log line per outcome; no code is exchangedmre1185f686/components/codebrowser.hl

5.2 KB

  1. // components/codebrowser.hl — THE CODE BROWSER (ticket #9, gitoria#16), composed into the three code pages:
  2. // code.hl (/code, /code/<path>: the main branch), branch.hl (/branch/<name>[/<path>]), commit.hl
  3. // (/commit/<id>[/<path>]); `kind` ('code' | 'branch' | 'commit') and `rest` (the part after /<kind>/) come from the
  4. // page. Rendered on the SERVER with its content: the repo from the request's host, the tree / file / branches /
  5. // commits from git (lib/code.hl browseNow — hl:proc run() waits, hybriel#80) — in the first HTML and in every hl:web navigation.
  6. import { slugOfRequest } from '../lib/orgs.hl'
  7. import { userOfSession } from '../lib/users.hl'
  8. import { repoAt, ownsRepo } from '../lib/repos.hl'
  9. import { browseNow, makeMain } from '../lib/code.hl'
  10. import { withRefParts } from '../lib/tickets-helpers.hl'
  11. host = null
  12. orepo = ''
  13. session = null
  14. kind = 'code'
  15. rest = ''
  16. slug = slugOfRequest(host, orepo)
  17. repo = repoAt(slug, session)
  18. hasRepo = repo != null
  19. codeData = repo != null ? withRefParts(browseNow(slug, kind, rest, repo.branch, ownsRepo(slug, session)), repo.ticketsProject) : null
  20. codeShown = codeData != null && !codeData.isMessage
  21. codeMessage = codeData != null && codeData.isMessage
  22. codeText = codeData != null && codeData.isMessage ? codeData.message : ''
  23. codeError = ''
  24. View {
  25. codeView {
  26. if (hasRepo) {
  27. if (codeMessage) { p { id = "codemessage" class = "empty" codeText } }
  28. if (codeShown) {
  29. codeBrowser {
  30. codeHead {
  31. span { id = "codekind" class = "muted" codeData.kindLabel }
  32. strong { id = "coderef" codeData.refLabel }
  33. latestCommit {
  34. a { id = "commitlink" href = codeData.commitHref codeData.short }
  35. span { id = "commitsubject" for (pt of codeData.subjectParts) { if (pt.isText) { span { pt.text } } if (pt.isLink) { a { class = "ticketref" href = pt.href pt.text } } } }
  36. span { class = "muted" codeData.author }
  37. time { codeData.date }
  38. }
  39. }
  40. pathCrumbs { id = "crumbs" class = "crumbs"
  41. for (c of codeData.crumbs) {
  42. if (c.linked) { a { href = c.href c.name } span { class = "muted" "/" } }
  43. if (c.last) { strong { c.name } }
  44. }
  45. }
  46. if (codeData.isTree) {
  47. if (codeData.noEntries) { p { id = "noentries" class = "empty" "This folder is empty." } }
  48. ul { id = "entries"
  49. for (e of codeData.entries) {
  50. li {
  51. if (e.isDir) { a { class = "dir" href = e.href e.name } }
  52. if (e.isFile) { a { class = "file" href = e.href e.name } }
  53. if (e.isOther) { span { class = "file" e.name } }
  54. span { class = "muted" e.size }
  55. }
  56. }
  57. }
  58. }
  59. if (codeData.isFile) {
  60. codeFile { id = "codefile"
  61. p { class = "muted" codeData.fileSize }
  62. if (codeData.binary) { p { id = "binary" class = "empty" "This file is not text (or not UTF-8) — not shown." } }
  63. if (codeData.tooBig) { p { id = "toobig" class = "empty" "This file is too large to show here." } }
  64. ol { id = "lines"
  65. for (ln of codeData.lines) { li { code { ln.text } } }
  66. }
  67. if (codeData.truncated) { p { id = "linestruncated" class = "muted" "Only the first lines are shown." } }
  68. }
  69. }
  70. codeSide {
  71. section { id = "branches"
  72. h2 { "Branches" }
  73. ul {
  74. for (b of codeData.branches) {
  75. li {
  76. if (b.isCurrent) { strong { b.name } }
  77. if (b.notCurrent) { a { href = b.href b.name } }
  78. if (b.isDefault) { span { class = "muted" "main branch" } }
  79. if (b.canSet) { button { class = "quiet setmain" type = "button" value = b.name "Make main" on click(e) { emit setMain(e.target.value) } } }
  80. }
  81. }
  82. }
  83. p { id = "codeerror" class = "message" codeError }
  84. }
  85. section { id = "commits"
  86. h2 { "Latest commits" }
  87. ul {
  88. for (c of codeData.commits) {
  89. li {
  90. a { href = c.href c.short }
  91. span { for (pt of c.parts) { if (pt.isText) { span { pt.text } } if (pt.isLink) { a { class = "ticketref" href = pt.href pt.text } } } }
  92. span { class = "muted" c.author }
  93. time { c.date }
  94. }
  95. }
  96. }
  97. }
  98. }
  99. }
  100. }
  101. }
  102. }
  103. }
  104. // "Make main" (the owner): the face answers with the same view, read again with the new main branch
  105. on setMain(name) {
  106. codeError = ''
  107. r = emit server gitoriaSetBranch(slug, name, kind, rest)
  108. if (r == null || r.error != null) {
  109. codeError = r != null ? r.error : 'could not change the main branch'
  110. return null
  111. }
  112. codeData = r.result
  113. codeShown = !r.result.isMessage
  114. codeMessage = r.result.isMessage
  115. codeText = r.result.isMessage ? r.result.message : ''
  116. }
  117. on server gitoriaSetBranch(slugOf, name, kindOf, restOf, session) {
  118. if (session == null || repoAt(slugOf, session) == null) { return { error = 'could not change the main branch' } }
  119. if (kindOf != 'code' && kindOf != 'branch' && kindOf != 'commit') { return { error = 'could not change the main branch' } }
  120. if (restOf == null || hlTypeName(restOf) != 'String' || restOf.length > 500 || name == null || hlTypeName(name) != 'String') { return { error = 'could not change the main branch' } }
  121. u = userOfSession(session)
  122. if (u == null || !ownsRepo(slugOf, session)) { return { error = 'only the owner can change the main branch' } }
  123. return makeMain(u.id, slugOf, name, kindOf, restOf)
  124. }

Branches

Latest commits

  • 1185f686gitoria#36: a failed return from tickets shows a note on the settings page and leaves one log line per outcome; no code is exchangedmre
  • 5d2c385agitoria: the sign-in callback keeps the session it finds and signs it in (same cookie, nothing signed out; ident#28); security gate 71+5 failing → 76 passed; deploy.sh runs tests/private.mjs toomre
  • 241ef3f9deploy.sh: rebuild the sshd image before up -d (GO34c)mre
  • 821cdbb1gitoria#34b: styles, create-repo tool, docs, push/ssh gates sign in through the selector, shots scriptmre
  • 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