gitoria

gitoria

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commiteefa2dbceefa2dbcRepo setting: refuse direct pushes to the main branch (pre-receive over HTTPS and ssh)mreeefa2dbc/components/list.hl

8.6 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. repoSlug = ''
  19. repoDescription = ''
  20. repoOrg = ''
  21. repoVisibility = 'public'
  22. orgSlug = ''
  23. orgVisibility = 'public'
  24. createError = ''
  25. orgError = ''
  26. createdText = ''
  27. createdHref = ''
  28. hasCreated = false
  29. // THE LIST COMES FIRST (mobile first): the repositories are what this page is for; the create form, tokens and keys follow it.
  30. // (Before, a phone scrolled past three forms — 5 000 px — to reach the first repository.)
  31. View {
  32. repoList {
  33. h1 { id = "heading" "Repositories" }
  34. if (needsLogin) { p { id = "loginhint" class = "muted" "Log in with ident (top right) to create a repository." } }
  35. if (noRepos) { p { id = "empty" class = "empty" "No repository yet." } }
  36. ol { id = "repos"
  37. for (r of repos) {
  38. li {
  39. a { Style.aRepoSlug href = r.address r.slug }
  40. if (r.isPrivate) { span { class = "muted" "Private" } }
  41. if (r.described) { span { Style.spanRepoAbout r.description } }
  42. repoMeta { span { r.owner } time { r.created } }
  43. }
  44. }
  45. }
  46. if (hasOrgs) {
  47. h2 { "Organizations" }
  48. ul { id = "orgs"
  49. for (o of orgs) {
  50. li { a { class = "slug" href = o.address o.slug } if (o.isPrivate) { span { class = "muted" "Private" } } }
  51. }
  52. }
  53. }
  54. if (canCreate) {
  55. form { id = "createform"
  56. on submit(e) {
  57. e.preventDefault()
  58. emit createIt(e)
  59. }
  60. h2 { "Create a repository" }
  61. label { "Address — its name is unique in the whole system and becomes NAME.gitoria.worldapi.org"
  62. input { id = "slug" name = "slug" required = "required" minlength = "2" maxlength = "40" autocomplete = "off" autocapitalize = "none" spellcheck = "false" value = repoSlug on input(e) { repoSlug = e.target.value } }
  63. }
  64. label { "Description (optional)"
  65. input { id = "description" name = "description" maxlength = "200" autocomplete = "off" value = repoDescription on input(e) { repoDescription = e.target.value } }
  66. }
  67. label { "Organization (optional) — put the repository inside one of yours: ORG.gitoria.worldapi.org/NAME"
  68. input { id = "org" name = "org" maxlength = "40" autocomplete = "off" autocapitalize = "none" spellcheck = "false" value = repoOrg on input(e) { repoOrg = e.target.value } }
  69. }
  70. label { "Visibility — a private repository is seen only by you and the members you add"
  71. select { id = "priv" name = "priv" value = repoVisibility on change(e) { repoVisibility = e.target.value }
  72. option { value = "public" "Public" }
  73. option { value = "private" "Private" }
  74. }
  75. }
  76. button { id = "createsave" type = "submit" "Create repository" }
  77. p { id = "createerror" createError }
  78. }
  79. }
  80. if (canCreate) {
  81. form { id = "orgform"
  82. on submit(e) {
  83. e.preventDefault()
  84. emit createOrgIt(e)
  85. }
  86. h2 { "Create an organization" }
  87. label { "Name — becomes NAME.gitoria.worldapi.org, its repositories live at NAME.gitoria.worldapi.org/REPO"
  88. input { id = "orgslug" name = "orgslug" required = "required" minlength = "2" maxlength = "40" autocomplete = "off" autocapitalize = "none" spellcheck = "false" value = orgSlug on input(e) { orgSlug = e.target.value } }
  89. }
  90. label { "Visibility — a private organization makes every repository of it private, also new ones"
  91. select { id = "orgpriv" name = "orgpriv" value = orgVisibility on change(e) { orgVisibility = e.target.value }
  92. option { value = "public" "Public" }
  93. option { value = "private" "Private" }
  94. }
  95. }
  96. button { id = "orgsave" type = "submit" "Create organization" }
  97. p { id = "orgerror" orgError }
  98. }
  99. }
  100. if (hasCreated) { p { id = "created" createdText " " a { id = "createdlink" href = createdHref "Open it" } } }
  101. Tokens { }
  102. SshKeys { }
  103. }
  104. }
  105. on createIt(e) {
  106. r = emit server gitoriaCreateRepo(repoSlug, repoDescription, repoOrg, repoVisibility == 'private')
  107. if (r == null || r.error != null) {
  108. createError = r != null ? r.error : 'could not create the repository'
  109. return null
  110. }
  111. createError = ''
  112. repoSlug = ''
  113. repoDescription = ''
  114. repoVisibility = 'public'
  115. createdText = "Created '" + r.repo.slug + "': "
  116. createdHref = r.repo.address
  117. hasCreated = true
  118. }
  119. on createOrgIt(e) {
  120. r = emit server gitoriaCreateOrg(orgSlug, orgVisibility == 'private')
  121. if (r == null || r.error != null) {
  122. orgError = r != null ? r.error : 'could not create the organization'
  123. return null
  124. }
  125. orgError = ''
  126. orgSlug = ''
  127. orgVisibility = 'public'
  128. createdText = "Created the organization '" + r.org.slug + "': "
  129. createdHref = r.address
  130. hasCreated = true
  131. // The ack may already sync orgs from session; prepend this slug only once.
  132. next = [{ slug = r.org.slug isPrivate = r.org.isPrivate isPublic = !r.org.isPrivate address = r.address }]
  133. for (x of orgs) { if (x.slug != r.org.slug) { next.push(x) } }
  134. orgs = next
  135. hasOrgs = true
  136. }
  137. // this session's tabs follow a login / name / logout (the shell's faces push them)
  138. on client gitoriaSignedIn(tag, info) {
  139. canCreate = info.named
  140. needsLogin = false
  141. }
  142. on client gitoriaSignedOut(tag) {
  143. canCreate = false
  144. needsLogin = true
  145. }
  146. // a new repo, from any session: the list follows live
  147. on client repoCreated(row) {
  148. repos.remove(row.@id)
  149. repos = [row, for (x of repos) { x }]
  150. noRepos = false
  151. }
  152. on server gitoriaCreate(slug, description, session) {
  153. return makeRepo(slug, description, '', false, session)
  154. }
  155. on server gitoriaCreateRepo(slug, description, org, priv, session) {
  156. return makeRepo(slug, description, org, priv, session)
  157. }
  158. on server gitoriaCreateOrg(slug, priv, session) {
  159. u = userOfSession(session)
  160. if (u == null) { return { error = 'log in with ident (top right) first' } }
  161. r = createOrg(u.id, slug, priv)
  162. if (r.error != null) { return { error = r.error } }
  163. return { org = r.org address = repoOrigin(r.org.slug) + '/' }
  164. }
  165. makeRepo = (slug, description, org, priv, session) => {
  166. u = userOfSession(session)
  167. if (u == null) { return { error = 'log in with ident (top right) to create a repository' } }
  168. r = createRepoIn(u.id, org, slug, description, priv)
  169. if (r.error != null) { return { error = r.error } }
  170. return r
  171. }
  172. Style {
  173. repoList {
  174. display = 'grid'
  175. gap = '1rem'
  176. minWidth = '0'
  177. // Direct-child and sibling combinators have no bare language form.
  178. '> *' {
  179. margin = '0'
  180. }
  181. }
  182. #createform {
  183. display = 'grid'
  184. gap = '.75rem'
  185. padding = '1rem'
  186. background = 'var(--color-surface)'
  187. borderRadius = 'var(--radius-large)'
  188. // Direct-child and sibling combinators have no bare language form.
  189. '> *' {
  190. margin = '0'
  191. }
  192. }
  193. #repos {
  194. display = 'grid'
  195. gap = '.5rem'
  196. margin = '0'
  197. padding = '0'
  198. listStyle = 'none'
  199. li {
  200. display = 'grid'
  201. gap = '.1rem'
  202. margin = '0'
  203. padding = '.25rem 1rem .6rem'
  204. background = 'var(--color-surface)'
  205. borderRadius = 'var(--radius-large)'
  206. @media {
  207. minWidth = '60rem'
  208. gridTemplateColumns = 'minmax(10rem, 16rem) 1fr auto'
  209. alignItems = 'center'
  210. gap = '.15rem 1rem'
  211. padding = '.25rem 1rem'
  212. }
  213. }
  214. }
  215. repoMeta {
  216. display = 'flex'
  217. flexWrap = 'wrap'
  218. gap = '.2rem 1rem'
  219. fontSize = '.875rem'
  220. color = 'var(--color-text-muted)'
  221. }
  222. #orgform {
  223. display = 'grid'
  224. gap = '.75rem'
  225. padding = '1rem'
  226. margin = '1rem 0'
  227. background = 'var(--color-surface)'
  228. borderRadius = 'var(--radius-large)'
  229. }
  230. #orgs {
  231. listStyle = 'none'
  232. margin = '0'
  233. padding = '0'
  234. display = 'grid'
  235. gap = '.1rem'
  236. li {
  237. display = 'flex'
  238. alignItems = 'center'
  239. gap = '.75rem'
  240. minHeight = '2.75rem'
  241. }
  242. }
  243. aRepoSlug {
  244. display = 'flex'
  245. alignItems = 'center'
  246. minHeight = '2.75rem'
  247. fontWeight = '700'
  248. fontSize = '1.05rem'
  249. overflowWrap = 'anywhere'
  250. }
  251. spanRepoAbout {
  252. color = 'var(--color-text)'
  253. }
  254. #createerror {
  255. margin = '0'
  256. color = 'var(--color-danger)'
  257. empty { display = 'none' }
  258. }
  259. #orgerror {
  260. margin = '0'
  261. color = 'var(--color-danger)'
  262. empty { display = 'none' }
  263. }
  264. #created {
  265. margin = '0'
  266. color = 'var(--color-success)'
  267. }
  268. }

