diff --git a/docs/assets/app.css b/docs/assets/app.css index 78f774a..e8e314a 100644 --- a/docs/assets/app.css +++ b/docs/assets/app.css @@ -7202,8 +7202,7 @@ body[data-active-view="ask"] section[data-view="ask"] { .check-run:hover { filter: brightness(1.08); } .check-toggle { margin-left: auto; } .check-output { border-top: 1px solid var(--rule); padding-top: 16px; } -.check-summary { font-size: 16px; margin: 0 0 10px; } -.check-legend { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; } +.check-summary { font-size: 16px; margin: 0 0 14px; } .ck-pill { display: inline-block; font-family: var(--mono); font-size: 10px; letter-spacing: 0.05em; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--rule); background: var(--paper-2); color: var(--ink-2); @@ -7243,8 +7242,28 @@ mark.ck ins { color: var(--status-good, #2f6b3a); text-decoration: none; font-st .ck-raw .dim { font-size: 12px; } .ck-resolved { margin-top: 6px; font-size: 13px; color: var(--ink-2); display: flex; flex-wrap: wrap; align-items: center; gap: 6px; } .ck-resolved .badge { margin-right: 2px; } -.ck-copy-cite { font: inherit; font-size: 12px; background: none; border: 1px solid var(--rule); border-radius: 2px; padding: 1px 8px; color: var(--garnet); cursor: pointer; } -.ck-copy-cite:hover { background: var(--garnet); color: var(--paper); border-color: var(--garnet); } +/* Row actions: the same three, in the same place, on every resolved row. */ +.ck-actions { margin-left: auto; display: inline-flex; gap: 6px; flex-wrap: wrap; } +.ck-act { + font: inherit; font-size: 12px; line-height: 1.5; background: none; border: 1px solid var(--rule); border-radius: 2px; + padding: 1px 8px; color: var(--garnet); cursor: pointer; text-decoration: none; white-space: nowrap; +} +.ck-act:hover, .ck-act:focus-visible { background: var(--garnet); color: var(--paper); border-color: var(--garnet); } +.ck-cand { white-space: nowrap; } +.ck-cand-src { margin-left: 3px; font-size: 11px; color: var(--ink-3, var(--ink-2)); text-decoration: none; } +.ck-cand-src:hover { color: var(--garnet); } +/* Status counts = legend + filter. */ +.ck-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; } +.ck-filter { font: inherit; font-size: 13px; cursor: pointer; background: none; border: 1px solid var(--rule); border-radius: 999px; padding: 2px 10px; color: var(--ink-2); } +.ck-filter.ck-pill { font-size: 12px; } +.ck-filter.is-on { box-shadow: 0 0 0 2px var(--ink-2) inset; } +.ck-filter:hover { border-color: var(--ink-2); } +.ck-quotes-line { margin: 8px 0 0; font-size: 14px; color: var(--ink-2); } +.ck-more { margin: 6px 0 0; font-size: 12px; color: var(--ink-3, var(--ink-2)); } +.ck-more > summary { cursor: pointer; } +.ck-note-ok .ck-para-summary { color: inherit; } +.ck-notes-more { margin: 4px 0 0; padding-left: 18px; } +@media (max-width: 600px) { .ck-actions { margin-left: 0; width: 100%; } } .ck-notes { margin: 8px 0 0; padding-left: 18px; font-size: 13px; color: var(--ink-2); } .ck-note { margin: 3px 0; } .ck-note-bad { color: var(--status-bad, #8b1e2b); } diff --git a/docs/assets/app.js b/docs/assets/app.js index 260a998..58b9891 100644 --- a/docs/assets/app.js +++ b/docs/assets/app.js @@ -5162,7 +5162,7 @@ function checkParaBlock(it) { const shown = paras.slice(0, CHECK_PARA_CAP); const url = checkOpenUrl(it); return `
- Show ${label} of ${escape(it.doc.signature || formatDocHeadline(it.doc))} + ${escape(String(it.pinResult.text).replace(/\.$/, ''))} · show text
${shown.map(p => { const n = String(checkParaNumber(p.n) || p.n || ''); @@ -5175,53 +5175,91 @@ function checkParaBlock(it) {
`; } +// One row per citation, Hick's-law layout: the verdict and three fixed actions +// (UNHRDB reader, official UN source, cite) on the first line; the resolved +// document on the second; then only what explains the verdict. Notes on how a +// citation was resolved fold away; a quotation identical to the source shows no diff. +function checkActions(it, i) { + const doc = it.doc; + if (!doc) return ''; + const url = checkOpenUrl(it); + const src = officialSourceUrl(doc); + return `${ + url ? `Reader` : ''}${ + src ? `UN source ↗` : ''}${ + doc.type !== 'rec' ? `` : ''}`; +} +function checkCandidateLinks(ids) { + return ids.slice(0, 6).map(id => { + const d = state.documents.get(id); + if (!d) return escape(id); + const src = officialSourceUrl(d); + return `${escape(d.signature || id)}${ + src ? `↗` : ''}`; + }).join(' · ') + (ids.length > 6 ? ` · +${ids.length - 6}` : ''); +} function checkRenderRows(items) { return items.map((it, i) => { const doc = it.doc; - const url = checkOpenUrl(it); const resolved = doc - ? `
${sourceBadge(doc.type)} ${escape(formatDocHeadline(doc))} · ${escape(doc.signature || '')}${url ? ` · Open ↗` : ''}${doc.type !== 'rec' ? ` · ` : ''}
` + ? `
${sourceBadge(doc.type)} ${escape(formatDocHeadline(doc))} · ${escape(doc.signature || '')}
` : it.candidates.length - ? `
Candidates: ${it.candidates.slice(0, 6).map(id => { const d = state.documents.get(id); return d ? `${escape(d.signature || id)}` : escape(id); }).join(' · ')}${it.candidates.length > 6 ? ` · +${it.candidates.length - 6}` : ''}
` + ? `
Candidates: ${checkCandidateLinks(it.candidates)}
` : (it.mention.kind === 'symbol' ? `
Look up ${escape(it.mention.norm)} on UN Documents ↗
` : ''); - const notes = [ - ...(it.pinResult ? [`
  • ${escape(it.pinResult.text)}${checkParaBlock(it)}
  • `] : (it.pin && doc ? ['
  • Pinpoint not checked.
  • '] : [])), - ...it.notes.map(n => `
  • ${escape(n)}
  • `), + const main = [ + ...(it.pinResult ? [`
  • ${checkParaBlock(it) || escape(it.pinResult.text)}
  • `] : (it.pin && doc ? ['
  • Pinpoint not checked.
  • '] : [])), ...it.quotes.map(q => q.result - ? `
  • Quotation ${q.result.where ? `(${escape(q.result.where)}) ` : ''}${escape(q.result.text)}.
    ${q.result.html}
  • ` + ? `
  • Quotation ${q.result.where ? `(${escape(q.result.where)}) ` : ''}${escape(q.result.text)}.${/<(del|ins)\b/.test(q.result.html || '') ? `
    ${q.result.html}
    ` : ''}
  • ` : '
  • Quotation not checked.
  • '), ]; - return `
  • + // How a citation was resolved ("Resolved as …") is background; a problem note is not, + // so on a row that is not ok the problem stays in view and only the background folds. + const isHow = (n) => it.status === 'ok' || /^Resolved as /.test(n); + main.push(...it.notes.filter(n => !isHow(n)).map(n => `
  • ${escape(n)}
  • `)); + const extra = it.notes.filter(isHow).map(n => `
  • ${escape(n)}
  • `); + const more = extra.length + ? `
    How it was resolved
    ` : ''; + return `
  • № ${String(i + 1).padStart(2, '0')} ${CHECK_STATUS_LABEL[it.status]} ${escape(it.mention.raw)}${it.pin ? ` para. ${escape(it.pin.from)}${it.pin.to ? `–${escape(it.pin.to)}` : ''}` : ''} + ${checkActions(it, i)}
    ${resolved} - ${notes.length ? `` : ''} + ${main.length ? `` : ''} + ${more}
  • `; }).join(''); } +// Problems first; zero counts are left out, so the chips are also the legend. +const CHECK_FILTER_ORDER = ['bad', 'warn', 'ambiguous', 'outside', 'ok']; function checkSummary(items, quoteList) { - const c = { ok: 0, warn: 0, bad: 0, ambiguous: 0, outside: 0 }; + const c = {}; for (const it of items) c[it.status] = (c[it.status] || 0) + 1; - const parts = [`${items.length} citation${items.length === 1 ? '' : 's'}`]; - const bits = []; - if (c.ok) bits.push(`${c.ok} found`); - if (c.warn) bits.push(`${c.warn} to check`); - if (c.bad) bits.push(`${c.bad} not found`); - if (c.ambiguous) bits.push(`${c.ambiguous} ambiguous`); - if (c.outside) bits.push(`${c.outside} outside this database`); - if (bits.length) parts.push(bits.join(' · ')); + const words = { ok: 'found', warn: 'to check', bad: 'not found', ambiguous: 'ambiguous', outside: 'outside this database' }; + const filter = state.check.filter || ''; + const chips = [``]; + for (const st of CHECK_FILTER_ORDER) { + if (!c[st]) continue; + chips.push(``); + } + const lines = [`
    ${chips.join('')}
    `]; const qs = quoteList.filter(q => q.owner); - if (qs.length) { + const orphan = quoteList.filter(q => !q.owner).length; + if (qs.length || orphan) { const q = { ok: 0, warn: 0, bad: 0 }; for (const x of qs) if (x.result) q[x.result.status]++; - parts.push(`${qs.length} quotation${qs.length === 1 ? '' : 's'}: ${q.ok} verbatim or near-verbatim · ${q.warn} differ · ${q.bad} not found`); + const qbits = []; + if (qs.length) qbits.push(`${qs.length} quotation${qs.length === 1 ? '' : 's'}: ${[q.ok && `${q.ok} verbatim or near-verbatim`, q.warn && `${q.warn} differ`, q.bad && `${q.bad} not found`].filter(Boolean).join(' · ') || 'not checked'}`); + if (orphan) qbits.push(`${orphan} without a nearby resolvable citation`); + lines.push(`

    ${qbits.join(' — ')}

    `); } - const orphan = quoteList.filter(q => !q.owner).length; - if (orphan) parts.push(`${orphan} quotation${orphan === 1 ? '' : 's'} without a nearby resolvable citation`); - return parts.join(' — '); + return lines.join(''); +} +function applyCheckFilter() { + const f = state.check.filter || ''; + for (const row of document.querySelectorAll('#check-list .ck-row')) row.hidden = !!f && row.dataset.ckStatus !== f; } function checkReportMarkdown(items, quoteList) { const lines = ['| # | As written | Status | Resolved to | Notes |', '|---|---|---|---|---|']; @@ -5273,6 +5311,15 @@ function paintCheckView() { catch { showFeedbackToast({ ok: false, _msg: 'Clipboard write failed', _mark: '⚠' }); } return; } + const chip = e.target.closest('[data-ck-filter]'); + if (chip) { + const f = chip.dataset.ckFilter; + state.check.filter = state.check.filter === f ? '' : f; + const last = state.check.last; + if (last) $('#check-summary').innerHTML = checkSummary(last.items, last.quotes); + applyCheckFilter(); + return; + } const scopeLink = e.target.closest('a[data-check-scope]'); if (scopeLink) { e.preventDefault(); @@ -5287,6 +5334,7 @@ async function runCitationCheck() { const out = $('#check-output'), status = $('#check-status'), summary = $('#check-summary'), ann = $('#check-annotated'), list = $('#check-list'); if (!out || !summary || !ann || !list) return; const run = ++state.check.run; + state.check.filter = ''; if (!text.trim()) { if (status) status.textContent = 'Paste some text first.'; return; } if (status) status.textContent = 'Resolving citations…'; const found = checkDetect(text); diff --git a/docs/assets/i18n-es.js b/docs/assets/i18n-es.js index 3deb773..175358b 100644 --- a/docs/assets/i18n-es.js +++ b/docs/assets/i18n-es.js @@ -466,10 +466,28 @@ export default { 'Try again in a minute, or use': 'Inténtelo de nuevo dentro de un minuto o use', 'in the meantime.': 'mientras tanto.', 'Ask is not configured for this deploy.': 'La función Preguntar no está configurada en esta instalación.', + + // ── Check: actions and status filter ── + 'Reader': 'Lector', + 'UN source ↗': 'Fuente ONU ↗', + 'How it was resolved': 'Cómo se resolvió', + '· show text': '· ver texto', + 'citations': 'citas', + 'citation': 'cita', + 'Show citations by status': 'Mostrar las citas por estado', + 'Official UN document': 'Documento oficial de la ONU', + 'Open the cited paragraph in the UNHRDB reader': 'Abrir el párrafo citado en el lector de UNHRDB', + 'Open the document in the UNHRDB reader': 'Abrir el documento en el lector de UNHRDB', + 'Copy the citation in your default format': 'Copiar la cita en su formato predeterminado', }, // Strings with numbers or a query: [RegExp, replacement]. Tried when the exact table misses. patterns: [ + [/^(✓|⚠|✖|\?|○) (\d+) (found|to check|not found|ambiguous|outside this database)$/, (m, mark, n, w) => + `${mark} ${n} ${({ found: 'encontradas', 'to check': 'por comprobar', 'not found': 'no encontradas', ambiguous: 'ambiguas', 'outside this database': 'fuera de esta base' })[w]}`], + [/^Paragraph (\S+) exists$/, 'El párrafo $1 existe'], + [/^Paragraphs (\S+) exist$/, 'Los párrafos $1 existen'], + [/^Open the official UN document \((.+)\)$/, 'Abrir el documento oficial de la ONU ($1)'], [/^Adopted (\d{1,2}) (\w+) (\d{4})$/, (m, d, mo, y) => `Aprobada el ${d} de ${ES_MONTH[mo] || mo} de ${y}`], [/^Decision adopted (\d{1,2}) (\w+) (\d{4})$/, (m, d, mo, y) => `Decisión adoptada el ${d} de ${ES_MONTH[mo] || mo} de ${y}`], [/^Issued (\d{1,2}) (\w+) (\d{4})$/, (m, d, mo, y) => `Publicado el ${d} de ${ES_MONTH[mo] || mo} de ${y}`], diff --git a/docs/index.html b/docs/index.html index 2a9fa32..0ece552 100644 --- a/docs/index.html +++ b/docs/index.html @@ -155,8 +155,8 @@ } - - + +