gitoria

gitoria

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit5d2c385a5d2c385agitoria: 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 toomre5d2c385a/components/list.hl

6.9 KB

  1. // components/list.hl — THE REPO LIST of the main address (ticket #6, gitoria#16): every repository, newest
  2. // first, and "Create a repository" (slug = its address, unique in the whole system) for a named user.
  3. // Composed into components/index.hl (route `/`) when the request's host is the main address. Rendered on
  4. // the server with its rows; a new repo from any session reaches every open list (push `repoCreated`).
  5. import { repoOrigin } from '../lib/util.hl'
  6. import Tokens from './tokens.hl'
  7. import SshKeys from './sshkeys.hl'
  8. import { repoRows, orgRows, createRepoIn, createOrg } from '../lib/repos.hl'
  9. import { infoOfSession, userOfSession, userIdOfSession } from '../lib/users.hl'
  10. session = null
  11. me = infoOfSession(session)
  12. canCreate = me != null && me.named
  13. needsLogin = me == null
  14. repos = repoRows(userIdOfSession(session))
  15. orgs = orgRows(userIdOfSession(session))
  16. hasOrgs = orgs.length > 0
  17. noRepos = repos.length == 0
  18. createError = ''
  19. orgError = ''
  20. createdText = ''
  21. createdHref = ''
  22. hasCreated = false
  23. // THE LIST COMES FIRST (mobile first): the repositories are what this page is for; the create form, tokens and keys follow it.
  24. // (Before, a phone scrolled past three forms — 5 000 px — to reach the first repository.)
  25. Style {
  26. // the form is a card like the other forms of the page; its members stand in a grid
  27. '#orgform' { display = 'grid' gap = '.75rem' padding = '1rem' margin = '1rem 0' background = 'var(--color-surface)' borderRadius = 'var(--radius-large)' }
  28. // the organizations: one dense row each, the name and its "Private" mark side by side
  29. '#orgs' { listStyle = 'none' margin = '0' padding = '0' display = 'grid' gap = '.1rem'
  30. li { display = 'flex' alignItems = 'center' gap = '.75rem' minHeight = '2.75rem' }
  31. }
  32. }
  33. View {
  34. repoList {
  35. h1 { id = "heading" "Repositories" }
  36. if (needsLogin) { p { id = "loginhint" class = "muted" "Log in with ident (top right) to create a repository." } }
  37. if (noRepos) { p { id = "empty" class = "empty" "No repository yet." } }
  38. ol { id = "repos"
  39. for (r of repos) {
  40. li {
  41. a { class = "slug" href = r.address r.slug }
  42. if (r.isPrivate) { span { class = "muted" "Private" } }
  43. if (r.described) { span { class = "about" r.description } }
  44. repoMeta { span { r.owner } time { r.created } }
  45. }
  46. }
  47. }
  48. if (hasOrgs) {
  49. h2 { "Organizations" }
  50. ul { id = "orgs"
  51. for (o of orgs) {
  52. li { a { class = "slug" href = o.address o.slug } if (o.isPrivate) { span { class = "muted" "Private" } } }
  53. }
  54. }
  55. }
  56. if (canCreate) {
  57. form { id = "createform"
  58. on submit(e) {
  59. e.preventDefault()
  60. emit createIt(e)
  61. }
  62. h2 { "Create a repository" }
  63. label { "Address — its name is unique in the whole system and becomes NAME.gitoria.worldapi.org"
  64. input { id = "slug" name = "slug" required = "required" minlength = "2" maxlength = "40" autocomplete = "off" autocapitalize = "none" spellcheck = "false" }
  65. }
  66. label { "Description (optional)"
  67. input { id = "description" name = "description" maxlength = "200" autocomplete = "off" }
  68. }
  69. label { "Organization (optional) — put the repository inside one of yours: ORG.gitoria.worldapi.org/NAME"
  70. input { id = "org" name = "org" maxlength = "40" autocomplete = "off" autocapitalize = "none" spellcheck = "false" }
  71. }
  72. label { "Visibility — a private repository is seen only by you and the members you add"
  73. select { id = "priv" name = "priv"
  74. option { value = "public" "Public" }
  75. option { value = "private" "Private" }
  76. }
  77. }
  78. button { id = "createsave" type = "submit" "Create repository" }
  79. p { id = "createerror" class = "message" createError }
  80. }
  81. }
  82. if (canCreate) {
  83. form { id = "orgform"
  84. on submit(e) {
  85. e.preventDefault()
  86. emit createOrgIt(e)
  87. }
  88. h2 { "Create an organization" }
  89. label { "Name — becomes NAME.gitoria.worldapi.org, its repositories live at NAME.gitoria.worldapi.org/REPO"
  90. input { id = "orgslug" name = "orgslug" required = "required" minlength = "2" maxlength = "40" autocomplete = "off" autocapitalize = "none" spellcheck = "false" }
  91. }
  92. label { "Visibility — a private organization makes every repository of it private, also new ones"
  93. select { id = "orgpriv" name = "orgpriv"
  94. option { value = "public" "Public" }
  95. option { value = "private" "Private" }
  96. }
  97. }
  98. button { id = "orgsave" type = "submit" "Create organization" }
  99. p { id = "orgerror" class = "message" orgError }
  100. }
  101. }
  102. if (hasCreated) { p { id = "created" class = "notice" createdText " " a { id = "createdlink" href = createdHref "Open it" } } }
  103. Tokens { }
  104. SshKeys { }
  105. }
  106. }
  107. on createIt(e) {
  108. f = e.target.elements
  109. r = emit server gitoriaCreateRepo(f.slug.value, f.description.value, f.org.value, f.priv.value == 'private')
  110. if (r == null || r.error != null) {
  111. createError = r != null ? r.error : 'could not create the repository'
  112. return null
  113. }
  114. createError = ''
  115. f.slug.value = ''
  116. f.description.value = ''
  117. f.priv.value = 'public'
  118. createdText = "Created '" + r.repo.slug + "': "
  119. createdHref = r.repo.address
  120. hasCreated = true
  121. }
  122. on createOrgIt(e) {
  123. f = e.target.elements
  124. r = emit server gitoriaCreateOrg(f.orgslug.value, f.orgpriv.value == 'private')
  125. if (r == null || r.error != null) {
  126. orgError = r != null ? r.error : 'could not create the organization'
  127. return null
  128. }
  129. orgError = ''
  130. f.orgslug.value = ''
  131. f.orgpriv.value = 'public'
  132. createdText = "Created the organization '" + r.org.slug + "': "
  133. createdHref = r.address
  134. hasCreated = true
  135. orgs = [{ slug = r.org.slug isPrivate = r.org.isPrivate isPublic = !r.org.isPrivate address = r.address }].concat(orgs)
  136. hasOrgs = true
  137. }
  138. // this session's tabs follow a login / name / logout (the shell's faces push them)
  139. on client gitoriaSignedIn(tag, info) {
  140. canCreate = info.named
  141. needsLogin = false
  142. }
  143. on client gitoriaSignedOut(tag) {
  144. canCreate = false
  145. needsLogin = true
  146. }
  147. // a new repo, from any session: the list follows live
  148. on client repoCreated(row) {
  149. next = [row]
  150. for (x of repos) { if (x.id != row.id) { next.push(x) } }
  151. repos = next
  152. noRepos = false
  153. }
  154. on server gitoriaCreate(slug, description, session) {
  155. return makeRepo(slug, description, '', false, session)
  156. }
  157. on server gitoriaCreateRepo(slug, description, org, priv, session) {
  158. return makeRepo(slug, description, org, priv, session)
  159. }
  160. on server gitoriaCreateOrg(slug, priv, session) {
  161. u = userOfSession(session)
  162. if (u == null) { return { error = 'log in with ident (top right) first' } }
  163. r = createOrg(u.id, slug, priv)
  164. if (r.error != null) { return { error = r.error } }
  165. return { org = r.org address = repoOrigin(r.org.slug) + '/' }
  166. }
  167. makeRepo = (slug, description, org, priv, session) => {
  168. u = userOfSession(session)
  169. if (u == null) { return { error = 'log in with ident (top right) to create a repository' } }
  170. r = createRepoIn(u.id, org, slug, description, priv)
  171. if (r.error != null) { return { error = r.error } }
  172. emit client repoCreated(r.repo)
  173. return r
  174. }

Branches

Latest commits

  • 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
  • 2a2fdd77gs: C2 check before cookie experimentsmre