forked from
tangled.org/core
Monorepo for Tangled — https://tangled.org
1{{ define "title" }}{{ .RepoInfo.FullName }} at {{ .Ref }}{{ end }}
2
3
4{{ define "extrameta" }}
5 {{ template "repo/fragments/meta" . }}
6
7 {{ template "repo/fragments/og" (dict "RepoInfo" .RepoInfo) }}
8{{ end }}
9
10
11{{ define "repoContent" }}
12 <main>
13 <div class="flex items-center justify-between pb-5">
14 {{ block "branchSelector" . }}{{ end }}
15 <div class="flex md:hidden items-center gap-4">
16 <a href="/{{ .RepoInfo.FullName }}/commits/{{ .Ref | urlquery }}" class="inline-flex items-center text-sm gap-1">
17 {{ i "git-commit-horizontal" "w-4" "h-4" }} {{ .TotalCommits }}
18 </a>
19 <a href="/{{ .RepoInfo.FullName }}/branches" class="inline-flex items-center text-sm gap-1">
20 {{ i "git-branch" "w-4" "h-4" }} {{ len .Branches }}
21 </a>
22 <a href="/{{ .RepoInfo.FullName }}/tags" class="inline-flex items-center text-sm gap-1">
23 {{ i "tags" "w-4" "h-4" }} {{ len .Tags }}
24 </a>
25 </div>
26 </div>
27 <div class="grid grid-cols-1 md:grid-cols-2 gap-2">
28 {{ block "fileTree" . }}{{ end }}
29 {{ block "rightInfo" . }}{{ end }}
30 </div>
31 </main>
32{{ end }}
33
34{{ define "branchSelector" }}
35 <div class="flex gap-4 items-center justify-center">
36 <select
37 onchange="window.location.href = '/{{ .RepoInfo.FullName }}/tree/' + encodeURIComponent(this.value)"
38 class="p-1 border max-w-32 border-gray-200 bg-white dark:bg-gray-800 dark:text-white dark:border-gray-700"
39 >
40 <optgroup label="branches ({{len .Branches}})" class="bold text-sm">
41 {{ range .Branches }}
42 <option
43 value="{{ .Reference.Name }}"
44 class="py-1"
45 {{ if eq .Reference.Name $.Ref }}
46 selected
47 {{ end }}
48 >
49 {{ .Reference.Name }}
50 </option>
51 {{ end }}
52 </optgroup>
53 <optgroup label="tags ({{len .Tags}})" class="bold text-sm">
54 {{ range .Tags }}
55 <option
56 value="{{ .Reference.Name }}"
57 class="py-1"
58 {{ if eq .Reference.Name $.Ref }}
59 selected
60 {{ end }}
61 >
62 {{ .Reference.Name }}
63 </option>
64 {{ else }}
65 <option class="py-1" disabled>no tags found</option>
66 {{ end }}
67 </optgroup>
68 </select>
69 <div class="flex items-center gap-2">
70 {{ $isOwner := and .LoggedInUser .RepoInfo.Roles.IsOwner }}
71 {{ $isCollaborator := and .LoggedInUser .RepoInfo.Roles.IsCollaborator }}
72 {{ if and (or $isOwner $isCollaborator) .ForkInfo .ForkInfo.IsFork }}
73 {{ $disabled := "" }}
74 {{ $title := "" }}
75 {{ if eq .ForkInfo.Status 0 }}
76 {{ $disabled = "disabled" }}
77 {{ $title = "This branch is not behind the upstream" }}
78 {{ else if eq .ForkInfo.Status 2 }}
79 {{ $disabled = "disabled" }}
80 {{ $title = "This branch has conflicts that must be resolved" }}
81 {{ else if eq .ForkInfo.Status 3 }}
82 {{ $disabled = "disabled" }}
83 {{ $title = "This branch does not exist on the upstream" }}
84 {{ end }}
85
86 <button
87 id="syncBtn"
88 {{ $disabled }}
89 {{ if $title }}title="{{ $title }}"{{ end }}
90 class="btn flex gap-2 items-center disabled:opacity-50 disabled:cursor-not-allowed"
91 hx-post="/{{ .RepoInfo.FullName }}/fork/sync"
92 hx-trigger="click"
93 hx-swap="none"
94 >
95 {{ if $disabled }}
96 {{ i "refresh-cw-off" "w-4 h-4" }}
97 {{ else }}
98 {{ i "refresh-cw" "w-4 h-4" }}
99 {{ end }}
100 <span>sync</span>
101 </button>
102 {{ end }}
103 <a
104 href="/{{ .RepoInfo.FullName }}/compare?base={{ $.Ref | urlquery }}"
105 class="btn flex items-center gap-2 no-underline hover:no-underline"
106 title="Compare branches or tags"
107 >
108 {{ i "git-compare" "w-4 h-4" }}
109 </a>
110 </div>
111</div>
112{{ end }}
113
114{{ define "fileTree" }}
115 <div
116 id="file-tree"
117 class="col-span-1 pr-2 md:border-r md:border-gray-200 dark:md:border-gray-700"
118 >
119 {{ $containerstyle := "py-1" }}
120 {{ $linkstyle := "no-underline hover:underline dark:text-white" }}
121
122 {{ range .Files }}
123 {{ if not .IsFile }}
124 <div class="{{ $containerstyle }}">
125 <div class="flex justify-between items-center">
126 <a
127 href="/{{ $.RepoInfo.FullName }}/tree/{{ $.Ref | urlquery }}/{{ .Name }}"
128 class="{{ $linkstyle }}"
129 >
130 <div class="flex items-center gap-2">
131 {{ i "folder" "size-4 fill-current" }}
132 {{ .Name }}
133 </div>
134 </a>
135
136 {{ if .LastCommit }}
137 <time class="text-xs text-gray-500 dark:text-gray-400"
138 >{{ timeFmt .LastCommit.When }}</time
139 >
140 {{ end }}
141 </div>
142 </div>
143 {{ end }}
144 {{ end }}
145
146 {{ range .Files }}
147 {{ if .IsFile }}
148 <div class="{{ $containerstyle }}">
149 <div class="flex justify-between items-center">
150 <a
151 href="/{{ $.RepoInfo.FullName }}/blob/{{ $.Ref | urlquery }}/{{ .Name }}"
152 class="{{ $linkstyle }}"
153 >
154 <div class="flex items-center gap-2">
155 {{ i "file" "size-4" }}{{ .Name }}
156 </div>
157 </a>
158
159 {{ if .LastCommit }}
160 <time class="text-xs text-gray-500 dark:text-gray-400"
161 >{{ timeFmt .LastCommit.When }}</time
162 >
163 {{ end }}
164 </div>
165 </div>
166 {{ end }}
167 {{ end }}
168 </div>
169{{ end }}
170
171{{ define "rightInfo" }}
172 <div id="right-info" class="hidden md:block col-span-1">
173 {{ block "commitLog" . }} {{ end }}
174 {{ block "branchList" . }} {{ end }}
175 {{ block "tagList" . }} {{ end }}
176 </div>
177{{ end }}
178
179{{ define "commitLog" }}
180<div id="commit-log" class="md:col-span-1 px-2 pb-4">
181 <div class="flex justify-between items-center">
182 <a href="/{{ .RepoInfo.FullName }}/commits/{{ .Ref | urlquery }}" class="flex text-black dark:text-white items-center gap-4 pb-2 no-underline hover:no-underline group">
183 <div class="flex gap-2 items-center font-bold">
184 {{ i "logs" "w-4 h-4" }} commits
185 </div>
186 <span class="hidden group-hover:flex gap-2 items-center text-sm text-gray-500 dark:text-gray-400 ">
187 view {{ .TotalCommits }} commits {{ i "chevron-right" "w-4 h-4" }}
188 </span>
189 </a>
190 </div>
191 <div class="flex flex-col gap-6">
192 {{ range .CommitsTrunc }}
193 <div>
194 <div id="commit-message">
195 {{ $messageParts := splitN .Message "\n\n" 2 }}
196 <div class="text-base cursor-pointer">
197 <div>
198 <div>
199 <a
200 href="/{{ $.RepoInfo.FullName }}/commit/{{ .Hash.String }}"
201 class="inline no-underline hover:underline dark:text-white"
202 >{{ index $messageParts 0 }}</a
203 >
204 {{ if gt (len $messageParts) 1 }}
205
206 <button
207 class="py-1/2 px-1 bg-gray-200 hover:bg-gray-400 rounded dark:bg-gray-700 dark:hover:bg-gray-600"
208 hx-on:click="this.parentElement.nextElementSibling.classList.toggle('hidden')"
209 >
210 {{ i "ellipsis" "w-3 h-3" }}
211 </button>
212 {{ end }}
213 </div>
214 {{ if gt (len $messageParts) 1 }}
215 <p
216 class="hidden mt-1 text-sm cursor-text pb-2 dark:text-gray-300"
217 >
218 {{ nl2br (index $messageParts 1) }}
219 </p>
220 {{ end }}
221 </div>
222 </div>
223 </div>
224
225 <div class="text-xs mt-2 text-gray-500 dark:text-gray-400 flex items-center">
226 {{ $verified := false }}
227 {{ $verified = index $.VerifiedCommits .Hash.String }}
228 {{ $hashStyle := "text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-900" }}
229 {{ if $verified }}
230 {{ $hashStyle = "bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200 px-2 rounded" }}
231 {{ end }}
232 <span class="font-mono">
233 <a href="/{{ $.RepoInfo.FullName }}/commit/{{ .Hash.String }}"
234 class="no-underline hover:underline {{ $hashStyle }} px-2 py-1 rounded flex items-center gap-2">
235 {{ slice .Hash.String 0 8 }}
236 {{ if $verified }}
237 {{ i "shield-check" "w-3 h-3" }}
238 {{ end }}
239 </a>
240 </span>
241 <span
242 class="mx-2 before:content-['·'] before:select-none"
243 ></span>
244 <span>
245 {{ $didOrHandle := index $.EmailToDidOrHandle .Author.Email }}
246 <a
247 href="{{ if $didOrHandle }}
248 /{{ $didOrHandle }}
249 {{ else }}
250 mailto:{{ .Author.Email }}
251 {{ end }}"
252 class="text-gray-500 dark:text-gray-400 no-underline hover:underline"
253 >{{ if $didOrHandle }}
254 {{ $didOrHandle }}
255 {{ else }}
256 {{ .Author.Name }}
257 {{ end }}</a
258 >
259 </span>
260 <div
261 class="inline-block px-1 select-none after:content-['·']"
262 ></div>
263 <span>{{ timeFmt .Committer.When }}</span>
264 {{ $tagsForCommit := index $.TagMap .Hash.String }}
265 {{ if gt (len $tagsForCommit) 0 }}
266 <div
267 class="inline-block px-1 select-none after:content-['·']"
268 ></div>
269 {{ end }}
270 {{ range $tagsForCommit }}
271 <span
272 class="text-xs rounded bg-gray-100 dark:bg-gray-700 text-black dark:text-white font-mono px-2 mx-1/2 inline-flex items-center"
273 >
274 {{ . }}
275 </span>
276 {{ end }}
277 </div>
278 </div>
279 {{ end }}
280 </div>
281</div>
282{{ end }}
283
284{{ define "branchList" }}
285 {{ if gt (len .BranchesTrunc) 0 }}
286 <div id="branches" class="md:col-span-1 px-2 py-4 border-t border-gray-200 dark:border-gray-700">
287 <a href="/{{ .RepoInfo.FullName }}/branches" class="flex text-black dark:text-white items-center gap-4 pb-2 no-underline hover:no-underline group">
288 <div class="flex gap-2 items-center font-bold">
289 {{ i "git-branch" "w-4 h-4" }} branches
290 </div>
291 <span class="hidden group-hover:flex gap-2 items-center text-sm text-gray-500 dark:text-gray-400 ">
292 view {{ len .Branches }} branches {{ i "chevron-right" "w-4 h-4" }}
293 </span>
294 </a>
295 <div class="flex flex-col gap-1">
296 {{ range .BranchesTrunc }}
297 <div class="text-base flex items-center gap-2">
298 <a href="/{{ $.RepoInfo.FullName }}/tree/{{ .Reference.Name | urlquery }}"
299 class="inline no-underline hover:underline dark:text-white">
300 {{ .Reference.Name }}
301 </a>
302 {{ if .Commit }}
303 <span class="px-1 text-gray-500 dark:text-gray-400 select-none after:content-['·']"></span>
304 <time class="text-xs text-gray-500 dark:text-gray-400">{{ timeFmt .Commit.Committer.When }}</time>
305 {{ end }}
306 {{ if .IsDefault }}
307 <span class="px-1 text-gray-500 dark:text-gray-400 select-none after:content-['·']"></span>
308 <span class="bg-gray-200 dark:bg-gray-700 rounded py-1/2 px-1 text-xs font-mono">default</span>
309 {{ end }}
310 </div>
311 {{ end }}
312 </div>
313 </div>
314 {{ end }}
315{{ end }}
316
317{{ define "tagList" }}
318 {{ if gt (len .TagsTrunc) 0 }}
319 <div id="tags" class="md:col-span-1 px-2 py-4 border-t border-gray-200 dark:border-gray-700">
320 <div class="flex justify-between items-center">
321 <a href="/{{ .RepoInfo.FullName }}/tags" class="flex text-black dark:text-white items-center gap-4 pb-2 no-underline hover:no-underline group">
322 <div class="flex gap-2 items-center font-bold">
323 {{ i "tags" "w-4 h-4" }} tags
324 </div>
325 <span class="hidden group-hover:flex gap-2 items-center text-sm text-gray-500 dark:text-gray-400 ">
326 view {{ len .Tags }} tags {{ i "chevron-right" "w-4 h-4" }}
327 </span>
328 </a>
329 </div>
330 <div class="flex flex-col gap-1">
331 {{ range $idx, $tag := .TagsTrunc }}
332 {{ with $tag }}
333 <div>
334 <div class="text-base flex items-center gap-2">
335 <a href="/{{ $.RepoInfo.FullName }}/tree/{{ .Reference.Name | urlquery }}"
336 class="inline no-underline hover:underline dark:text-white">
337 {{ .Reference.Name }}
338 </a>
339 </div>
340 <div>
341 {{ with .Tag }}
342 <time class="text-xs text-gray-500 dark:text-gray-400">{{ timeFmt .Tagger.When }}</time>
343 {{ end }}
344 {{ if eq $idx 0 }}
345 <span class="px-1 text-gray-500 dark:text-gray-400 select-none after:content-['·']"></span>
346 <span class="bg-gray-200 dark:bg-gray-700 rounded py-1/2 px-1 text-xs font-mono">latest</span>
347 {{ end }}
348 </div>
349 </div>
350 {{ end }}
351 {{ end }}
352 </div>
353 </div>
354 {{ end }}
355{{ end }}
356
357{{ define "repoAfter" }}
358 {{- if .HTMLReadme -}}
359 <section
360 class="p-6 mt-4 rounded-br rounded-bl bg-white dark:bg-gray-800 dark:text-white drop-shadow-sm w-full mx-auto overflow-auto {{ if not .Raw }}
361 prose dark:prose-invert dark:[&_pre]:bg-gray-900
362 dark:[&_code]:text-gray-300 dark:[&_pre_code]:bg-gray-900
363 dark:[&_pre]:border dark:[&_pre]:border-gray-700
364 {{ end }}"
365 >
366 <article class="{{ if .Raw }}whitespace-pre{{ end }}">{{- if .Raw -}}<pre class="dark:bg-gray-800 dark:text-white overflow-x-scroll">
367 {{- .HTMLReadme -}}
368 </pre>
369 {{- else -}}
370 {{ .HTMLReadme }}
371 {{- end -}}</article>
372 </section>
373 {{- end -}}
374
375 {{ template "repo/fragments/cloneInstructions" . }}
376{{ end }}