gitoria
All repositories: gitoria
8.6 KB
// components/list.hl — THE REPO LIST of the main address (ticket #6, gitoria#16): every repository, newest// first, and "Create a repository" (slug = its address, unique in the whole system) for a named user.// Composed into components/index.hl (route `/`) when the request's host is the main address. Rendered on// the server with its rows; a new repo from any session reaches every open list (push `repoCreated`).import { repoOrigin } from '../lib/util.hl'import Tokens from './tokens.hl'import SshKeys from './sshkeys.hl'import { repoRows, orgRows, createRepoIn, createOrg } from '../lib/repos.hl'import { infoOfSession, userOfSession, userIdOfSession } from '../lib/users.hl'session = nullme = infoOfSession(session)canCreate = me != null && me.namedneedsLogin = me == nullrepos = repoRows(userIdOfSession(session))orgs = orgRows(userIdOfSession(session))hasOrgs = orgs.length > 0noRepos = repos.length == 0repoSlug = ''repoDescription = ''repoOrg = ''repoVisibility = 'public'orgSlug = ''orgVisibility = 'public'createError = ''orgError = ''createdText = ''createdHref = ''hasCreated = false// THE LIST COMES FIRST (mobile first): the repositories are what this page is for; the create form, tokens and keys follow it.// (Before, a phone scrolled past three forms — 5 000 px — to reach the first repository.)View {repoList {h1 { id = "heading" "Repositories" }if (needsLogin) { p { id = "loginhint" class = "muted" "Log in with ident (top right) to create a repository." } }if (noRepos) { p { id = "empty" class = "empty" "No repository yet." } }ol { id = "repos"for (r of repos) {li {a { Style.aRepoSlug href = r.address r.slug }if (r.isPrivate) { span { class = "muted" "Private" } }if (r.described) { span { Style.spanRepoAbout r.description } }repoMeta { span { r.owner } time { r.created } }}}}if (hasOrgs) {h2 { "Organizations" }ul { id = "orgs"for (o of orgs) {li { a { class = "slug" href = o.address o.slug } if (o.isPrivate) { span { class = "muted" "Private" } } }}}}if (canCreate) {form { id = "createform"on submit(e) {e.preventDefault()emit createIt(e)}h2 { "Create a repository" }label { "Address — its name is unique in the whole system and becomes NAME.gitoria.worldapi.org"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 } }}label { "Description (optional)"input { id = "description" name = "description" maxlength = "200" autocomplete = "off" value = repoDescription on input(e) { repoDescription = e.target.value } }}label { "Organization (optional) — put the repository inside one of yours: ORG.gitoria.worldapi.org/NAME"input { id = "org" name = "org" maxlength = "40" autocomplete = "off" autocapitalize = "none" spellcheck = "false" value = repoOrg on input(e) { repoOrg = e.target.value } }}label { "Visibility — a private repository is seen only by you and the members you add"select { id = "priv" name = "priv" value = repoVisibility on change(e) { repoVisibility = e.target.value }option { value = "public" "Public" }option { value = "private" "Private" }}}button { id = "createsave" type = "submit" "Create repository" }p { id = "createerror" createError }}}if (canCreate) {form { id = "orgform"on submit(e) {e.preventDefault()emit createOrgIt(e)}h2 { "Create an organization" }label { "Name — becomes NAME.gitoria.worldapi.org, its repositories live at NAME.gitoria.worldapi.org/REPO"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 } }}label { "Visibility — a private organization makes every repository of it private, also new ones"select { id = "orgpriv" name = "orgpriv" value = orgVisibility on change(e) { orgVisibility = e.target.value }option { value = "public" "Public" }option { value = "private" "Private" }}}button { id = "orgsave" type = "submit" "Create organization" }p { id = "orgerror" orgError }}}if (hasCreated) { p { id = "created" createdText " " a { id = "createdlink" href = createdHref "Open it" } } }Tokens { }SshKeys { }}}on createIt(e) {r = emit server gitoriaCreateRepo(repoSlug, repoDescription, repoOrg, repoVisibility == 'private')if (r == null || r.error != null) {createError = r != null ? r.error : 'could not create the repository'return null}createError = ''repoSlug = ''repoDescription = ''repoVisibility = 'public'createdText = "Created '" + r.repo.slug + "': "createdHref = r.repo.addresshasCreated = true}on createOrgIt(e) {r = emit server gitoriaCreateOrg(orgSlug, orgVisibility == 'private')if (r == null || r.error != null) {orgError = r != null ? r.error : 'could not create the organization'return null}orgError = ''orgSlug = ''orgVisibility = 'public'createdText = "Created the organization '" + r.org.slug + "': "createdHref = r.addresshasCreated = true// The ack may already sync orgs from session; prepend this slug only once.next = [{ slug = r.org.slug isPrivate = r.org.isPrivate isPublic = !r.org.isPrivate address = r.address }]for (x of orgs) { if (x.slug != r.org.slug) { next.push(x) } }orgs = nexthasOrgs = true}// this session's tabs follow a login / name / logout (the shell's faces push them)on client gitoriaSignedIn(tag, info) {canCreate = info.namedneedsLogin = false}on client gitoriaSignedOut(tag) {canCreate = falseneedsLogin = true}// a new repo, from any session: the list follows liveon client repoCreated(row) {repos.remove(row.@id)repos = [row, for (x of repos) { x }]noRepos = false}on server gitoriaCreate(slug, description, session) {return makeRepo(slug, description, '', false, session)}on server gitoriaCreateRepo(slug, description, org, priv, session) {return makeRepo(slug, description, org, priv, session)}on server gitoriaCreateOrg(slug, priv, session) {u = userOfSession(session)if (u == null) { return { error = 'log in with ident (top right) first' } }r = createOrg(u.id, slug, priv)if (r.error != null) { return { error = r.error } }return { org = r.org address = repoOrigin(r.org.slug) + '/' }}makeRepo = (slug, description, org, priv, session) => {u = userOfSession(session)if (u == null) { return { error = 'log in with ident (top right) to create a repository' } }r = createRepoIn(u.id, org, slug, description, priv)if (r.error != null) { return { error = r.error } }return r}Style {repoList {display = 'grid'gap = '1rem'minWidth = '0'// Direct-child and sibling combinators have no bare language form.'> *' {margin = '0'}}#createform {display = 'grid'gap = '.75rem'padding = '1rem'background = 'var(--color-surface)'borderRadius = 'var(--radius-large)'// Direct-child and sibling combinators have no bare language form.'> *' {margin = '0'}}#repos {display = 'grid'gap = '.5rem'margin = '0'padding = '0'listStyle = 'none'li {display = 'grid'gap = '.1rem'margin = '0'padding = '.25rem 1rem .6rem'background = 'var(--color-surface)'borderRadius = 'var(--radius-large)'@media {minWidth = '60rem'gridTemplateColumns = 'minmax(10rem, 16rem) 1fr auto'alignItems = 'center'gap = '.15rem 1rem'padding = '.25rem 1rem'}}}repoMeta {display = 'flex'flexWrap = 'wrap'gap = '.2rem 1rem'fontSize = '.875rem'color = 'var(--color-text-muted)'}#orgform {display = 'grid'gap = '.75rem'padding = '1rem'margin = '1rem 0'background = 'var(--color-surface)'borderRadius = 'var(--radius-large)'}#orgs {listStyle = 'none'margin = '0'padding = '0'display = 'grid'gap = '.1rem'li {display = 'flex'alignItems = 'center'gap = '.75rem'minHeight = '2.75rem'}}aRepoSlug {display = 'flex'alignItems = 'center'minHeight = '2.75rem'fontWeight = '700'fontSize = '1.05rem'overflowWrap = 'anywhere'}spanRepoAbout {color = 'var(--color-text)'}#createerror {margin = '0'color = 'var(--color-danger)'empty { display = 'none' }}#orgerror {margin = '0'color = 'var(--color-danger)'empty { display = 'none' }}#created {margin = '0'color = 'var(--color-success)'}}
Branches
- f1-broken-json
- f2-api-bugs
- gp-gate-ports
- heap-revert
- hl25-records
- ident-chooser-selector
- mainmain branch
- p51-public-pr-reads
- records-1112
- s25-no-session-on-login-error
- v59
- w52-person-approval
- w52b-approval-followup
- w52c-header-phone
- w53-pulls-speed-pr
- w54-repo-rename-pr
- w55-rename-org
- w56-owner-members
- w62-pr-close
- w63-force-push
- w64-org-slash
Latest commits
- 3eeea733log: 2026-11-09 PR flow plan and membersmre
- e7c2ff1fdocs: neutral name for the apps-api reviewmre
- 120b7abdlog: step 3 queuedmre
- 358474bflog: P50 livemre
- 477d7bdcMerge branch 'p50'mre
- 00efc06fP50 reportmre
- e3f85afblog: commit mention slipmre
- 4d1a4cf4log: #25 numbersmre
- 1af0a60ddocs: H25 run() correctionmre
- eefa2dbcRepo setting: refuse direct pushes to the main branch (pre-receive over HTTPS and ssh)mre
- 8c8ba2f1log: PR flow announcedmre
- fa00cd35log: Kunibert pings provenmre
- 3a68cfaclog: components decisionmre
- 87de8e31log: Kunibert connected to 9 app reposmre
- c22aff69log: PR-only rollout startedmre
- 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