22c9b9ff61
- Version/Verlauf/Zitieren als dezente Outline-Pills (wie Versions-Marke), „·"-Trenner entfernt - Byline (Autor) + „Aktualisiert am" nur noch bei Library-Beiträgen; Seiten wie Manifest/Kontakt/Spenden/Colophon zeigen sie nicht mehr Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
77 lines
3.4 KiB
HTML
77 lines
3.4 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">
|
|
{{ 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>
|