Files
OPENBUREAU/layouts/_partials/provenance.html
T
karim f2aef5c89a feature: Versionsverlauf + Diff (rot/grün) komplett auf der Seite
- API: /api/history/diff liefert den Unified-Diff einer Fassung (git show)
- „Version vom <Datum>"-Pill (statt Marke oben + Git-Links) öffnet den Verlauf
  direkt auf openbureau: Liste der Fassungen → Diff rot/grün wie auf GitHub,
  Toggle „ganze Fassung anzeigen", Rücksprung. Keine externen Git-Links mehr.
- Pills neu: Dialog (Akzent-Outline, wie zuvor) + Version/Zitieren im Tag-Look
- CSS: Tag-Pills, Diff-Styling (d-add/d-del/d-hunk), alte Badge-Styles raus

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-02 02:06:43 +02:00

85 lines
4.0 KiB
HTML

{{/* Herkunft eines Beitrags: Version (→ Commit), Verlauf, Zitieren.
Version/Verlauf nur, wenn Git-Info da ist (enableGitInfo) und repoURL gesetzt.
„Zitieren" kopiert eine Quellenangabe in die Zwischenablage. */}}
{{ $author := .Params.author | default site.Params.author.name }}
<div class="provenance" aria-label="Herkunft">
{{/* Dialog: gleiche Pill-Reihe, sticht durch Pfeil + Akzentfarbe hervor. */}}
<a class="prov-dialog" id="dialog-link" data-thread="{{ .RelPermalink }}" href="/dialog/?thread={{ .RelPermalink }}">→ Dialog</a>
{{/* „Version vom <Datum>" öffnet den Verlauf direkt auf der Seite (Diff rot/grün). */}}
<button type="button" class="prov-version" id="version-badge" aria-expanded="false"
data-path="{{ .File.Path }}">Version vom {{ .Lastmod.Format "02.01.2006" }}</button>
<button type="button" class="prov-cite" aria-expanded="false"
data-title="{{ .Title }}"
data-author="{{ $author }}"
data-url="{{ .Permalink }}"
{{ with .GitInfo }}data-version="{{ .AbbreviatedHash }}"{{ end }}>Zitieren</button>
</div>
<div class="prov-citation" hidden>
<p class="prov-citation-text"></p>
<div class="prov-citation-actions">
<button type="button" class="prov-citation-copy">Kopieren</button>
<span class="prov-citation-status" role="status"></span>
</div>
</div>
<script>
(function () {
if (window.__provCite) return; window.__provCite = 1;
var btn = document.querySelector('.prov-cite');
var panel = document.querySelector('.prov-citation');
if (!btn || !panel) return;
var textEl = panel.querySelector('.prov-citation-text');
var copyBtn = panel.querySelector('.prov-citation-copy');
var statusEl = panel.querySelector('.prov-citation-status');
var d = btn.dataset;
var today = new Date().toLocaleDateString('de-CH');
var v = d.version ? ', Version ' + d.version : '';
// Format: Autor: Titel. OPENBUREAU, Version xxx. Abgerufen am TT.MM.JJJJ, URL
var cite = d.author + ': ' + d.title + '. OPENBUREAU' + v + '. Abgerufen am ' + today + ', ' + d.url;
textEl.textContent = cite;
function selectText() {
var r = document.createRange(); r.selectNodeContents(textEl);
var sel = window.getSelection(); sel.removeAllRanges(); sel.addRange(r);
}
function copy() {
if (navigator.clipboard && navigator.clipboard.writeText) {
return navigator.clipboard.writeText(cite);
}
// Fallback für unsichere Kontexte (HTTP/LAN): execCommand auf Auswahl.
return new Promise(function (resolve, reject) {
try {
var ta = document.createElement('textarea');
ta.value = cite; ta.style.position = 'fixed'; ta.style.opacity = '0';
document.body.appendChild(ta); ta.focus(); ta.select();
var ok = document.execCommand('copy');
document.body.removeChild(ta);
ok ? resolve() : reject();
} catch (e) { reject(e); }
});
}
btn.addEventListener('click', function () {
var open = panel.hasAttribute('hidden');
if (open) { panel.removeAttribute('hidden'); selectText(); }
else { panel.setAttribute('hidden', ''); }
btn.setAttribute('aria-expanded', String(open));
});
copyBtn.addEventListener('click', function () {
copy().then(function () { statusEl.textContent = 'Kopiert ✓'; })
.catch(function () { statusEl.textContent = 'Markiert — bitte mit Strg/⌘+C kopieren.'; selectText(); });
setTimeout(function () { statusEl.textContent = ''; }, 3000);
});
})();
</script>
<script>
/* Wortmeldungs-Zahl an die Dialog-Pill hängen (→ Dialog · 3). */
(function () {
var l = document.getElementById('dialog-link'); if (!l) return;
fetch('/api/comments?thread=' + encodeURIComponent(l.dataset.thread))
.then(function (r) { return r.ok ? r.json() : []; })
.then(function (d) { var n = d.filter(function (c) { return !c.deleted; }).length; if (n) l.textContent = '→ Dialog · ' + n; })
.catch(function () {});
})();
</script>