Monorepo for Tangled
tangled.org
1{{ define "title" }}Commits · {{ .RepoInfo.FullName }} · Tangled{{ end }}
2
3{{ define "extrameta" }}
4 {{ $title := printf "Commits · %s" .RepoInfo.FullName }}
5 {{ $url := printf "https://tangled.org/%s/commits" .RepoInfo.FullName }}
6
7 {{ template "repo/fragments/og" (dict "RepoInfo" .RepoInfo "Title" $title "Url" $url) }}
8{{ end }}
9
10{{ define "repoContent" }}
11<section id="commit-table" class="overflow-x-auto">
12 <h2 class="font-bold text-sm mb-4 dark:text-white">
13 Commits
14 </h2>
15
16 <!-- desktop view (hidden on small screens) -->
17 <div class="hidden md:flex md:flex-col divide-y divide-gray-200 dark:divide-gray-700">
18 {{ $grid := "grid grid-cols-14 gap-4" }}
19 <div class="{{ $grid }}">
20 <div class="py-2 text-sm text-left text-gray-700 dark:text-gray-300 font-bold col-span-3">Author</div>
21 <div class="py-2 text-sm text-left text-gray-700 dark:text-gray-300 font-bold col-span-3">Commit</div>
22 <div class="py-2 text-sm text-left text-gray-700 dark:text-gray-300 font-bold col-span-6">Message</div>
23 <div class="py-2 text-sm text-left text-gray-700 dark:text-gray-300 font-bold col-span-2 justify-self-end">Date</div>
24 </div>
25 {{ range $index, $commit := .Commits }}
26 {{ $messageParts := splitN $commit.Message "\n\n" 2 }}
27 <div class="{{ $grid }} py-3">
28 <div class="align-top col-span-3">
29 {{ template "attribution" (list $commit $.EmailToDid) }}
30 </div>
31 <div class="align-top font-mono flex items-start col-span-3">
32 {{ $verified := $.VerifiedCommits.IsVerified $commit.Hash.String }}
33 {{ $hashStyle := "text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-900" }}
34 {{ if $verified }}
35 {{ $hashStyle = "bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200 px-2 rounded" }}
36 {{ end }}
37 <a href="/{{ $.RepoInfo.FullName }}/commit/{{ $commit.Hash.String }}"
38 {{ if $commit.ChangeId }}title="jj change id: {{ $commit.ChangeId }}"{{ end }}
39 class="no-underline hover:underline {{ $hashStyle }} px-2 py-1/2 rounded flex items-center gap-2">
40 {{ slice $commit.Hash.String 0 8 }}
41 {{ if $verified }}
42 {{ i "shield-check" "w-4 h-4" }}
43 {{ end }}
44 </a>
45 <div class="{{ if not $verified }} ml-6 {{ end }}inline-flex">
46 <button class="p-1 mx-1 hover:bg-gray-100 dark:hover:bg-gray-700 rounded"
47 title="Copy SHA"
48 onclick="navigator.clipboard.writeText('{{ $commit.Hash.String }}'); this.innerHTML=`{{ i "copy-check" "w-4 h-4" }}`; setTimeout(() => this.innerHTML=`{{ i "copy" "w-4 h-4" }}`, 1500)">
49 {{ i "copy" "w-4 h-4" }}
50 </button>
51 <a href="/{{ $.RepoInfo.FullName }}/tree/{{ $commit.Hash.String }}" class="p-1 mx-1 hover:bg-gray-100 dark:hover:bg-gray-700 rounded" title="Browse repository at this commit">
52 {{ i "folder-code" "w-4 h-4" }}
53 </a>
54 </div>
55
56 </div>
57 <div class="align-top col-span-6">
58 <div>
59 <a href="/{{ $.RepoInfo.FullName }}/commit/{{ $commit.Hash.String }}" class="dark:text-white no-underline hover:underline">{{ index $messageParts 0 }}</a>
60
61 {{ if gt (len $messageParts) 1 }}
62 <button class="py-1/2 px-1 bg-gray-200 hover:bg-gray-400 dark:bg-gray-700 dark:hover:bg-gray-600 rounded" hx-on:click="this.parentElement.nextElementSibling.classList.toggle('hidden')">{{ i "ellipsis" "w-3 h-3" }}</button>
63 {{ end }}
64
65 {{ if index $.TagMap $commit.Hash.String }}
66 {{ range $tag := index $.TagMap $commit.Hash.String }}
67 <span class="ml-2 text-xs rounded bg-gray-100 dark:bg-gray-700 text-black dark:text-white font-mono px-2 inline-flex items-center">
68 {{ $tag }}
69 </span>
70 {{ end }}
71 {{ end }}
72
73 <!-- ci status -->
74 <span class="text-xs">
75 {{ $pipeline := index $.Pipelines .Hash.String }}
76 {{ if and $pipeline (gt (len $pipeline.Statuses) 0) }}
77 {{ template "repo/pipelines/fragments/pipelineSymbolLong" (dict "Pipeline" $pipeline "RepoInfo" $.RepoInfo) }}
78 {{ end }}
79 </span>
80 </div>
81
82 {{ if gt (len $messageParts) 1 }}
83 <p class="hidden mt-1 text-sm text-gray-600 dark:text-gray-400">{{ nl2br (index $messageParts 1) }}</p>
84 {{ end }}
85 </div>
86 <div class="align-top justify-self-end text-gray-500 dark:text-gray-400 col-span-2">{{ template "repo/fragments/shortTimeAgo" $commit.Committer.When }}</div>
87 </div>
88 {{ end }}
89 </div>
90
91 <!-- mobile view (visible only on small screens) -->
92 <div class="md:hidden">
93 {{ range $index, $commit := .Commits }}
94 <div class="relative p-2 mb-2 {{ if ne $index (sub (len $.Commits) 1) }}border-b border-gray-200 dark:border-gray-700{{ end }}">
95 <div id="commit-message">
96 {{ $messageParts := splitN $commit.Message "\n\n" 2 }}
97 <div class="text-base cursor-pointer">
98 <div class="flex items-center justify-between">
99 <div class="flex-1">
100 <div>
101 <a href="/{{ $.RepoInfo.FullName }}/commit/{{ $commit.Hash.String }}"
102 class="inline no-underline hover:underline dark:text-white">
103 {{ index $messageParts 0 }}
104 </a>
105 {{ if gt (len $messageParts) 1 }}
106 <button
107 class="py-1/2 px-1 bg-gray-200 hover:bg-gray-400 rounded dark:bg-gray-700 dark:hover:bg-gray-600"
108 hx-on:click="this.parentElement.nextElementSibling.classList.toggle('hidden')">
109 {{ i "ellipsis" "w-3 h-3" }}
110 </button>
111 {{ end }}
112
113 {{ if index $.TagMap $commit.Hash.String }}
114 {{ range $tag := index $.TagMap $commit.Hash.String }}
115 <span class="ml-2 text-xs rounded bg-gray-100 dark:bg-gray-700 text-black dark:text-white font-mono px-2 inline-flex items-center">
116 {{ $tag }}
117 </span>
118 {{ end }}
119 {{ end }}
120 </div>
121
122 {{ if gt (len $messageParts) 1 }}
123 <p class="hidden mt-1 text-sm cursor-text pb-2 dark:text-gray-300">
124 {{ nl2br (index $messageParts 1) }}
125 </p>
126 {{ end }}
127 </div>
128 <a href="/{{ $.RepoInfo.FullName }}/tree/{{ $commit.Hash.String }}"
129 class="p-1 mr-1 hover:bg-gray-100 dark:hover:bg-gray-700 rounded"
130 title="Browse repository at this commit">
131 {{ i "folder-code" "w-4 h-4" }}
132 </a>
133 </div>
134 </div>
135 </div>
136
137 <div class="text-xs mt-2 text-gray-500 dark:text-gray-400 flex items-center">
138 {{ $verified := $.VerifiedCommits.IsVerified $commit.Hash.String }}
139 {{ $hashStyle := "text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-900" }}
140 {{ if $verified }}
141 {{ $hashStyle = "bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200 px-2 rounded" }}
142 {{ end }}
143 <span class="font-mono">
144 <a href="/{{ $.RepoInfo.FullName }}/commit/{{ $commit.Hash.String }}"
145 {{ if $commit.ChangeId }}title="jj change id: {{ $commit.ChangeId }}"{{ end }}
146 class="no-underline hover:underline {{ $hashStyle }} px-2 py-1 rounded flex items-center gap-2">
147 {{ slice $commit.Hash.String 0 8 }}
148 {{ if $verified }}
149 {{ i "shield-check" "w-3 h-3" }}
150 {{ end }}
151 </a>
152 </span>
153 <span class="mx-2 before:content-['·'] before:select-none"></span>
154 {{ template "attribution" (list $commit $.EmailToDid) }}
155 <div class="inline-block px-1 select-none after:content-['·']"></div>
156 <span>{{ template "repo/fragments/shortTime" $commit.Committer.When }}</span>
157
158 <!-- ci status -->
159 {{ $pipeline := index $.Pipelines .Hash.String }}
160 {{ if and $pipeline (gt (len $pipeline.Statuses) 0) }}
161 <div class="inline-block px-1 select-none after:content-['·']"></div>
162 <span class="text-sm">
163 {{ template "repo/pipelines/fragments/pipelineSymbolLong" (dict "Pipeline" $pipeline "RepoInfo" $.RepoInfo) }}
164 </span>
165 {{ end }}
166 </div>
167 </div>
168 {{ end }}
169 </div>
170</section>
171
172{{ end }}
173
174{{ define "attribution" }}
175 {{ $commit := index . 0 }}
176 {{ $map := index . 1 }}
177 <span class="flex items-center gap-1">
178 {{ $author := index $map $commit.Author.Email }}
179 {{ $coauthors := $commit.CoAuthors }}
180 {{ $all := list }}
181
182 {{ if $author }}
183 {{ $all = append $all $author }}
184 {{ end }}
185 {{ range $coauthors }}
186 {{ $co := index $map .Email }}
187 {{ if $co }}
188 {{ $all = append $all $co }}
189 {{ end }}
190 {{ end }}
191
192 {{ if $author }}
193 {{ template "fragments/tinyAvatarList" (dict "all" $all "classes" "size-6") }}
194 {{ else }}
195 {{ placeholderAvatar "tiny" }}
196 {{ end }}
197 <a href="{{ if $author }}/{{ $author }}{{ else }}mailto:{{ $commit.Author.Email }}{{ end }}"
198 class="no-underline hover:underline">
199 {{ if $author }}{{ resolve $author }}{{ else }}{{ $commit.Author.Name }}{{ end }}
200 {{ if $coauthors }} +{{ length $coauthors }}{{ end }}
201 </a>
202 </span>
203{{ end }}
204
205{{ define "repoAfter" }}
206 {{ $commits_len := len .Commits }}
207 <div class="flex justify-end mt-4 gap-2">
208 {{ if gt .Page 1 }}<a class="btn flex items-center gap-2 no-underline hover:no-underline dark:text-white dark:hover:bg-gray-700" hx-boost="true" onclick="window.location.href = window.location.pathname + '?page={{ sub .Page 1 }}'">{{ i "chevron-left" "w-4 h-4" }} Previous</a>{{ else }}<div></div>{{ end }}
209 {{ if eq $commits_len 60 }}<a class="btn flex items-center gap-2 no-underline hover:no-underline dark:text-white dark:hover:bg-gray-700" hx-boost="true" onclick="window.location.href = window.location.pathname + '?page={{ add .Page 1 }}'">Next {{ i "chevron-right" "w-4 h-4" }}</a>{{ end }}
210 </div>
211{{ end }}