gitoria

tickets

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitf04afc43f04afc43tickets: MdEditor from components 59704ce (a file manager copy still attaches, pipe rows, tickets#49)mref04afc43/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

  • f04afc43tickets: MdEditor from components 59704ce (a file manager copy still attaches, pipe rows, tickets#49)mre
  • 06599fa0tickets: MdEditor from components b0f1ec2 (a clipboard with text always pastes the text, tickets#49); real Ctrl+V gatemre
  • 2e1b116ftickets: re-vendor Hybriel master acaceaf3 (framework ec8d6c1d): plugins/web patch queue while a page is built, anonymous session cookies refresh; gate waits for the comment editors to draw (W174) and clicks the form editor when it stands still; security gate: main's code runs on its own binary, lazy-session cookie checksmre
  • 361bc0fetickets: re-vendor Hybriel 7a684920 (WIP, not deployed); on Error exits 1 at startup; migrate passes its log by reference; gate checks follow lazy sessions and the 413 refusalmre
  • 8a69999cident#28: /login/callback never signs out the session it finds; a valid code puts the user on the same sessionmre
  • 337e9b21tickets#37: a comment's files are open to everyone who can read the commentmre
  • 1800600ftickets: write the standby service out in full so the boot gate can read the main servicemre
  • 8179d287tickets: standby service on its port plus 10 and a deploy that hands over through it without a gapmre
  • 0398145ctickets: the table grid rule is marked functional for check-thememre
  • 40fddc20tickets takes components e54f83a: tables get thin grey lines from the theme, desktop toolbar stays one row with the Table button, F4 check counts 11 buttonsmre
  • c1b77d61tickets#35: text typed before the editor is built is taken in once by the build (the input handler no longer writes it to the field first, which doubled the first letters); the gate failure shows the surfacemre
  • 32bf1873tickets#35: the gate types right after the load with the CPU slowed, no waitingmre
  • 64ea9ca2tickets#35: text typed into the reply editor before the page has finished starting is kept; the gate types right after loadmre
  • ccd3a327tickets: the security gate expects frame-src to be exactly the ident address (the sign-in frame), still no wildcard or selfmre
  • 4348dbabident#31: the selector's sign-in returns to the page the user started on (return attribute = the login callback with next), gate checkmre
  • 66ef3005Merge branch 'iw-ident-widget'mre
  • bc0ad663tickets: a gap between your name and Log out in the phone header (they touched); gate checks itmre
  • 2f818d46UX2: report, LOG line, e2e fixes, gate pause after loadmre
  • af3ef7c4gate: the legacy state line says progressmre
  • 62480a00tickets#33: a state change with a note is a comment card in the feed (same framework rendering, can be liked, edited, deleted), its state line stands alone; gate checks for a new comment with and without a state change, at once and after a reloadmre