Monorepo for Tangled
tangled.org
1{{ define "title" }}commits · {{ .RepoInfo.FullName }}{{ 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 uppercase 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 uppercase font-bold col-span-3">Author</div>
21 <div class="py-2 text-sm text-left text-gray-700 dark:text-gray-300 uppercase font-bold col-span-3">Commit</div>
22 <div class="py-2 text-sm text-left text-gray-700 dark:text-gray-300 uppercase font-bold col-span-6">Message</div>
23 <div class="py-2 text-sm text-left text-gray-700 dark:text-gray-300 uppercase 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 }}" class="no-underline hover:underline {{ $hashStyle }} px-2 py-1/2 rounded flex items-center gap-2">
38 {{ slice $commit.Hash.String 0 8 }}
39 {{ if $verified }}
40 {{ i "shield-check" "w-4 h-4" }}
41 {{ end }}
42 </a>
43 <div class="{{ if not $verified }} ml-6 {{ end }}inline-flex">
44 <button class="p-1 mx-1 hover:bg-gray-100 dark:hover:bg-gray-700 rounded"
45 title="Copy SHA"
46 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)">
47 {{ i "copy" "w-4 h-4" }}
48 </button>
49 <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">
50 {{ i "folder-code" "w-4 h-4" }}
51 </a>
52 </div>
53
54 </div>
55 <div class="align-top col-span-6">
56 <div>
57 <a href="/{{ $.RepoInfo.FullName }}/commit/{{ $commit.Hash.String }}" class="dark:text-white no-underline hover:underline">{{ index $messageParts 0 }}</a>
58
59 {{ if gt (len $messageParts) 1 }}
60 <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>
61 {{ end }}
62
63 {{ if index $.TagMap $commit.Hash.String }}
64 {{ range $tag := index $.TagMap $commit.Hash.String }}
65 <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">
66 {{ $tag }}
67 </span>
68 {{ end }}
69 {{ end }}
70
71 <!-- ci status -->
72 <span class="text-xs">
73 {{ $pipeline := index $.Pipelines .Hash.String }}
74 {{ if and $pipeline (gt (len $pipeline.Statuses) 0) }}
75 {{ template "repo/pipelines/fragments/pipelineSymbolLong" (dict "Pipeline" $pipeline "RepoInfo" $.RepoInfo) }}
76 {{ end }}
77 </span>
78 </div>
79
80 {{ if gt (len $messageParts) 1 }}
81 <p class="hidden mt-1 text-sm text-gray-600 dark:text-gray-400">{{ nl2br (index $messageParts 1) }}</p>
82 {{ end }}
83 </div>
84 <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>
85 </div>
86 {{ end }}
87 </div>
88
89 <!-- mobile view (visible only on small screens) -->
90 <div class="md:hidden">
91 {{ range $index, $commit := .Commits }}
92 <div class="relative p-2 mb-2 {{ if ne $index (sub (len $.Commits) 1) }}border-b border-gray-200 dark:border-gray-700{{ end }}">
93 <div id="commit-message">
94 {{ $messageParts := splitN $commit.Message "\n\n" 2 }}
95 <div class="text-base cursor-pointer">
96 <div class="flex items-center justify-between">
97 <div class="flex-1">
98 <div>
99 <a href="/{{ $.RepoInfo.FullName }}/commit/{{ $commit.Hash.String }}"
100 class="inline no-underline hover:underline dark:text-white">
101 {{ index $messageParts 0 }}
102 </a>
103 {{ if gt (len $messageParts) 1 }}
104 <button
105 class="py-1/2 px-1 bg-gray-200 hover:bg-gray-400 rounded dark:bg-gray-700 dark:hover:bg-gray-600"
106 hx-on:click="this.parentElement.nextElementSibling.classList.toggle('hidden')">
107 {{ i "ellipsis" "w-3 h-3" }}
108 </button>
109 {{ end }}
110
111 {{ if index $.TagMap $commit.Hash.String }}
112 {{ range $tag := index $.TagMap $commit.Hash.String }}
113 <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">
114 {{ $tag }}
115 </span>
116 {{ end }}
117 {{ end }}
118 </div>
119
120 {{ if gt (len $messageParts) 1 }}
121 <p class="hidden mt-1 text-sm cursor-text pb-2 dark:text-gray-300">
122 {{ nl2br (index $messageParts 1) }}
123 </p>
124 {{ end }}
125 </div>
126 <a href="/{{ $.RepoInfo.FullName }}/tree/{{ $commit.Hash.String }}"
127 class="p-1 mr-1 hover:bg-gray-100 dark:hover:bg-gray-700 rounded"
128 title="Browse repository at this commit">
129 {{ i "folder-code" "w-4 h-4" }}
130 </a>
131 </div>
132 </div>
133 </div>
134
135 <div class="text-xs mt-2 text-gray-500 dark:text-gray-400 flex items-center">
136 {{ $verified := $.VerifiedCommits.IsVerified $commit.Hash.String }}
137 {{ $hashStyle := "text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-900" }}
138 {{ if $verified }}
139 {{ $hashStyle = "bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200 px-2 rounded" }}
140 {{ end }}
141 <span class="font-mono">
142 <a href="/{{ $.RepoInfo.FullName }}/commit/{{ $commit.Hash.String }}"
143 class="no-underline hover:underline {{ $hashStyle }} px-2 py-1 rounded flex items-center gap-2">
144 {{ slice $commit.Hash.String 0 8 }}
145 {{ if $verified }}
146 {{ i "shield-check" "w-3 h-3" }}
147 {{ end }}
148 </a>
149 </span>
150 <span class="mx-2 before:content-['·'] before:select-none"></span>
151 {{ template "attribution" (list $commit $.EmailToDid) }}
152 <div class="inline-block px-1 select-none after:content-['·']"></div>
153 <span>{{ template "repo/fragments/shortTime" $commit.Committer.When }}</span>
154
155 <!-- ci status -->
156 {{ $pipeline := index $.Pipelines .Hash.String }}
157 {{ if and $pipeline (gt (len $pipeline.Statuses) 0) }}
158 <div class="inline-block px-1 select-none after:content-['·']"></div>
159 <span class="text-sm">
160 {{ template "repo/pipelines/fragments/pipelineSymbolLong" (dict "Pipeline" $pipeline "RepoInfo" $.RepoInfo) }}
161 </span>
162 {{ end }}
163 </div>
164 </div>
165 {{ end }}
166 </div>
167</section>
168
169{{ end }}
170
171{{ define "attribution" }}
172 {{ $commit := index . 0 }}
173 {{ $map := index . 1 }}
174 <span class="flex items-center gap-1">
175 {{ $author := index $map $commit.Author.Email }}
176 {{ $coauthors := $commit.CoAuthors }}
177 {{ $all := list }}
178
179 {{ if $author }}
180 {{ $all = append $all $author }}
181 {{ end }}
182 {{ range $coauthors }}
183 {{ $co := index $map .Email }}
184 {{ if $co }}
185 {{ $all = append $all $co }}
186 {{ end }}
187 {{ end }}
188
189 {{ template "fragments/tinyAvatarList" (dict "all" $all "classes" "size-6") }}
190 <a href="{{ if $author }}/{{ $author }}{{ else }}mailto:{{ $commit.Author.Email }}{{ end }}"
191 class="no-underline hover:underline">
192 {{ if $author }}{{ resolve $author }}{{ else }}{{ $commit.Author.Name }}{{ end }}
193 {{ if $coauthors }} +{{ length $coauthors }}{{ end }}
194 </a>
195 </span>
196{{ end }}
197
198{{ define "repoAfter" }}
199 {{ $commits_len := len .Commits }}
200 <div class="flex justify-end mt-4 gap-2">
201 {{ 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 }}
202 {{ 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 }}
203 </div>
204{{ end }}