gitoria

tickets

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commite17e2855e17e2855re-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)mree17e2855/lib/mdview.hl

6.1 KB

  1. // lib/mdview.hl — THE MARKDOWN READ VIEW FOR LLM READERS (ticket #6, mission 014; CONCEPT.md "Data
  2. // formats": a Markdown read view for LLM readers). The ticket GET endpoints answer
  3. // `Accept: text/markdown` with a compact Markdown document instead of JSON (lib/api-helpers.hl
  4. // `wantsMarkdown`, `markdownReply`); JSON stays the default and is unchanged. Statics only.
  5. //
  6. // one ticket → # <project> #<n>: <subject>
  7. // state · opened (by) · updated · formerly · URL
  8. // the summary as written (it IS Markdown)
  9. // ## History — one `### <seq> · <when> · <author> <what>` per event, its text below
  10. // a list → # Tickets (<filters>): <count>
  11. // one line per ticket: `- <project> #<n> [<state>] <subject> · updated <when> · <url>`
  12. // Texts are embedded as written (they are Markdown already), so a text's own headings sit
  13. // inside the document — readers should take the `### <seq> ·` lines as the event boundaries.
  14. import { publicUrl } from './users.hl'
  15. static NL = "
  16. "
  17. // one line: line breaks and runs of spaces become one space
  18. static oneLine = (s) => {
  19. if (s == null) { return '' }
  20. parts = []
  21. for (w of ('' + s).replaceAll(NL, ' ').split(' ')) { if (w != '') { parts.push(w) } }
  22. return parts.join(' ')
  23. }
  24. // `> ` in front of every line (a previous summary inside an edit event)
  25. static quoted = (s) => {
  26. out = []
  27. for (l of ('' + s).split(NL)) { out.push(l == '' ? '>' : '> ' + l) }
  28. return out.join(NL)
  29. }
  30. static ticketLine = (row) => {
  31. return '- ' + row.project + ' ' + row.ref + ' [' + row.state + '] ' + oneLine(row.subject) + ' · updated ' + row.updated + ' · ' + publicUrl + row.href + relationTail(row)
  32. }
  33. // ---- relations (ticket #4, mission 017) --------------------------------------------------------
  34. // one ticket's document gets "Parent:", "Children (k of n done):", "Blocked by:", "Blocks:"
  35. // blocks under its URL; a list line gets ` · parent … · children n, k done · blocked by … · blocks …`
  36. static refName = (r) => { return r.project + ' ' + r.ref }
  37. static refLine = (r) => { return '- ' + refName(r) + ' [' + r.state + '] ' + oneLine(r.subject) + ' · ' + publicUrl + r.href }
  38. static confirmedOf = (refs) => {
  39. let n = 0
  40. for (r of refs) { if (r.state == 'done') { n = n + 1 } }
  41. return n
  42. }
  43. static relationTail = (row) => {
  44. parts = []
  45. if (row.parent != null) { parts.push('parent ' + refName(row.parent)) }
  46. total = row.children.length
  47. if (total > 0) { parts.push('children ' + total + (row.allChildrenConfirmed ? ', all done' : ', ' + confirmedOf(row.children) + ' done')) }
  48. if (row.blockedBy.length > 0) {
  49. bs = []
  50. for (r of row.blockedBy) { bs.push(refName(r) + ' [' + r.state + ']') }
  51. parts.push('blocked by ' + bs.join(', '))
  52. }
  53. if (row.blocks.length > 0) {
  54. bs = []
  55. for (r of row.blocks) { bs.push(refName(r)) }
  56. parts.push('blocks ' + bs.join(', '))
  57. }
  58. return parts.length == 0 ? '' : ' · ' + parts.join(' · ')
  59. }
  60. static relationLines = (t) => {
  61. lines = []
  62. if (t.parent != null) {
  63. lines.push('')
  64. lines.push('Parent: ' + refName(t.parent) + ' [' + t.parent.state + '] ' + oneLine(t.parent.subject) + ' · ' + publicUrl + t.parent.href)
  65. }
  66. total = t.children.length
  67. if (total > 0) {
  68. lines.push('')
  69. lines.push('Children (' + (t.allChildrenConfirmed ? 'all ' + total + ' done' : confirmedOf(t.children) + ' of ' + total + ' done') + '):')
  70. for (r of t.children) { lines.push(refLine(r)) }
  71. }
  72. if (t.blockedBy.length > 0) {
  73. lines.push('')
  74. lines.push('Blocked by:')
  75. for (r of t.blockedBy) { lines.push(refLine(r)) }
  76. }
  77. if (t.blocks.length > 0) {
  78. lines.push('')
  79. lines.push('Blocks:')
  80. for (r of t.blocks) { lines.push(refLine(r)) }
  81. }
  82. return lines
  83. }
  84. // a list: { tickets } (rows, as the JSON answer) + a label of its filters ('' = all)
  85. static listDocument = (rows, filters) => {
  86. lines = []
  87. lines.push('# Tickets' + (filters != '' ? ' (' + filters + ')' : '') + ': ' + rows.length)
  88. lines.push('')
  89. for (r of rows) { lines.push(ticketLine(r)) }
  90. return lines.join(NL) + NL
  91. }
  92. static eventHeadline = (e) => {
  93. let what = e.label
  94. if (e.kind == 'state') { what = 'changed the state: ' + (e.from != '' ? e.from : '?') + ' → ' + e.to }
  95. // mission 016: an edited comment shows its newest text, the headline says since when (a deleted one: its label)
  96. if (e.edited == true) { what = 'commented (edited ' + e.editedWhen + ')' }
  97. if (e.kind == 'edit') {
  98. parts = []
  99. if (e.subjectChanged) { parts.push('subject') }
  100. if (e.summaryChanged) { parts.push('summary') }
  101. what = 'edited the ' + parts.join(' and ')
  102. }
  103. return '### ' + e.seq + ' · ' + e.when + ' · ' + oneLine(e.author) + ' ' + what
  104. }
  105. // one ticket: { ticket (row), events (rows, oldest first) } as the JSON answer
  106. static ticketDocument = (data) => {
  107. t = data.ticket
  108. let opener = ''
  109. for (e of data.events) { if (e.kind == 'created' && opener == '') { opener = oneLine(e.author) } }
  110. lines = []
  111. lines.push('# ' + t.project + ' ' + t.ref + ': ' + oneLine(t.subject))
  112. lines.push('')
  113. let meta = 'state: ' + t.state + ' · opened ' + t.created + (opener != '' ? ' by ' + opener : '') + ' · updated ' + t.updated
  114. if (t.hasOld) { meta = meta + ' · formerly ' + t.oldRef }
  115. lines.push(meta)
  116. lines.push(publicUrl + t.href)
  117. for (l of relationLines(t)) { lines.push(l) }
  118. lines.push('')
  119. lines.push(t.summary != '' ? t.summary : '(no summary)')
  120. lines.push('')
  121. lines.push('## History')
  122. for (e of data.events) {
  123. lines.push('')
  124. lines.push(eventHeadline(e))
  125. if (e.kind == 'edit') {
  126. if (e.subjectChanged) {
  127. lines.push('')
  128. lines.push('Subject before: ' + oneLine(e.oldSubject))
  129. }
  130. if (e.summaryChanged) {
  131. lines.push('')
  132. lines.push('Summary before:')
  133. lines.push('')
  134. lines.push(e.oldSummary != '' ? quoted(e.oldSummary) : '> (empty)')
  135. }
  136. }
  137. if (e.hasText) {
  138. lines.push('')
  139. lines.push(e.text)
  140. }
  141. // tickets#27: a comment's files, one line each (the address needs a member's login or token)
  142. if (e.attachments != null) {
  143. lines.push('')
  144. lines.push('Attachments:')
  145. for (a of e.attachments) { lines.push('- [' + oneLine(a.name).replaceAll('[', '(').replaceAll(']', ')') + '](' + publicUrl + a.url + ') · ' + a.type + ' · ' + a.size + ' bytes') }
  146. }
  147. }
  148. return lines.join(NL) + NL
  149. }

