gitoriaLog in with ident

gitoria

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit9b27cb269b27cb26gitoria#21: installable app (manifest, service worker, offline start page), own iconmre9b27cb26/components/list.hl

3.2 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 Tokens from './tokens.hl'
  6. import SshKeys from './sshkeys.hl'
  7. import { repoRows, createRepo } from '../repos.hl'
  8. import { infoOfSession, userOfSession } from '../users.hl'
  9. session = null
  10. me = infoOfSession(session)
  11. canCreate = me != null && me.named
  12. needsLogin = me == null
  13. repos = repoRows()
  14. noRepos = repos.length == 0
  15. createError = ''
  16. createdText = ''
  17. createdHref = ''
  18. hasCreated = false
  19. View {
  20. repoList {
  21. h1 { id = "heading" "Repositories" }
  22. if (needsLogin) { p { id = "loginhint" class = "muted" "Log in with ident (top right) to create a repository." } }
  23. if (canCreate) {
  24. form { id = "createform"
  25. on submit(e) {
  26. e.preventDefault()
  27. emit createIt(e)
  28. }
  29. h2 { "Create a repository" }
  30. label { "Address — its name is unique in the whole system and becomes NAME.gitoria.worldapi.org"
  31. input { id = "slug" name = "slug" required = "required" minlength = "2" maxlength = "40" autocomplete = "off" autocapitalize = "none" spellcheck = "false" }
  32. }
  33. label { "Description (optional)"
  34. input { id = "description" name = "description" maxlength = "200" autocomplete = "off" }
  35. }
  36. button { id = "createsave" type = "submit" "Create repository" }
  37. p { id = "createerror" class = "message" createError }
  38. }
  39. }
  40. if (hasCreated) { p { id = "created" class = "notice" createdText " " a { id = "createdlink" href = createdHref "Open it" } } }
  41. if (noRepos) { p { id = "empty" class = "empty" "No repository yet." } }
  42. Tokens { }
  43. SshKeys { }
  44. ol { id = "repos"
  45. for (r of repos) {
  46. li {
  47. a { class = "slug" href = r.address r.slug }
  48. if (r.described) { span { class = "about" r.description } }
  49. repoMeta { span { r.owner } time { r.created } }
  50. }
  51. }
  52. }
  53. }
  54. }
  55. on createIt(e) {
  56. let f = e.target.elements
  57. let r = emit server gitoriaCreate(f.slug.value, f.description.value)
  58. if (r == null || r.error != null) {
  59. createError = r != null ? r.error : 'could not create the repository'
  60. return null
  61. }
  62. createError = ''
  63. f.slug.value = ''
  64. f.description.value = ''
  65. createdText = "Created '" + r.repo.slug + "': "
  66. createdHref = r.repo.address
  67. hasCreated = true
  68. }
  69. // this session's tabs follow a login / name / logout (the shell's faces push them)
  70. on client gitoriaSignedIn(tag, info) {
  71. canCreate = info.named
  72. needsLogin = false
  73. }
  74. on client gitoriaSignedOut(tag) {
  75. canCreate = false
  76. needsLogin = true
  77. }
  78. // a new repo, from any session: the list follows live
  79. on client repoCreated(row) {
  80. let next = [row]
  81. for (x of repos) { if (x.id != row.id) { next.push(x) } }
  82. repos = next
  83. noRepos = false
  84. }
  85. on server gitoriaCreate(slug, description, session) {
  86. let u = userOfSession(session)
  87. if (u == null) { return { error = 'log in with ident (top right) to create a repository' } }
  88. let r = createRepo(u.id, slug, description)
  89. if (r.error != null) { return { error = r.error } }
  90. emit client repoCreated(r.repo)
  91. return r
  92. }

Branches

Latest commits

  • 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