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