63 lines
2 KiB
HTML
63 lines
2 KiB
HTML
{{- /* sigdl — Download & Verify block for each post.
|
|
Usage: {{< sigdl >}}
|
|
Normalizes index.md/_index.md so links become /sources/<dir>.md
|
|
*/ -}}
|
|
|
|
{{- /* Compute a normalized relative path for the source */ -}}
|
|
{{- $rel := replace .Page.File.Path "content/" "" -}}
|
|
{{- $rel = replace $rel "/index.md" ".md" -}}
|
|
{{- $rel = replace $rel "/_index.md" ".md" -}}
|
|
|
|
{{- $download := printf "/sources/%s" $rel -}}
|
|
{{- $asc := printf "%s.asc" $download -}}
|
|
{{- $staticAscPath := printf "static%s.asc" $download -}}
|
|
|
|
{{- $sig := "" -}}
|
|
{{- if (fileExists $staticAscPath) -}}
|
|
{{- $sig = (readFile $staticAscPath) | htmlEscape -}}
|
|
{{- end -}}
|
|
|
|
{{/* Robust onion detection:
|
|
1) prefer --environment onion
|
|
2) else parse .Site.Params.isOnion (string-safe)
|
|
3) else check baseURL contains ".onion"
|
|
*/}}
|
|
{{- $isOnion := eq hugo.Environment "onion" -}}
|
|
{{- if not $isOnion -}}
|
|
{{- with .Site.Params.isOnion -}}
|
|
{{- $v := (printf "%v" . | lower) -}}
|
|
{{- if or (eq $v "true") (eq $v "1") (eq $v "yes") (eq $v "on") -}}
|
|
{{- $isOnion = true -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- if and (not $isOnion) (in (lower (site.BaseURL)) ".onion") -}}
|
|
{{- $isOnion = true -}}
|
|
{{- end -}}
|
|
|
|
<div class="signature-block" style="margin-top:1rem">
|
|
<p><strong>Downloads:</strong>
|
|
<a href="{{ $download | relURL }}">Markdown</a> ·
|
|
<a href="{{ $asc | relURL }}">Signature (.asc)</a>
|
|
</p>
|
|
|
|
{{- if $sig -}}
|
|
<details class="signature">
|
|
<summary>View OpenPGP signature</summary>
|
|
<pre style="font-size:0.85em; overflow-x:auto; padding:0.75rem;">{{ $sig }}</pre>
|
|
</details>
|
|
{{- end -}}
|
|
|
|
<p><em>Verify locally:</em></p>
|
|
<pre style="font-size:0.85em; overflow-x:auto; padding:0.75rem;">
|
|
{{- if $isOnion -}}
|
|
torsocks curl -fSLO {{ $download | absURL }}
|
|
torsocks curl -fSLO {{ $asc | absURL }}
|
|
{{- else -}}
|
|
curl -fSLO {{ $download | absURL }}
|
|
curl -fSLO {{ $asc | absURL }}
|
|
{{- end }}
|
|
gpg --verify {{ path.Base $asc }} {{ path.Base $download }}
|
|
</pre>
|
|
</div>
|
|
|