gitoria
All repositories: gitoria
9.2 KB
// project.hl — gitoria.worldapi.org: THE MAP. Config, routes and WHO HEARS WHAT; the logic lives in lib/. Hybriel on hl:web.//// WHERE THINGS ARE (one line per feature; README.md "Files" has the full list):// repos: create, list, owner, main-branch setting, push rule lib/repos.hl (slug rules, rows, Markdown view: lib/repos-helpers.hl)// users, login through ident, display names lib/users.hl// git on the server (calls, branches, init, temp folder) lib/git.hl (paths, ids, |||PR / |||RL markers: lib/git-helpers.hl)// the repo homepage (README.md / $docs) lib/homepage.hl (Markdown → blocks: lib/markdown.hl)// browsing code (/code, /branch, /commit), "Make main" lib/code.hl// pull requests, the Merge button lib/pulls.hl// releases lib/releases.hl// a repo's tickets, connecting tickets, `#12` links both ways lib/tickets.hl (lib/tickets-helpers.hl)// push and pull over HTTPS (the git protocol's routes) lib/transport.hl (lib/transport-helpers.hl)// access tokens / ssh keys lib/tokens.hl / lib/sshkeys.hl// function routes: API, /login/callback, /settings/connect…, /__git/… lib/api.hl (plumbing: lib/api-helpers.hl)// shared helpers (env, storage dir, addresses, lists, Vienna time) lib/util.hl// pages: shell, repo list, readme, code, pulls, releases, tickets, settings, tokens, keys components/*.hl; CSS components/styles.hl//// HOW A REPO GETS ITS ADDRESS (ticket #6, gitoria#16): nginx sends `gitoria.worldapi.org` AND every// `<slug>.gitoria.worldapi.org` to this one app. Every page component that declares `host = null` gets the// request's host (without port, hybriel#74) on the SERVER, on the first load and on every hl:web navigation:// the main address shows the repo list + "create" (components/index.hl → list.hl), `<slug>.` shows that repo —// each repo view is its own page component on its own route (readme, code, branch, commit, pulls, releases,// tickets), rendered on the server WITH its content: git is read with hl:proc run(), which waits (hybriel#80).// The session cookie carries `Domain=.<host>` (hl:web `sessionDomain`, hybriel#44) so one// login holds on every address; the login button always returns through the main address// (the only origin registered in ident) and then on to the repo the login started from.import WebFramework from 'hl:web'import { env } from 'hl:proc'import Styles from './components/styles.hl'import { dark, darker } from './shared/tokens.hl'import { hostOnly, domainFor, scheme } from './lib/util.hl'import { tagOf } from './lib/users.hl'import { notFoundPage, notFoundApi, apiRepos, apiRepo, loginCallback, shareSession, connectStart, connectBack, gitKeys, gitAccess } from './lib/api.hl'import { gitTransport } from './lib/transport.hl'import Index from './components/index.hl'import Code from './components/code.hl'import Branch from './components/branch.hl'import Commit from './components/commit.hl'import Pulls from './components/pulls.hl'import Releases from './components/releases.hl'import Tickets from './components/tickets.hl'import Settings from './components/settings.hl'import LoginFailed from './components/loginfailed.hl'import NotFound from './components/notfound.hl'static siteName = "gitoria"appTitle = siteNamestyles = Styles// ---- THE INSTALLABLE APP (mission 046), the same way calendar.worldapi.org and tracker do it: hl:web's own web app// manifest (/__hl/manifest.webmanifest, linked from every head with the apple-touch-icon and theme-color) and service// worker (/__hl/sw.js) from these settings — no JavaScript of ours. Icons in icons/ (icon.svg is the source, the PNGs// are rendered from it with rsvg-convert, README "PWA"). The theme colour is the header's background (darker), the// splash background the page's (dark) — both off the tokens. Every repo address is its own origin, so each one gets// its own manifest and worker (start_url / = that repo's Readme).appThemeColor = darker.valueappBackgroundColor = dark.valueappIcons = [{ src = '/icons/icon-192.png' sizes = '192x192' purpose = 'any' }{ src = '/icons/icon-512.png' sizes = '512x512' purpose = 'any' }{ src = '/icons/icon-192.png' sizes = '192x192' purpose = 'maskable' }{ src = '/icons/icon-512.png' sizes = '512x512' purpose = 'maskable' }]appTouchIcon = '/icons/apple-touch-icon.png'appFavicon = '/icons/favicon.svg'// OFFLINE: only the shell and `/` (components/main.hl says "You are offline" while the browser has no network). `/`// is kept as last seen (the worker is network-first and refreshes its copy on every online visit): the repo list on// the main address, the Readme on a repo address. Every other page (code, commits, pulls, …) needs the network and// gets hl:web's "Unavailable offline" page.offline = [ Index ]// EVERY REPO VIEW IS ITS OWN PAGE (gitoria#16); `/` is the list on the main address, the Readme on a repo address.routes = [{ pattern = "/favicon.ico" file = "./icons/favicon.ico" headers = { 'Cache-Control' = 'no-cache' } }// the installable app (mission 046): the icons (manifest and service worker are hl:web's own, from appIcons / offline){ pattern = "/icons/icon-192.png" file = "./icons/icon-192.png" headers = { 'Cache-Control' = 'no-cache' } }{ pattern = "/icons/icon-512.png" file = "./icons/icon-512.png" headers = { 'Cache-Control' = 'no-cache' } }{ pattern = "/icons/apple-touch-icon.png" file = "./icons/apple-touch-icon.png" headers = { 'Cache-Control' = 'no-cache' } }{ pattern = "/icons/favicon.svg" file = "./icons/favicon.svg" headers = { 'Cache-Control' = 'no-cache' } }// the login button's return and the tickets connection write the session: the request and the store go BY REFERENCE (lib/api.hl){ pattern = "/login/callback" function = (route, req) => { return loginCallback(route, &req, &server.sessions) } }{ pattern = "/session/share" function = (route, req) => { return shareSession(route, &req, &server.sessions) } }{ pattern = "/login/failed" component = LoginFailed }{ pattern = "/login.js" file = "./login.js" headers = { 'Cache-Control' = 'no-cache' } }{ pattern = "/api/repos" function = apiRepos }{ pattern = "/api/repos/:slug" function = apiRepo }{ pattern = "/" component = Index }{ pattern = "/code" component = Code }{ pattern = "/code/*path" component = Code }{ pattern = "/branch/*path" component = Branch }{ pattern = "/commit/*path" component = Commit }{ pattern = "/pulls" component = Pulls }{ pattern = "/releases" component = Releases }{ pattern = "/tickets" component = Tickets }{ pattern = "/settings" component = Settings }{ pattern = "/settings/connect" function = (route, req) => { return connectStart(route, &req, &server.sessions) } }{ pattern = "/settings/connected" function = (route, req) => { return connectBack(route, &req, &server.sessions) } }{ pattern = "/__git/keys" function = gitKeys }{ pattern = "/__git/access" function = gitAccess }{ pattern = "/:repo/info/refs" function = gitTransport }{ pattern = "/:repo/git-upload-pack" function = gitTransport }{ pattern = "/:repo/git-receive-pack" function = gitTransport }// THE LAST ROUTES: any other path → the shell's 404 page (the API: a JSON 404){ pattern = "/api/*" function = notFoundApi }{ pattern = "/*" function = (route, req) => { return notFoundPage(route, req, &server, NotFound) } }]// WHO GETS THE PUSH: a new repo reaches every open page (the list follows live)// `gitoriaSignedIn` / `gitoriaSignedOut` go to the tabs of ONE session: the one whose login carries// that random tag (session.data.tag, set at login, users.hl tagOf) — every open page of it switches without a reload.audience = {repoCreated = (row, session) => { return true }ticketOpened = (slug, row, session) => { return true }gitoriaSignedIn = (tag, info, session) => { return tag != null && tagOf(session) == tag }gitoriaSignedOut = (tag, session) => { return tag != null && tagOf(session) == tag }}sessionDir = env('GITORIA_SESSIONS') != null ? env('GITORIA_SESSIONS') : nullport = env('GITORIA_PORT') != null ? toNumber(env('GITORIA_PORT')) : 8360// HL_HOST = the interface hl:web binds (hybriel #24, fixed upstream): 127.0.0.1 on Byrodin behind nginx;// unset = 0.0.0.0 (dev on Loreana). GITORIA_WATCH=0 = no dev watcher. The session cookie is `gitoriasid` (hybriel #10).watching = env('GITORIA_WATCH') != '0'sessionCookie = 'gitoriasid'// the cookie's Domain (hybriel#44): every <slug>.<host> shares the login (util.hl domainFor; '' = host-only → null)sessionDomain = domainFor(hostOnly) != '' ? domainFor(hostOnly) : null// SECURITY (mission SG): the session cookie is `Secure` when the public address is https (the proxy speaks http to us, so the app says so);// no face of ours takes a file, so /__hl/upload (open to anyone, held in memory) refuses every file with a size (uploadMax = 0)sessionSecure = scheme == 'https'uploadMax = 0server = new WebFramework(routes = routes, styles = styles, minify = true, port = port, watchMode = watching, sessionCookie = sessionCookie, sessionDomain = sessionDomain, sessionSecure = sessionSecure, uploadMax = uploadMax, sessionMaxAge = 3122064000)on Error(e) { console.log('error absorbed: ' + e.message) }
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
- a80da7bdWIP gs: security gate for lazy sessions, g24 browser checksmre
- 23fb05d8re-vendor Hybriel aaa39e69 (hl:web batch 20: login emit and Sessions.mint, tab follows a login, signed-in session cookie wins among duplicates and is re-issued with the Domain, W85 faster render, lazy sessions)mre
- a0727ca3ident#31: the selector's sign-in returns to the page the user started on (return attribute = the login callback with next), gate checkmre
- a06975f9gitoria: a gap between your name and Log out in the phone header (they touched); gate checks itmre
- 32ba9d59gitoria: leave the host-only cookie experiment out of the browser gate (gitoria#24 is a separate mission)mre
- 43ad2bcfgitoria header: the selector alone plus your name and Log out as before the theme missions; tests follow (WIP: host-only cookie experiment fails)mre
- ac2c4e3fident selector back in the header (creator 2026-10-24): selector top right signed in and out on phone and desktop, no second Log in button, new gate checks (WIP: gates not re-run after the last edits)mre
- b279f536theme: sync from layouts 4994037 (list rows stack, td word-keep, heading code, edited tap target)mre
- 2b01515ctests/ticketskit: a failed start kills the tickets server (own process group); stop() kills the groupmre
- 109cfc5ctests/ticketskit: keep the rotated session cookie of the tickets login (tickets ST2 session rotation)mre
- 7eb6be27sessions last 99 years (creator 2026-10-23: logins never expire; only sign out ends them)mre
- b3911918reports/MG-mobile.md: 404 fixed, rebased gatesMG
- 9da65b42tests/browser.mjs: 404 checks (host, no hydration wait)MG
- 00517fafgitoria: shell 404 page for unknown paths (catch-all route, status 404, JSON 404 under /api), 390 gate checksMG
- d9e977f0reports/MG-mobile.md, LOGMG
- 2f2725actests/browser.mjs: commit-row check (one row, centred date)MG
- 4df1ea01tests/browser.mjs: MG phone checks (list first, no dead strip, one branch heading, tab grid, commit rows, PR title row, ticket columns, wrapping commands)MG
- c52424e9gitoria mobile: repo list before the forms, 3x2 tab grid, no duplicate branch heading, ordered commit rows, aligned ticket rows, pull title on its own row, wrapping clone commands, no dead strip under formsMG
- 3a95252dG3: cache parsed README blocks by sha256 of the text (bounded LRU), reportmre
- 570138cddeploy: security gate (tests/security.mjs)mre