HTML · 1611 bytes Raw Blame History
1 {{/*
2 S51 verified-badge partial. Renders three states based on the
3 passed-in sigverify.View:
4
5 - Reason == "valid" → green "Verified" pill
6 - Reason == "unsigned" → render nothing (no badge)
7 - any other Reason → yellow "Unverified" pill
8
9 Reason strings come from sigverify.Reason (which mirrors GitHub's
10 documented commit.verification.reason enum). The popover is a
11 <details> disclosure for accessibility — keyboard-openable without
12 a JS dependency.
13
14 Caller invokes as `{{ template "verified-badge" .Verification }}`
15 passing the View struct directly (NOT a map). The View's String()
16 is on .Reason so we compare against literal strings here.
17 */}}
18 {{ define "verified-badge" -}}
19 {{- if eq (printf "%s" .Reason) "unsigned" -}}{{/* render nothing */}}
20 {{- else if .Verified -}}
21 <details class="shithub-verified-badge shithub-verified-badge--verified">
22 <summary aria-label="Signature verification details">Verified</summary>
23 <div class="shithub-verified-popover">
24 <p>This commit was signed with a verified signature.</p>
25 <dl>
26 {{ if .SignerEmail }}<dt>Signer</dt><dd>{{ .SignerEmail }}</dd>{{ end }}
27 {{ if .VerifiedAt }}<dt>Verified at</dt><dd>{{ .VerifiedAt.Format "Jan 2, 2006, 3:04 PM" }}</dd>{{ end }}
28 </dl>
29 </div>
30 </details>
31 {{- else -}}
32 <details class="shithub-verified-badge shithub-verified-badge--unverified">
33 <summary aria-label="Signature verification details">Unverified</summary>
34 <div class="shithub-verified-popover">
35 <p>{{ verifiedReasonMessage .Reason }}</p>
36 </div>
37 </details>
38 {{- end -}}
39 {{- end }}