gitoria
All repositories: gitoria
2.4 KB
// lib/orgs.hl — ORGANIZATIONS (ticket gitoria#34, GO34). An organization is a name that is its own address <org>.<domain>; its repos live at// <org>.<domain>/<repo> and look like a repo page on <repo>.<domain>. One hl:mpackdb table, storage/mpackdb/orgs.db:// pk @id index !slug, owner { slug, owner (users @id), priv (true = every repo of it is private, also new ones), created }// An organization's name and a repo's name share one namespace (both are subdomains): lib/repos.hl checks both. Who belongs to an// organization is the one member list of lib/members.hl. Statics only; no page code.import { MPackDB } from 'hl:mpackdb'import { now } from 'hl:time'import { storageDir, firstOf, slugOfHost } from './util.hl'static orgsTable = new MPackDB(file = storageDir + '/orgs.db', primaryKey = '@id', indexes = ['!slug', 'owner'])static orgBySlug = (slug) => {if (slug == null || hlTypeName(slug) != 'String' || slug == '') { return null }return firstOf(orgsTable.find('slug', slug))}static putOrg = (slug, owner, priv) => {id = orgsTable.put({ slug = slug owner = owner priv = priv created = now() })return id == null ? null : orgsTable.fetch(id)}static setOrgPriv = (o, priv) => {orgsTable.update(o.id, { id = o.id slug = o.slug owner = o.owner priv = priv created = o.created })after = orgsTable.fetch(o.id)return after != null && after.priv == priv}// every organization recordstatic allOrgs = () => {all = orgsTable.find(null, null)return all == null || all.length == null ? [] : all}// THE REPO NAME OF A REQUEST: `host` (no port) and `orepo` (the first path segment of an organization's address, '' elsewhere).// '' = the main address; `name` = a repo's own address; `org/name` = a repo inside an organization; '!x' = a path that names// no repo (a first segment on a host that is not an organization) — "No such repository".static slugOfRequest = (host, orepo) => {label = slugOfHost(host)if (orepo == null || orepo == '') { return label }if (label != '' && orgBySlug(label) != null) { return label + '/' + orepo }return '!'}// the first path segment of an organization's address (the repo inside it), '' on every other host or at the organization's rootstatic orepoOfPath = (host, path) => {label = slugOfHost(host)if (label == '' || path == null || orgBySlug(label) == null) { return '' }rest = path.startsWith('/') ? path.slice(1) : pathi = rest.indexOf('/')return i < 0 ? rest : rest.slice(0, i)}
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
- 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
- 09955dedMerge v48: Hybriel set-day48, theme layouts ce4a0bamre
- f2a2b0cevendor: Hybriel set-day48, theme layouts ce4a0bamre
- 5d0834e7log: Apollo model rulemre
- fe8e5bd5log: #25 sample, V48 missionmre
- 8580c5d9log: theme fix from Atlasmre
- 46823d93log: Apollo budget correctionmre
- f6d32341log: Apollo on budget and #25 nextmre
- d7184f53log: batch live, #25 evidencemre
- 5e25e816log: W61 mergedmre
- aafe330dTidy: drop evidence JSON (kept in scratch), collapse blank linesmre
- aca1fda1Merge W61: theme from layouts 17e0f03, Views refer to Style rules (gitoria#37 #27)mre
- 03cb650blog: W61 theme decisionmre