tickets
All repositories: gitoria
6.3 KB
// lib/mdview.hl — THE MARKDOWN READ VIEW FOR LLM READERS (ticket #6, mission 014; CONCEPT.md "Data// formats": a Markdown read view for LLM readers). The ticket GET endpoints answer// `Accept: text/markdown` with a compact Markdown document instead of JSON (lib/api-helpers.hl// `wantsMarkdown`, `markdownReply`); JSON stays the default and is unchanged. Statics only.//// one ticket → # <project> #<n>: <subject>// state · opened (by) · updated · formerly · URL// the summary as written (it IS Markdown)// ## History — one `### <seq> · <when> · <author> <what>` per event, its text below// a list → # Tickets (<filters>): <count>// one line per ticket: `- <project> #<n> [<state>] <subject> · updated <when> · <url>`// Texts are embedded as written (they are Markdown already), so a text's own headings sit// inside the document — readers should take the `### <seq> ·` lines as the event boundaries.import { publicUrl } from './users.hl'static NL = ""// one line: line breaks and runs of spaces become one spacestatic oneLine = (s) => {if (s == null) { return '' }parts = []for (w of ('' + s).replaceAll(NL, ' ').split(' ')) { if (w != '') { parts.push(w) } }return parts.join(' ')}// `> ` in front of every line (a previous summary inside an edit event)static quoted = (s) => {out = []for (l of ('' + s).split(NL)) { out.push(l == '' ? '>' : '> ' + l) }return out.join(NL)}static ticketLine = (row) => {return '- ' + row.project + ' ' + row.ref + ' [' + row.state + '] ' + oneLine(row.subject) + ' · updated ' + row.updated + ' · ' + publicUrl + row.href + relationTail(row)}// ---- relations (ticket #4, mission 017) --------------------------------------------------------// one ticket's document gets "Parent:", "Children (k of n done):", "Blocked by:", "Blocks:"// blocks under its URL; a list line gets ` · parent … · children n, k done · blocked by … · blocks …`static refName = (r) => { return r.project + ' ' + r.ref }static refLine = (r) => { return '- ' + refName(r) + ' [' + r.state + '] ' + oneLine(r.subject) + ' · ' + publicUrl + r.href }static confirmedOf = (refs) => {let n = 0for (r of refs) { if (r.state == 'done') { n = n + 1 } }return n}static relationTail = (row) => {parts = []if (row.parent != null) { parts.push('parent ' + refName(row.parent)) }total = row.children.lengthif (total > 0) { parts.push('children ' + total + (row.allChildrenConfirmed ? ', all done' : ', ' + confirmedOf(row.children) + ' done')) }if (row.blockedBy.length > 0) {bs = []for (r of row.blockedBy) { bs.push(refName(r) + ' [' + r.state + ']') }parts.push('blocked by ' + bs.join(', '))}if (row.blocks.length > 0) {bs = []for (r of row.blocks) { bs.push(refName(r)) }parts.push('blocks ' + bs.join(', '))}return parts.length == 0 ? '' : ' · ' + parts.join(' · ')}static relationLines = (t) => {lines = []if (t.parent != null) {lines.push('')lines.push('Parent: ' + refName(t.parent) + ' [' + t.parent.state + '] ' + oneLine(t.parent.subject) + ' · ' + publicUrl + t.parent.href)}total = t.children.lengthif (total > 0) {lines.push('')lines.push('Children (' + (t.allChildrenConfirmed ? 'all ' + total + ' done' : confirmedOf(t.children) + ' of ' + total + ' done') + '):')for (r of t.children) { lines.push(refLine(r)) }}if (t.blockedBy.length > 0) {lines.push('')lines.push('Blocked by:')for (r of t.blockedBy) { lines.push(refLine(r)) }}if (t.blocks.length > 0) {lines.push('')lines.push('Blocks:')for (r of t.blocks) { lines.push(refLine(r)) }}return lines}// a list: { tickets } (rows, as the JSON answer) + a label of its filters ('' = all)static listDocument = (rows, filters) => {lines = []lines.push('# Tickets' + (filters != '' ? ' (' + filters + ')' : '') + ': ' + rows.length)lines.push('')for (r of rows) { lines.push(ticketLine(r)) }return lines.join(NL) + NL}static eventHeadline = (e) => {let what = e.labelif (e.kind == 'state') { what = 'changed the state: ' + (e.from != '' ? e.from : '?') + ' → ' + e.to }// An edited note keeps its event label and transition; the marker describes the text edit.if (e.edited == true) { what = what + ' (edited ' + e.editedWhen + ')' }if (e.kind == 'edit') {parts = []if (e.subjectChanged) { parts.push('subject') }if (e.summaryChanged) { parts.push('summary') }what = 'edited the ' + parts.join(' and ')}return '### ' + e.seq + ' · ' + e.when + ' · ' + oneLine(e.author) + ' ' + what}// one ticket: { ticket (row), events (rows, oldest first) } as the JSON answerstatic ticketDocument = (data) => {t = data.ticketlet opener = ''for (e of data.events) { if (e.kind == 'created' && opener == '') { opener = oneLine(e.author) } }lines = []lines.push('# ' + t.project + ' ' + t.ref + ': ' + oneLine(t.subject))lines.push('')let meta = 'state: ' + t.state + ' · opened ' + t.created + (opener != '' ? ' by ' + opener : '') + ' · updated ' + t.updatedif (t.hasOld) { meta = meta + ' · formerly ' + t.oldRef }lines.push(meta)lines.push(publicUrl + t.href)for (l of relationLines(t)) { lines.push(l) }lines.push('')lines.push(t.summary != '' ? t.summary : '(no summary)')lines.push('')lines.push('## History')for (e of data.events) {lines.push('')lines.push(eventHeadline(e))if (e.kind == 'edit') {if (e.subjectChanged) {lines.push('')lines.push('Subject before: ' + oneLine(e.oldSubject))}if (e.summaryChanged) {lines.push('')lines.push('Summary before:')lines.push('')lines.push(e.oldSummary != '' ? quoted(e.oldSummary) : '> (empty)')}}if (e.hasText) {lines.push('')lines.push(e.text)}// tickets#27: a comment's files, one line each (the address needs a member's login or token)if (e.attachments != null) {lines.push('')lines.push('Attachments:')for (a of e.attachments) { lines.push('- [' + oneLine(a.name).replaceAll('[', '(').replaceAll(']', ')') + '](' + publicUrl + a.url + ') · ' + a.type + ' · ' + a.size + ' bytes') }}}return lines.join(NL) + NL}static moveJournalDocument = (Hybrid moves) => {if (moves.length == 0) { return '' }lines = ['' '## Project move history']for (m of moves) { lines.push('- ' + m.when + ' · ' + m.text + ' · ' + m.href) }return lines.join(NL) + NL}
Branches
Latest commits
- 610d8e8aMerge branch 'records-t39' into mainTickets
- 32bcdf24|||PR records: GO P39 K40mre
- 4123c6d1Merge branch 'records-t38' into mainTickets
- cd3641a1|||PR records: day72 deploy live, tickets closedmre
- 7d44d852Merge branch 'records-t37' into mainTickets
- 926f7061|||PR records: merges, D36 deploymre
- bf58534eMerge branch 'l33-final' into mainTickets
- 759a9ac3|||PR thin login (tickets#46, #45): merge main, route entry cleanupmre
- 239436d8Merge remote-tracking branch 'origin/main' into l33-finalmre
- 5822cb3aMerge branch 'o34-clean' into mainTickets
- 0870653c|||PR offline note from __hlOnline, no polling (tickets#41)mre
- 14cf96b4Merge branch 'records-t36' into mainTickets
- 07749fa1|||PR records: day72 + #40 mergedmre
- ecd7e226|||PR Consolidate login and move handler logic into topic libraries (partial)mre
- 6dea1c60Merge branch 'r35-day72' into mainTickets
- 7bcfdc22|||PR drop worker edits to conductor recordsmre
- 2617b6ee|||PR dialogs: host flag cleared on close, dialog gate (tickets#40)mre
- 6e701371|||PR record partial day72 dialog validationmre
- b9fb9a91|||PR bind ticket dialog visibility to member flagsmre
- 0788e65f|||PR re-vendor Hybriel day72mre