gitoria

gitoria

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit32ba9d5932ba9d59gitoria: leave the host-only cookie experiment out of the browser gate (gitoria#24 is a separate mission)mre32ba9d59/components/tickets.hl

5.2 KB

  1. // components/tickets.hl — THE TICKETS of a repo (gitoria#10, gitoria#16): `/tickets` on <slug>.<domain>, its own
  2. // route, rendered on the SERVER with its list: the repo comes from the request's host, the tickets from
  3. // tickets.worldapi.org (lib/tickets.hl — hl:fetch answers at once, so the list is in the first HTML and in every
  4. // hl:web navigation). The repo must be connected to a tickets project first (gitoria#18, /settings). A named user
  5. // opens a ticket AS THEMSELVES (the repo's key + their ident id, tickets.hl); a ticket opened here reaches every open
  6. // tickets page of the repo (push `ticketOpened`).
  7. parent './repo.hl'
  8. import { siteName } from '../project.hl'
  9. import { slugOfHost } from '../lib/util.hl'
  10. import { infoOfSession, userOfSession } from '../lib/users.hl'
  11. import { repoAt } from '../lib/repos.hl'
  12. import { pageTitle } from '../lib/repos-helpers.hl'
  13. import { loadTickets, openTicket } from '../lib/tickets.hl'
  14. host = null
  15. session = null
  16. slug = slugOfHost(host)
  17. repo = repoAt(slug)
  18. hasRepo = repo != null
  19. me = infoOfSession(session)
  20. canCreate = repo != null && repo.ticketsOn && me != null && me.named
  21. needsLogin = repo != null && repo.ticketsOn && me == null
  22. notConnected = repo != null && repo.ticketsOff
  23. loaded = repo != null && repo.ticketsOn ? loadTickets(slug) : null
  24. ticketsErrorShown = loaded != null && loaded.error != null
  25. ticketsError = loaded != null && loaded.error != null ? loaded.error : ''
  26. tickets = loaded != null && loaded.tickets != null ? loaded.tickets : []
  27. ticketsTruncated = loaded != null && loaded.truncated == true
  28. ticketsHref = loaded != null && loaded.url != null ? loaded.url : ''
  29. ticketsShown = tickets.length > 0
  30. ticketsNone = loaded != null && loaded.error == null && tickets.length == 0
  31. ticketError = ''
  32. ticketNotice = ''
  33. hasTicketNotice = false
  34. __title = pageTitle(siteName, slug, 'Tickets')
  35. View {
  36. repoPage {
  37. if (hasRepo) {
  38. repoTickets { id = "tickets"
  39. if (notConnected) { p { id = "ticketsnotconnected" class = "empty" "This repository is not connected to a tickets project. The owner connects it under " a { id = "tosettings" href = "/settings" "Settings" } "." } }
  40. if (ticketsErrorShown) { p { id = "ticketserror" class = "message" ticketsError } }
  41. if (canCreate) {
  42. details { id = "newticket"
  43. summary { "New ticket" }
  44. form { id = "newticketform"
  45. on submit(e) {
  46. e.preventDefault()
  47. emit openIt(e)
  48. }
  49. label { "Subject"
  50. input { id = "ticketsubject" name = "subject" required = "required" maxlength = "200" autocomplete = "off" }
  51. }
  52. label { "Text (Markdown, optional)"
  53. textarea { id = "ticketsummary" name = "summary" rows = "5" }
  54. }
  55. button { id = "ticketsave" type = "submit" "Open ticket" }
  56. p { id = "newticketerror" class = "message" ticketError }
  57. }
  58. }
  59. }
  60. if (needsLogin) { p { id = "ticketsloginhint" class = "muted" "Log in with ident (top right) to open a ticket." } }
  61. if (hasTicketNotice) { p { id = "ticketnotice" class = "notice" ticketNotice } }
  62. if (ticketsNone) { p { id = "noticketsyet" class = "empty" "No ticket yet in this project." } }
  63. if (ticketsShown) {
  64. ol { id = "ticketlist"
  65. for (t of tickets) {
  66. li {
  67. a { class = "number" href = t.url "#" t.number }
  68. a { class = "subject" href = t.url t.subject }
  69. span { class = "state" t.state }
  70. time { t.updated }
  71. }
  72. }
  73. }
  74. p { class = "muted" "Open a ticket to read and answer it in " a { id = "ticketsall" href = ticketsHref "tickets.worldapi.org" } "." }
  75. if (ticketsTruncated) { p { id = "ticketstruncated" class = "muted" "Only the latest tickets are listed here." } }
  76. }
  77. }
  78. }
  79. }
  80. }
  81. on openIt(e) {
  82. f = e.target.elements
  83. r = emit server gitoriaOpenTicket(slug, f.subject.value, f.summary.value)
  84. if (r == null || r.error != null) {
  85. ticketError = r != null ? r.error : 'could not open the ticket'
  86. return null
  87. }
  88. ticketError = ''
  89. f.subject.value = ''
  90. f.summary.value = ''
  91. ticketNotice = 'Opened ticket #' + r.ticket.number + '.'
  92. hasTicketNotice = true
  93. addTicket(r.ticket)
  94. }
  95. addTicket = (row) => {
  96. next = [row]
  97. for (x of tickets) { if (x.number != row.number) { next.push(x) } }
  98. tickets = next
  99. ticketsShown = true
  100. ticketsNone = false
  101. }
  102. // a ticket opened here by anyone: every open tickets page of that repo follows
  103. on client ticketOpened(slugOf, row) {
  104. if (!hasRepo || slugOf != slug) { return null }
  105. addTicket(row)
  106. }
  107. // this session's tabs follow a login / name / logout (the shell's faces push them)
  108. on client gitoriaSignedIn(tag, info) {
  109. canCreate = repo != null && repo.ticketsOn && info.named
  110. needsLogin = false
  111. }
  112. on client gitoriaSignedOut(tag) {
  113. canCreate = false
  114. needsLogin = repo != null && repo.ticketsOn
  115. }
  116. on server gitoriaOpenTicket(slugOf, subject, summary, session) {
  117. if (repoAt(slugOf) == null) { return { error = 'no such repository' } }
  118. u = userOfSession(session)
  119. if (u == null) { return { error = 'log in with ident (top right) to open a ticket' } }
  120. if (u.name == '') { return { error = 'choose a display name first (top of the page)' } }
  121. r = openTicket(slugOf, u.identity, subject, summary)
  122. if (r.error != null) { return { error = r.error } }
  123. emit client ticketOpened(slugOf, r.ticket)
  124. return r
  125. }

Branches

Latest commits

  • 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
  • da6b20fcgitoria SG: security audit fixes (uploadMax 0, Secure cookie on https, session rotation at login, nosniff on function routes, no identity in page data) + tests/security.mjs gate + reportmre
  • f98c981fgitoria B1: report wordingmre
  • c6364cedgitoria B1: compact Markdown blocks (one kind flag per block/span, empty and false fields omitted); same rendered HTML, page values -67%mre
  • cd99d2feWIP gitoria#22: always render the repo level's slot (missing-repo boot hang), pages render nothing without a repo; hydration diagnosis in reports/G2-hydrate.mdmre