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