gitoria
All repositories: gitoria
8.4 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 } from './lib/util.hl'import { tagOf } from './lib/users.hl'import { apiRepos, apiRepo, loginCallback, 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'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 = "/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 }]// 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) : nullserver = new WebFramework(routes = routes, styles = styles, minify = true, port = port, watchMode = watching, sessionCookie = sessionCookie, sessionDomain = sessionDomain)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
- 63cfa21ereports/G2-repotabs.mdmre
- 9b0516fdgitoria#22: mark the tab underline functional (check-theme), chain E2E: serve/measure split, bring the lisbeth tab to frontmre
- 19bc1df8gitoria#22: all repo pages under ONE layout level (components/repo.hl, hl:web D-CHAIN): a tab click replaces only the page in the slot; head and tab nav stay the same DOM nodesmre
- 40658417tests/browser.mjs: wait for the page to be live (hydrated) before clicking Merge — a click on the server-rendered button before the client mounted was lost (flaky 'Clashing change' under load)mre
- 48a6154bre-vendor Hybriel 5406d146 (hl:web batches 9+10: #72 emits while the socket is closed delivered after reconnect, browser boot linear, faster list appends; contains int 6–14 + m406)mre
- e972e8d7tests: short-id-switch (GITORIA_SWITCH_IDENT_PORT/_PORT) and ssh tunnel (GITORIA_GATE_TUNNEL_PORT) ports from env, defaults unchangedmre
- f06f5349re-vendor Hybriel 6f8a0689 (int 6–11: streaming cursors, #203 index heal + close() fix, fd403 listDir/cursor fds, hl:time browser side, hl:web batches 5+6)mre
- c7d3cc87docker-compose: nofile 65536 (Hybriel int 6+ boot opened >1024 files in the tracker)mre
- f0e7ff8cdeploy: backup copies index files first and *.mpack data last (hot-copy skew, hybriel #203)mre
- fe5f707cgitoria 010: report, mission, comment on why current = true staysmre
- 9705ca86gitoria 010: gate: menu marker in the server HTMLmre
- 8cff663agitoria 010: main-menu.hl from layouts 0bcc629 (route marker)mre
- 359c79f7gitoria 010: re-vendor Hybriel master f9614007 (plugins whole, bin/ git-ignored)mre
- 6bd7fb3cgitoria 009: theme re-copied from layouts 76f99f6 (menu marks the current page), current = true on the menu item, e2e marker checks, reportmre
- 44de915cidentkit: refuse a taken ident port, cold-start deadline, abort on dead ident, clear no-code error (as notes)mre
- 2bf5343egitoria 007: theme re-copied from layouts dbe3de7 (44 px taps), redundant tap overrides dropped, crumbs class, real-browser walk test, reportmre
- 18843648deploy.sh: a gate without a 'passed,' line (check-theme) no longer ends the script silently (grep under pipefail) — print check-theme's summary, as layouts doesmre
- e6dff0cbgitoria#23: report 005, STATUS, LOGmre
- 7f992d62gitoria#23: phone first on the shared theme — brand, branch and pull links 44 px, readme code 14 px; gate block "phone first" (15 pages at 390 + the three dropdowns, fails 20 on old), dropdown-aware login/logout clicks, check-theme in GATESmre
- a2a840a5gitoria#23 WIP (quota stop): theme from layouts, styles inherit it, shell on the theme's header/menus/sidebar, phone measurement script; gates not runmre