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