Files
OPENBUREAU/layouts/_partials/provenance.html
T
karim 0cc90ac295 ui: Dialog als Pill in die Provenance-Reihe, sticht durch Symbol+Akzent hervor
Dialog-Link in .provenance verschoben: → Dialog · Version · Verlauf · Zitieren
in einer Reihe, gleiche Pill-Form. Dialog (prov-dialog) hebt sich durch Pfeil
+ Akzentfarbe (Rahmen/Text, fett) ab, Hover füllt Akzent. Zähler-Script mit ins
Partial gezogen; alte .dialog-link-Klasse/-CSS entfernt.

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

89 lines
4.1 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. */}}
{{ $repo := site.Params.repoURL }}
{{ $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>
{{ with .GitInfo }}
{{ with $repo }}
<a class="prov-version" href="{{ . }}/commit/{{ $.GitInfo.Hash }}" title="Diese Version als Commit ansehen">Version {{ $.GitInfo.AbbreviatedHash }}</a>
<a class="prov-history" href="{{ . }}/commits/branch/main/content/{{ $.File.Path }}">Verlauf</a>
{{ end }}
{{ end }}
<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>