Branches

Latest commits

  • e17e2855re-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
  • a6ddccd2re-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
  • 81e036b7docker-compose: nofile 65536 (Hybriel int 6+ boot opened >1024 files in the tracker)mre
  • 5d8d2cf6deploy: backup copies index files first and *.mpack data last (hot-copy skew, hybriel #203)mre
  • 58e8c02cmission 024: report, LOG, STATUS, e2e fixmre
  • 50778073tests/e2e-route-marker.mjs: first paint marker, comments post/edit redrawmre
  • c5203298mission 024: MainMenu marks the page from the route (layouts 0bcc629 main-menu.hl); browser-side marker removed; gate: marker in the server HTMLmre
  • b1a4c270re-vendor Hybriel master f9614007: bin/ (git-ignored) and plugins wholemre
  • 866397a0mission 023: theme from layouts 76f99f6 (current marker, menu count badge), components from 3794c59 (MdEditor keys); Inbox count as badge, current by address; gates and E2E; reportmre
  • 7ed2e5e5deploy.sh: a gate without a 'passed,' line (check-theme) no longer ends the script silently (grep under pipefail), as gitoria/layoutsmre
  • bf9064a3mission 022: tickets on the layouts theme (step 1): shell, styles, gates, audit, E2E; reportmre
  • f3d61711mission 022 WIP: tickets on the layouts theme (dbe3de7): AppHeader/MainMenu/UserMenu/Sidebar/ContentFirst shell, styles reduced to the app's own, check-theme in the gates, 390 audit + real-Chrome walk scriptmre
  • 31cabfccmission 021: E2E script, report, LOG, STATUSmre
  • 6aea8683editor look: .empty rule only for p.empty, files off where tickets has no upload, state note one line, events test scrolls the editor into view; synced md-editor (components d702d76+6f27ad3); gate 377/0, events 52/0mre
  • dce6ffa6Merge branch 'w28-deflake'mre
  • 536092a1tickets (mission 019): de-flake the m016 comment clicks (B: unliked) — calmClick waits until the button stops moving; test only, no app changemre
  • 9c5fd42amission 020: attachments E2E proof (lisbeth Chrome, real-data copy), reportmre
  • 1206404fREADME attachments, report 018, LOG/STATUSmre
  • 3d9e7f3ctests: m017 gate fixes (list count, waits before delete clicks); gate 373/0mre
  • dd41d5bcre-sync components 15be2ac; mission 018mre