207 lines
7.5 kB
1
{{ define "title" }}{{ .RepoInfo.FullName }} at {{ .Ref }}{{ end }}
2
3
{{ define "repoContent" }}
4
<main>
5
{{ block "branchSelector" . }} {{ end }}
6
<div class="flex gap-2">
7
{{ block "fileTree" . }} {{ end }}
8
{{ block "commitLog" . }} {{ end }}
9
</div>
10
</main>
11
{{ end }}
12
13
{{ define "branchSelector" }}
14
<div class="flex justify-between pb-5">
15
<select
16
onchange="window.location.href = '/{{ .RepoInfo.FullName }}/tree/' + this.value"
17
class="p-1 border border-gray-200 bg-white"
18
>
19
<optgroup label="branches" class="bold text-sm">
20
{{ range .Branches }}
21
<option
22
value="{{ .Reference.Name }}"
23
class="py-1"
24
{{ if eq .Reference.Name $.Ref }}
25
selected
26
{{ end }}
27
>
28
{{ .Reference.Name }}
29
</option>
30
{{ end }}
31
</optgroup>
32
<optgroup label="tags" class="bold text-sm">
33
{{ range .Tags }}
34
<option
35
value="{{ .Reference.Name }}"
36
class="py-1"
37
{{ if eq .Reference.Name $.Ref }}
38
selected
39
{{ end }}
40
>
41
{{ .Reference.Name }}
42
</option>
43
{{ else }}
44
<option class="py-1" disabled>no tags found</option>
45
{{ end }}
46
</optgroup>
47
</select>
48
<a
49
href="/{{ .RepoInfo.FullName }}/commits/{{ .Ref }}"
50
class="ml-2 no-underline flex items-center gap-2 text-sm uppercase font-bold"
51
>
52
<i class="w-4 h-4" data-lucide="logs"></i>
53
{{ .TotalCommits }}
54
{{ if eq .TotalCommits 1 }}commit{{ else }}commits{{ end }}
55
</a>
56
</div>
57
{{ end }}
58
59
{{ define "fileTree" }}
60
<div id="file-tree" class="w-3/5 pr-2 border-r border-gray-200">
61
{{ $containerstyle := "py-1" }}
62
{{ $linkstyle := "no-underline hover:underline" }}
63
64
{{ range .Files }}
65
{{ if not .IsFile }}
66
<div class="{{ $containerstyle }}">
67
<div class="flex justify-between items-center">
68
<a
69
href="/{{ $.RepoInfo.FullName }}/tree/{{ $.Ref }}/{{ .Name }}"
70
class="{{ $linkstyle }}"
71
>
72
<div class="flex items-center gap-2">
73
<i
74
class="w-3 h-3 fill-current"
75
data-lucide="folder"
76
></i
77
>{{ .Name }}
78
</div>
79
</a>
80
81
<time class="text-xs text-gray-500"
82
>{{ timeFmt .LastCommit.Author.When }}</time
83
>
84
</div>
85
</div>
86
{{ end }}
87
{{ end }}
88
89
{{ range .Files }}
90
{{ if .IsFile }}
91
<div class="{{ $containerstyle }}">
92
<div class="flex justify-between items-center">
93
<a
94
href="/{{ $.RepoInfo.FullName }}/blob/{{ $.Ref }}/{{ .Name }}"
95
class="{{ $linkstyle }}"
96
>
97
<div class="flex items-center gap-2">
98
<i
99
class="w-3 h-3"
100
data-lucide="file"
101
></i
102
>{{ .Name }}
103
</div>
104
</a>
105
106
<time class="text-xs text-gray-500"
107
>{{ timeFmt .LastCommit.Author.When }}</time
108
>
109
</div>
110
</div>
111
{{ end }}
112
{{ end }}
113
</div>
114
{{ end }}
115
116
117
{{ define "commitLog" }}
118
<div id="commit-log" class="flex-1">
119
{{ range .Commits }}
120
<div class="relative px-2 pb-8">
121
<div id="commit-message">
122
{{ $messageParts := splitN .Message "\n\n" 2 }}
123
<div class="text-base cursor-pointer">
124
<div>
125
<div>
126
<a
127
href="/{{ $.RepoInfo.FullName }}/commit/{{ .Hash.String }}"
128
class="inline no-underline hover:underline"
129
>{{ index $messageParts 0 }}</a
130
>
131
{{ if gt (len $messageParts) 1 }}
132
133
<button
134
class="py-1/2 px-1 bg-gray-200 hover:bg-gray-400 rounded"
135
hx-on:click="this.parentElement.nextElementSibling.classList.toggle('hidden')"
136
>
137
<i
138
class="w-3 h-3"
139
data-lucide="ellipsis"
140
></i>
141
</button>
142
{{ end }}
143
144
{{ $tagsForCommit := index $.TagMap .Hash.String }}
145
{{ range $tagsForCommit }}
146
<span class="text-xs rounded-full bg-black text-white px-2 mx-1 inline-flex items-center">
147
{{ . }}
148
</span>
149
{{ end }}
150
</div>
151
{{ if gt (len $messageParts) 1 }}
152
<p
153
class="hidden mt-1 text-sm cursor-text pb-2"
154
>
155
{{ nl2br (unwrapText (index $messageParts 1)) }}
156
</p>
157
{{ end }}
158
</div>
159
</div>
160
</div>
161
162
<div class="text-xs text-gray-500">
163
<span class="font-mono">
164
<a
165
href="/{{ $.RepoInfo.FullName }}/commit/{{ .Hash.String }}"
166
class="text-gray-500 no-underline hover:underline"
167
>{{ slice .Hash.String 0 8 }}</a
168
>
169
</span>
170
<span
171
class="mx-2 before:content-['·'] before:select-none"
172
></span>
173
<span>
174
<a
175
href="mailto:{{ .Author.Email }}"
176
class="text-gray-500 no-underline hover:underline"
177
>{{ .Author.Name }}</a
178
>
179
</span>
180
<div
181
class="inline-block px-1 select-none after:content-['·']"
182
></div>
183
<span>{{ timeFmt .Author.When }}</span>
184
</div>
185
</div>
186
{{ end }}
187
</div>
188
{{ end }}
189
190
191
{{ define "repoAfter" }}
192
{{- if .Readme }}
193
<section class="mt-4 p-6 rounded bg-white w-full mx-auto">
194
<article class="readme">
195
{{- .Readme -}}
196
</article>
197
</section>
198
{{- end -}}
199
200
201
<section class="mt-4 p-6 rounded bg-white w-full mx-auto">
202
<strong>clone</strong>
203
<pre>
204
git clone https://tangled.sh/{{ .RepoInfo.OwnerWithAt }}/{{ .RepoInfo.Name }} </pre
205
>
206
</section>
207
{{ end }}
208