gitoria

gitoria

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitf0cbe6a6f0cbe6a6gitoria: standby service on port 45014 and a deploy that hands over through it without a gapmref0cbe6a6/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

  • f0cbe6a6gitoria: standby service on port 45014 and a deploy that hands over through it without a gapmre
  • 727cd083gitoria#25: README: vendor notes for Hybriel c1b1010f and the page cachemre
  • 61b72dedgitoria#25: re-vendor Hybriel master c1b1010f (W149 page cache), key the repo Readme page by slug and main commit, extend the readme-cache gatemre
  • 5b0b4b9ereadme-cache gate: use the security gate's ports when no own ports are givenmre
  • bc8f20d9gitoria#25: re-vendor Hybriel c09538bb with the W141 render cache, cache the homepage per commit, add the readme-cache gatemre
  • 9feebbd3Re-vendor Hybriel to ded47c13 (W145: Firefox start script fix)mre
  • 28ed41e5gitoria#24: one sign-in comes from hl:web batch 20, the /session/share workaround is gonemre
  • 3b2669e4gs: drop the unbuildable legacy check, fix pwa fetchmre
  • 2a2fdd77gs: C2 check before cookie experimentsmre
  • 76e0587aWIP gs 2mre
  • 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