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