tickets
All repositories: gitoria
6.1 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 }// mission 016: an edited comment shows its newest text, the headline says since when (a deleted one: its label)if (e.edited == true) { what = 'commented (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}
Branches
Latest commits
- 01fad593inbox: format Style with nested language rulesmre
- 79dc9392you: format Style with nested language rulesmre
- 78073baamain: format Style with nested language rulesmre
- 5499c290Sync theme unchanged from layouts 17e0f03mre
- fd33ee21Sync reviewed components from 8176eb1mre
- 93348453Re-vendor tickets to Hybriel set day35mre
- a4123831tickets#42: the /connect and /login/callback error pages are app pages: the function routes redirect to /connect/failed/<code> and /login/failed/<code> (components/problem.hl, sentences in lib/problems.hl), htmlPage and its hand-written stylesheet are gone; gate tests/error-pages.mjsmre
- cefc7b4atickets: a startup error prints its message before exit 1 (hybriel#247)mre
- 99bd6570tickets: lib/migrate.hl writes no table of another topic any more: projects.hl rewriteSlug / addProjectNamed / hasMembers, tickets.hl moveToProject / ticketRecords / ticketRecordsOf, events.hl renameStates / eventRecords / eventRecordsOf; the migration calls them (tickets#47)mre
- b57161e3tickets: the markup names its own rules (Style.pMessage, Style.olTickets, ...) instead of hand-written class strings that copy a stylesheet rule; the shared bodies sit in lib/looks.hl (tickets#38)mre
- f767b24dtickets: 111 needless let became plain declarations (3 in ticket.hl, ticket_list.hl, comments.hl and 108 never-reassigned, not captured loop-body ones); the 212 really reassigned lets stay (tickets#44)mre
- 16c0d3b5tickets: the modal window is phone first: the full-screen sheet is the base rule, the centred window sits in the min-width 60rem block (tickets#39)mre
- 090ee809tickets: every component's styles in its own nested Style {} block; styles.hl keeps only the theme inherit, the accent and the site-wide rules (tickets#36)mre
- d395763ftickets: ident-access gate ports 8769/8768 (8797 is taken on loreana)mre
- afb9a403tickets: an ident access key (Authorization: Bearer idt_…) works in the API (ident#27 app side): lib/ident-access.hl copied from components, read keys GET only, ident down 503; gate tests/ident-access-tickets.mjsmre
- 48c1ba79tickets: md-paste-files gate with the file manager casesmre
- 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