tickets
All repositories: gitoria
4.5 KB
// components/connect.hl — `/connect/:nonce` (ticket #21): another app (first: gitoria) asks to be connected to one// project. The person — logged in through ident, with a display name — picks a project they are ADMIN of, or makes a// new one, and confirms. Then the page links back to the app with a one-time code (connections.hl); the app's server// swaps the code for a key that reaches that one project. Everybody else sees the login hint; a used or expired// request says so. Everything is checked again by the store in the faces.parent './main.hl'import { requestOf, requestView, adminProjects, confirmRequest } from '../lib/connections.hl'import { siteName } from '../project.hl'import { userOfSession, writerOfSession, canWriteSession } from '../lib/users.hl'nonce = nullsession = nullpending = requestOf(nonce)valid = pending != nullgone = pending == nullinfo = pending != null ? requestView(pending) : { app = '' label = '' hasLabel = false host = '' }appName = info.appappLabel = info.labelhasLabel = info.hasLabelappHost = info.hostcanWrite = valid && canWriteSession(session)showForm = valid && canWriteSession(session)mustLogIn = valid && !canWriteSession(session)choices = adminProjects(userOfSession(session))choice = choices.length > 0 ? choices[0].id : ''makeNew = choices.length == 0newTitle = ''message = ''done = falsedoneUrl = ''doneProject = ''__title = siteName + ' | connect ' + (pending != null ? pending.app : 'an app')View {connectPage {if (gone) { p { id = "gone" class = "empty" "This connection request is used up or expired. Start again from the app." } }if (valid) {h1 { id = "connecttitle" "Connect " appName " to a project" }p { id = "connectwho" class = "hint"strong { appName }if (hasLabel) { " (" appLabel ")" }" at "strong { appHost }" asks for a key to ONE of your projects. With it the app can open tickets, comment and change their state there — for the people who work in it, within their roles. You can disconnect it on the project's page at any time."}}if (mustLogIn) { p { id = "loginhint" class = "hint" "Log in with ident (top right) and choose a display name to connect." } }if (showForm) {form { id = "connectform"on submit(e) {e.preventDefault()emit confirm(e)}label { "Project"select { id = "connectproject" name = "project" value = choice on change(e) { emit setChoice(e.target.value) }for (c of choices) { option { value = c.id c.title } }option { value = "" "A new project" }}}if (makeNew) {label { "Title of the new project"input { id = "connecttitleinput" name = "title" required = "required" maxlength = "100" autocomplete = "off" value = newTitle on input(e) { emit setNewTitle(e.target.value) } }}}button { id = "connectconfirm" type = "submit" "Connect" }p { id = "connectmessage" class = "message" message }}}if (done) {p { id = "connected" class = "notice" "Connected to " strong { doneProject } ". " }a { id = "connectcontinue" class = "button" href = doneUrl "Continue to " appName }}}}on setChoice(v) {choice = vmakeNew = v == ''}on setNewTitle(v) { newTitle = v }on confirm(e) {if (makeNew && newTitle.trim() == '') { return null }r = emit server connectConfirm(nonce, choice, newTitle)if (r == null || r.error != null) {message = r != null ? r.error : 'could not connect'return null}message = ''showForm = falsedoneUrl = r.urldoneProject = r.projectdone = true}on client signedIn(tag, info) {r = emit server connectChoices()if (r != null && r.projects != null) {choices = r.projectschoice = r.projects.length > 0 ? r.projects[0].id : ''makeNew = r.projects.length == 0}canWrite = valid && info.namedshowForm = valid && info.named && !donemustLogIn = valid && !info.named}on client signedOut(tag) {canWrite = falseshowForm = falsemustLogIn = validchoices = []}on server connectChoices(session) {u = userOfSession(session)if (u == null) { return { error = 'log in first' } }return { projects = adminProjects(u) }}on server connectConfirm(nonce, projectId, title, session) {w = writerOfSession(session)if (w.error != null) { return { error = w.error } }if (hlTypeName(nonce) != 'String' || hlTypeName(projectId) != 'String' || hlTypeName(title) != 'String') { return { error = 'nonce, project and title must be text' } }r = confirmRequest(nonce, w.user, projectId, title)if (r.error != null) { return { error = r.error } }return { url = r.url project = r.project slug = r.slug }}
Branches
- mainmain branch
Latest commits
- a75e0279mission 010 (code order) 3/4: let only where a variable is reassigned or re-bound in a loop body (456 lets → plain declarations; Hybriel refuses a plain declaration inside a loop on its 2nd pass). gate 249/0, connect 60/0, real-data reads identical, a 50-step write sequence (API + faces) identical to the old codemre
- e9d5c618mission 010 (code order) 2/4: one lib/ file per topic — store.hl split into projects / tickets (+ relations) / events / tickets-helpers, util.hl shared helpers (env, storage dir, URLs, sorts, Vienna time), the function routes out of project.hl into lib/api.hl (thin; auth/filters/Accept in api-helpers.hl), invite + member-removal logic out of the faces/routes into invites.hl / tickets.hl; project.hl is the map. /login/callback gets req + the session store by reference. gate 249/0, connect 60/0, real-data reads identicalmre
- 97e269b5mission 010 (code order) 1/4: .hl files out of the root — lib/ (store, users, connections, invites, migrate, markdown, mdview, import = ticketfile, util = localtime, jsoncheck, api-helpers = api), tools/import.hl, components/styles.hl; import paths only. gate 249/0, connect 60/0, real-data reads identicalmre
- 38f9d10ftickets: Hybriel master 06617221 (plugin allocators 3a781359 + 413f60e4, mpackdb 2cb7ae5e, http1 773de63e); gate 249/0, connect 60/0mre
- d3db6139tickets: Hybriel master 190aa11d (fc838894 GC correctness, #126 closure scopes, #127); gate 249/0, connect 60/0mre
- bce182e3tickets: Hybriel master 7eea0d32 (#126 memory, #48 lambda copies its argument); migrate.hl lambdas take &logmre
- 4137be0fantcolony#40: mission references point to the moved missionsmre
- 9bfba36aantcolony#40: history (LOG.md), worker briefs (missions/) and reports moved here from antcolony, numbered per project; old numbers in antcolony docs/mission-map.mdmre
- c7bd2645tickets: Hybriel master 73267707 (#122 fixed); compactNow workaround removed (#110 covered)mre
- 2ab91ee9tickets: gate checks rows appear once (session sync); re-vendor to ff51cf46 stopped on hybriel#122, stays 837fe120mre
- e01c2b1dtickets#24: installable app (manifest, service worker, offline list), own icon; gate waits for the hello's pongmre
- 752fbb7fdeploy.sh: back up live storage/.sessions/.env before every deploy (newest 5 kept)mre
- 38bdd5e4deploy.sh: never send .git or .gitignore to Byrodinmre
- f12fa1bcState of 2026-09-27, before the move to gitoriamre