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
This commit is contained in:
Protocolbot
2026-07-07 21:39:30 -06:00
parent 7e00656feb
commit fac9a140eb
+12 -8
View File
@@ -244,12 +244,16 @@ async function loadProtocols() {
function setSort(mode) { function setSort(mode) {
sortBy = mode; sortBy = mode;
document.querySelectorAll('.sort-option').forEach(function(el) {
el.classList.toggle('active', el.textContent.trim().startsWith(mode === 'date' ? 'date' : 'relevance'));
});
loadProtocols(); loadProtocols();
} }
function renderSortToggle() { function renderSortToggle() {
document.querySelectorAll('.sort-option').forEach(function(el, i) { // Update active state based on current sortBy
var isDate = i === 0; document.querySelectorAll('.sort-option').forEach(function(el) {
var isDate = el.textContent.trim().startsWith('date');
el.classList.toggle('active', (sortBy === 'date' && isDate) || (sortBy === 'relevance' && !isDate)); el.classList.toggle('active', (sortBy === 'date' && isDate) || (sortBy === 'relevance' && !isDate));
}); });
} }
@@ -334,10 +338,10 @@ function renderDetail(p) {
'<div class="content"><h4>' + escapeHtml(s.headline) + '</h4><p>' + escapeHtml(s.description || '') + '</p></div></div>'; '<div class="content"><h4>' + escapeHtml(s.headline) + '</h4><p>' + escapeHtml(s.description || '') + '</p></div></div>';
}).join(''); }).join('');
const forkNotice = p.forked_from ? '<div class="fork-notice">forked from: <a href="#protocol/' + p.forked_from + '" onclick="showDetail(\'' + p.forked_from + '\');return false">' + p.forked_from + '</a></div>' : ''; const forkNotice = p.forked_from ? '<div class="fork-notice">forked from: <a href="#protocol/' + p.forked_from + '" onclick="showDetail(\'' + p.forked_from + '\');return false">' + p.forked_from + '</a></div>' : '';
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 ? ' · <a href="' + escapeHtml(p.source_url) + '" target="_blank">view_original</a>' : ''; var sourceLink = p.source_url ? ' · <a href="' + escapeHtml(p.source_url) + '" target="_blank">view_original</a>' : '';
var authorLine = p.author ? ' · authored by <a href="#user/' + p.author + '" onclick="showUser(\'' + p.author + '\');return false">@' + escapeHtml(p.author) + '</a>' : ''; var authorLine = p.author ? (sourceLine ? ' · ' : '') + 'contributor: <a href="#users/' + p.author + '" onclick="showUser(\'' + p.author + '\');return false">@' + escapeHtml(p.author) + '</a>' : '';
var dateLine = p.created_at ? ' · ' + formatDate(p.created_at) : ''; var dateLine = p.created_at ? ' · added ' + formatDate(p.created_at) : '';
return '<div class="detail-header"><div class="tag-row">' + tags + '</div>' + return '<div class="detail-header"><div class="tag-row">' + tags + '</div>' +
'<h1>' + escapeHtml(p.title) + '</h1>' + '<h1>' + escapeHtml(p.title) + '</h1>' +
@@ -735,9 +739,9 @@ async function showCollectionDetail(slug) {
} }
} }
} }
var sourceLine = c.source ? 'SOURCE: ' + escapeHtml(c.source) : ''; var sourceLine = (c.source && c.source !== '@' + (c.author || '') && c.source !== '') ? 'SOURCE: ' + escapeHtml(c.source) : '';
var authorLine = c.author ? ' · authored by <a href="#user/' + c.author + '" onclick="showUser(\'' + c.author + '\');return false">@' + escapeHtml(c.author) + '</a>' : ''; var authorLine = c.author ? (sourceLine ? ' · ' : '') + 'contributor: <a href="#users/' + c.author + '" onclick="showUser(\'' + c.author + '\');return false">@' + escapeHtml(c.author) + '</a>' : '';
var dateLine = c.created_at ? ' · ' + formatDate(c.created_at) : ''; var dateLine = c.created_at ? ' · added ' + formatDate(c.created_at) : '';
document.getElementById('collectionDetailContent').innerHTML = document.getElementById('collectionDetailContent').innerHTML =
'<div class="detail-header"><h1>' + escapeHtml(c.title) + '</h1>' + '<div class="detail-header"><h1>' + escapeHtml(c.title) + '</h1>' +