forked from
tangled.org/core
Monorepo for Tangled — https://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.sh/%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 <table class="w-full border-collapse hidden md:table">
18 <thead>
19 <tr>
20 <th class="py-2 text-sm text-left text-gray-700 dark:text-gray-300 uppercase font-bold">Author</th>
21 <th class="py-2 text-sm text-left text-gray-700 dark:text-gray-300 uppercase font-bold">Commit</th>
22 <th class="py-2 text-sm text-left text-gray-700 dark:text-gray-300 uppercase font-bold">Message</th>
23 <th class="py-2 text-sm text-left text-gray-700 dark:text-gray-300 uppercase font-bold">Date</th>
24 </tr>
25 </thead>
26 <tbody>
27 {{ range $index, $commit := .Commits }}
28 {{ $messageParts := splitN $commit.Message "\n\n" 2 }}
29 <tr class="{{ if ne $index (sub (len $.Commits) 1) }}border-b border-gray-200 dark:border-gray-700{{ end }}">
30 <td class=" py-3 align-top">
31 {{ $didOrHandle := index $.EmailToDidOrHandle $commit.Author.Email }}
32 {{ if $didOrHandle }}
33 <a href="/{{ $didOrHandle }}" class="text-gray-700 dark:text-gray-300 no-underline hover:underline">{{ $didOrHandle }}</a>
34 {{ else }}
35 <a href="mailto:{{ $commit.Author.Email }}" class="text-gray-700 dark:text-gray-300 no-underline hover:underline">{{ $commit.Author.Name }}</a>
36 {{ end }}
37 </td>
38 <td class="py-3 align-top font-mono flex items-center">
39 {{ $verified := false }}
40 {{ $verified = index $.VerifiedCommits $commit.Hash.String }}
41 {{ $hashStyle := "text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-900" }}
42 {{ if $verified }}
43 {{ $hashStyle = "bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200 px-2 rounded" }}
44 {{ end }}
45 <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">
46 {{ slice $commit.Hash.String 0 8 }}
47 {{ if $verified }}
48 {{ i "shield-check" "w-4 h-4" }}
49 {{ end }}
50 </a>
51 <div class="{{ if not $verified }} ml-6 {{ end }}inline-flex">
52 <button class="p-1 mx-1 hover:bg-gray-100 dark:hover:bg-gray-700 rounded"
53 title="Copy SHA"
54 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)">
55 {{ i "copy" "w-4 h-4" }}
56 </button>
57 <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">
58 {{ i "folder-code" "w-4 h-4" }}
59 </a>
60 </div>
61 </td>
62 <td class=" py-3 align-top">
63 <div>
64 <div class="flex items-center justify-start">
65 <a href="/{{ $.RepoInfo.FullName }}/commit/{{ $commit.Hash.String }}" class="dark:text-white no-underline hover:underline">{{ index $messageParts 0 }}</a>
66 {{ if gt (len $messageParts) 1 }}
67 <button class="ml-2 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>
68 {{ end }}
69
70
71 {{ if index $.TagMap $commit.Hash.String }}
72 {{ range $tag := index $.TagMap $commit.Hash.String }}
73 <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">
74 {{ $tag }}
75 </span>
76 {{ end }}
77 {{ end }}
78
79 </div>
80
81 {{ if gt (len $messageParts) 1 }}
82 <p class="hidden mt-1 text-sm text-gray-600 dark:text-gray-400">{{ nl2br (index $messageParts 1) }}</p>
83 {{ end }}
84 </td>
85 <td class=" py-3 align-top text-gray-500 dark:text-gray-400">{{ timeFmt $commit.Committer.When }}</td>
86 </tr>
87 {{ end }}
88 </tbody>
89 </table>
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>
99 <div class="flex items-center justify-between">
100 <div class="flex-1">
101 <div class="inline">
102 <a href="/{{ $.RepoInfo.FullName }}/commit/{{ $commit.Hash.String }}"
103 class="inline no-underline hover:underline dark:text-white">
104 {{ index $messageParts 0 }}
105 </a>
106 {{ if gt (len $messageParts) 1 }}
107 <button
108 class="py-1/2 px-1 bg-gray-200 hover:bg-gray-400 rounded dark:bg-gray-700 dark:hover:bg-gray-600 ml-2"
109 hx-on:click="this.parentElement.nextElementSibling.classList.toggle('hidden')">
110 {{ i "ellipsis" "w-3 h-3" }}
111 </button>
112 {{ end }}
113
114 {{ if index $.TagMap $commit.Hash.String }}
115 {{ range $tag := index $.TagMap $commit.Hash.String }}
116 <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">
117 {{ $tag }}
118 </span>
119 {{ end }}
120 {{ end }}
121 </div>
122
123 {{ if gt (len $messageParts) 1 }}
124 <p class="hidden mt-1 text-sm cursor-text pb-2 dark:text-gray-300">
125 {{ nl2br (index $messageParts 1) }}
126 </p>
127 {{ end }}
128 </div>
129 <a href="/{{ $.RepoInfo.FullName }}/tree/{{ $commit.Hash.String }}"
130 class="p-1 mr-1 hover:bg-gray-100 dark:hover:bg-gray-700 rounded"
131 title="Browse repository at this commit">
132 {{ i "folder-code" "w-4 h-4" }}
133 </a>
134 </div>
135 </div>
136 </div>
137 </div>
138
139 <div class="text-xs mt-2 text-gray-500 dark:text-gray-400 flex items-center">
140 {{ $verified := false }}
141 {{ $verified = index $.VerifiedCommits $commit.Hash.String }}
142 {{ $hashStyle := "text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-900" }}
143 {{ if $verified }}
144 {{ $hashStyle = "bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200 px-2 rounded" }}
145 {{ end }}
146 <span class="font-mono">
147 <a href="/{{ $.RepoInfo.FullName }}/commit/{{ $commit.Hash.String }}"
148 class="no-underline hover:underline {{ $hashStyle }} px-2 py-1 rounded flex items-center gap-2">
149 {{ slice $commit.Hash.String 0 8 }}
150 {{ if $verified }}
151 {{ i "shield-check" "w-3 h-3" }}
152 {{ end }}
153 </a>
154 </span>
155 <span class="mx-2 before:content-['·'] before:select-none"></span>
156 <span>
157 {{ $didOrHandle := index $.EmailToDidOrHandle $commit.Author.Email }}
158 <a href="{{ if $didOrHandle }}/{{ $didOrHandle }}{{ else }}mailto:{{ $commit.Author.Email }}{{ end }}"
159 class="text-gray-500 dark:text-gray-400 no-underline hover:underline">
160 {{ if $didOrHandle }}{{ $didOrHandle }}{{ else }}{{ $commit.Author.Name }}{{ end }}
161 </a>
162 </span>
163 <div class="inline-block px-1 select-none after:content-['·']"></div>
164 <span>{{ shortTimeFmt $commit.Committer.When }}</span>
165 </div>
166 </div>
167 {{ end }}
168 </div>
169</section>
170
171{{ end }}
172
173{{ define "repoAfter" }}
174 {{ $commits_len := len .Commits }}
175 <div class="flex justify-end mt-4 gap-2">
176 {{ 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 }}
177 {{ 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 }}
178 </div>
179{{ end }}