From fac9a140ebb404e05f72227596cb899bbafc57ea Mon Sep 17 00:00:00 2001 From: Protocolbot Date: Tue, 7 Jul 2026 21:39:30 -0600 Subject: [PATCH] fix: suppress empty source, rename 'authored by' to 'contributor:' - When source is empty or matches @author, only show 'contributor:' - Renamed 'authored by' to 'contributor:' on protocol and collection detail pages --- frontend/app.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/frontend/app.js b/frontend/app.js index c07f4a4..1799f4a 100644 --- a/frontend/app.js +++ b/frontend/app.js @@ -244,12 +244,16 @@ async function loadProtocols() { function setSort(mode) { sortBy = mode; + document.querySelectorAll('.sort-option').forEach(function(el) { + el.classList.toggle('active', el.textContent.trim().startsWith(mode === 'date' ? 'date' : 'relevance')); + }); loadProtocols(); } function renderSortToggle() { - document.querySelectorAll('.sort-option').forEach(function(el, i) { - var isDate = i === 0; + // Update active state based on current sortBy + document.querySelectorAll('.sort-option').forEach(function(el) { + var isDate = el.textContent.trim().startsWith('date'); el.classList.toggle('active', (sortBy === 'date' && isDate) || (sortBy === 'relevance' && !isDate)); }); } @@ -334,10 +338,10 @@ function renderDetail(p) { '

' + escapeHtml(s.headline) + '

' + escapeHtml(s.description || '') + '

'; }).join(''); const forkNotice = p.forked_from ? '
forked from: ' + p.forked_from + '
' : ''; - const sourceLine = p.source ? 'SOURCE: ' + escapeHtml(p.source) : ''; + const sourceLine = (p.source && p.source !== '@' + (p.author || '') && p.source !== '') ? 'SOURCE: ' + escapeHtml(p.source) : ''; var sourceLink = p.source_url ? ' · view_original' : ''; - var authorLine = p.author ? ' · authored by @' + escapeHtml(p.author) + '' : ''; - var dateLine = p.created_at ? ' · ' + formatDate(p.created_at) : ''; + var authorLine = p.author ? (sourceLine ? ' · ' : '') + 'contributor: @' + escapeHtml(p.author) + '' : ''; + var dateLine = p.created_at ? ' · added ' + formatDate(p.created_at) : ''; return '
' + tags + '
' + '

' + escapeHtml(p.title) + '

' + @@ -735,9 +739,9 @@ async function showCollectionDetail(slug) { } } } - var sourceLine = c.source ? 'SOURCE: ' + escapeHtml(c.source) : ''; - var authorLine = c.author ? ' · authored by @' + escapeHtml(c.author) + '' : ''; - var dateLine = c.created_at ? ' · ' + formatDate(c.created_at) : ''; + var sourceLine = (c.source && c.source !== '@' + (c.author || '') && c.source !== '') ? 'SOURCE: ' + escapeHtml(c.source) : ''; + var authorLine = c.author ? (sourceLine ? ' · ' : '') + 'contributor: @' + escapeHtml(c.author) + '' : ''; + var dateLine = c.created_at ? ' · added ' + formatDate(c.created_at) : ''; document.getElementById('collectionDetailContent').innerHTML = '

' + escapeHtml(c.title) + '

' +