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