Monorepo for Tangled
tangled.org
1{{ define "title" }} commit {{ .Diff.Commit.This }} · {{ .RepoInfo.FullName }} {{ end }}
2
3{{ define "extrameta" }}
4 {{ $title := printf "commit %s · %s" .Diff.Commit.This .RepoInfo.FullName }}
5 {{ $url := printf "https://tangled.org/%s/commit/%s" .RepoInfo.FullName .Diff.Commit.This }}
6
7 {{ template "repo/fragments/og" (dict "RepoInfo" .RepoInfo "Title" $title "Url" $url) }}
8{{ end }}
9
10
11{{ define "repoContent" }}
12
13{{ $repo := .RepoInfo.FullName }}
14{{ $commit := .Diff.Commit }}
15
16<section class="commit dark:text-white">
17 <div id="commit-message">
18 {{ $messageParts := splitN $commit.Message "\n\n" 2 }}
19 <div>
20 <p class="pb-2">{{ index $messageParts 0 }}</p>
21 {{ if gt (len $messageParts) 1 }}
22 <p class="mt-1 cursor-text pb-2 text-sm">{{ nl2br (index $messageParts 1) }}</p>
23 {{ end }}
24 </div>
25 </div>
26
27 <div class="flex flex-wrap items-center space-x-2">
28 <p class="flex flex-wrap items-center gap-1 text-sm text-gray-500 dark:text-gray-300">
29 {{ template "attribution" . }}
30
31 <span class="px-1 select-none before:content-['\00B7']"></span>
32 {{ template "repo/fragments/time" $commit.Committer.When }}
33 <span class="px-1 select-none before:content-['\00B7']"></span>
34
35 <a href="/{{ $repo }}/commit/{{ $commit.This }}" class="no-underline hover:underline text-gray-500 dark:text-gray-300">{{ slice $commit.This 0 8 }}</a>
36
37 {{ if $commit.Parent }}
38 {{ i "arrow-left" "w-3 h-3 mx-1" }}
39 <a href="/{{ $repo }}/commit/{{ $commit.Parent }}" class="no-underline hover:underline text-gray-500 dark:text-gray-300">{{ slice $commit.Parent 0 8 }}</a>
40 {{ end }}
41 </p>
42
43 {{ if .VerifiedCommit.IsVerified $commit.This }}
44 <div class="group relative inline-block text-sm">
45 <div class="bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200 px-2 py-1 rounded cursor-pointer">
46 <div class="flex items-center gap-2">
47 {{ i "shield-check" "w-4 h-4" }}
48 verified
49 </div>
50 </div>
51 <div class="absolute z-[9999] hidden group-hover:block bg-white dark:bg-gray-900 text-sm text-black dark:text-white rounded-md shadow-md p-4 w-80 top-full mt-2">
52 <div class="mb-1">This commit was signed with the committer's <span class="text-green-600 font-semibold">known signature</span>.</div>
53 <div class="flex items-center gap-2 my-2">
54 {{ i "user" "w-4 h-4" }}
55 {{ $committerDid := index $.EmailToDid $commit.Committer.Email }}
56 {{ template "user/fragments/picHandleLink" $committerDid }}
57 </div>
58 <div class="my-1 pt-2 text-xs border-t border-gray-200 dark:border-gray-700">
59 <div class="text-gray-600 dark:text-gray-300">SSH Key Fingerprint:</div>
60 <div class="break-all">{{ .VerifiedCommit.Fingerprint $commit.This }}</div>
61 </div>
62 </div>
63 </div>
64 {{ end }}
65
66 <div class="text-sm">
67 {{ if $.Pipeline }}
68 {{ template "repo/pipelines/fragments/pipelineSymbolLong" (dict "Pipeline" $.Pipeline "RepoInfo" $.RepoInfo) }}
69 {{ end }}
70 </div>
71 </div>
72
73</section>
74{{end}}
75
76{{ define "attribution" }}
77 {{ $commit := .Diff.Commit }}
78 {{ $showCommitter := true }}
79 {{ if eq $commit.Author.Email $commit.Committer.Email }}
80 {{ $showCommitter = false }}
81 {{ end }}
82
83 {{ if $showCommitter }}
84 authored by {{ template "attributedUser" (list $commit.Author.Email $commit.Author.Name $.EmailToDid) }}
85 {{ range $commit.CoAuthors }}
86 {{ template "attributedUser" (list .Email .Name $.EmailToDid) }}
87 {{ end }}
88 and committed by {{ template "attributedUser" (list $commit.Committer.Email $commit.Committer.Name $.EmailToDid) }}
89 {{ else }}
90 {{ template "attributedUser" (list $commit.Author.Email $commit.Author.Name $.EmailToDid )}}
91 {{ end }}
92{{ end }}
93
94{{ define "attributedUser" }}
95 {{ $email := index . 0 }}
96 {{ $name := index . 1 }}
97 {{ $map := index . 2 }}
98 {{ $did := index $map $email }}
99
100 {{ if $did }}
101 {{ template "user/fragments/picHandleLink" $did }}
102 {{ else }}
103 <a href="mailto:{{ $email }}" class="no-underline hover:underline text-gray-500 dark:text-gray-300">{{ $name }}</a>
104 {{ end }}
105{{ end }}
106
107{{ define "topbarLayout" }}
108 <header class="col-span-full" style="z-index: 20;">
109 {{ template "layouts/fragments/topbar" . }}
110 </header>
111{{ end }}
112
113{{ define "mainLayout" }}
114 <div class="px-1 flex-grow col-span-full flex flex-col gap-4">
115 {{ block "contentLayout" . }}
116 {{ block "content" . }}{{ end }}
117 {{ end }}
118
119 {{ block "contentAfterLayout" . }}
120 <div class="flex-grow grid grid-cols-1 md:grid-cols-12 gap-4">
121 <div class="flex flex-col gap-4 col-span-1 md:col-span-2">
122 {{ block "contentAfterLeft" . }} {{ end }}
123 </div>
124 <main class="col-span-1 md:col-span-10">
125 {{ block "contentAfter" . }}{{ end }}
126 </main>
127 </div>
128 {{ end }}
129 </div>
130{{ end }}
131
132{{ define "footerLayout" }}
133 <footer class="col-span-full mt-12">
134 {{ template "layouts/fragments/footer" . }}
135 </footer>
136{{ end }}
137
138{{ define "contentAfter" }}
139 {{ template "repo/fragments/diff" (list .Diff .DiffOpts) }}
140{{end}}
141
142{{ define "contentAfterLeft" }}
143 <div class="flex flex-col gap-4 col-span-1 md:col-span-2">
144 {{ template "repo/fragments/diffOpts" .DiffOpts }}
145 </div>
146 <div class="sticky top-0 flex-grow max-h-screen overflow-y-auto">
147 {{ template "repo/fragments/diffChangedFiles" .Diff }}
148 </div>
149{{end}}