Branches

Latest commits

  • eefa2dbcRepo setting: refuse direct pushes to the main branch (pre-receive over HTTPS and ssh)mre
  • 25309981log: STOP and paused workers 2026-11-08mre
  • 5286803alog: worker briefs and reports of 2026-11-08mre
  • 85c86605log: 2026-11-08 Arachne on list shapemre
  • cb634512log: 2026-11-08 keyed lists livemre
  • 07c98d4aLists: keyed rows with @id, remove(id) and one whole-list assignment instead of hand-rebuilt loopsmre
  • 0db0d81elog: 2026-11-08 day52 live, W30 startedmre
  • b05f6d92tests/status: the gate's 3 s app token expired during the restart; it lives 60 s like status-keyedmre
  • 1e8f4f0avendor: Hybriel set-day52 (fault-path leak fix #335, keyed rows #331)mre
  • f5f0fb7blog: 2026-11-08 day50/#29 live, H25 correction, V52 startedmre
  • dc77fb95main: offline note from __hlOnline, tick removed (#29)mre
  • 37a86d93tests/reviews: seeded fake hook's DNS failures are not server errors (flaky gate)mre
  • 07ab845bvendor: Hybriel set-day50 (run() leak fix #335)mre
  • 71b2fa4blog: hybriel#335mre
  • bd94cc7elog: #25 cause found (run() leak)mre
  • 565cb508log: H25 round 1mre
  • 90a0af84log: H25 startedmre
  • 87bd53b8mission H25mre
  • 71a746cflog: day48 livemre
  • bf568e14log: V48 mergedmre