155 lines
6.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-1/2">
8
{{ $containerstyle := "py-1" }}
9
{{ $linkstyle := "no-underline hover:underline" }}
10
11
12
<div class="flex justify-end">
13
<select
14
hx-get="/{{ .RepoInfo.FullName }}/tree/"
15
hx-on::config-request = "event.detail.path += this.value"
16
hx-trigger="change"
17
hx-target="#repo-content"
18
hx-select="#repo-content"
19
hx-push-url="true"
20
class="p-1 border border-gray-500 bg-white"
21
>
22
<optgroup label="branches" class="font-semibold">
23
{{ range .Branches }}
24
<option
25
value="{{ .Reference.Name }}"
26
class="py-1"
27
>
28
{{ .Reference.Name }}
29
</option>
30
{{ end }}
31
</optgroup>
32
<optgroup label="tags" class="font-semibold">
33
{{ range .Tags }}
34
<option
35
value="{{ .Reference.Name }}"
36
class="py-1"
37
>
38
{{ .Reference.Name }}
39
</option>
40
{{ end }}
41
</optgroup>
42
</select>
43
</div>
44
45
<section id="repo-content">
46
{{ range .Files }}
47
{{ if not .IsFile }}
48
<div class="{{ $containerstyle }}">
49
<a
50
href="/{{ $.RepoInfo.FullName }}/tree/{{ $.Ref }}/{{ .Name }}"
51
class="{{ $linkstyle }}"
52
>
53
<div class="flex items-center gap-2">
54
<i
55
class="w-3 h-3 fill-current"
56
data-lucide="folder"
57
></i
58
>{{ .Name }}/
59
</div>
60
</a>
61
</div>
62
{{ end }}
63
{{ end }}
64
65
{{ range .Files }}
66
{{ if .IsFile }}
67
<div class="{{ $containerstyle }}">
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
</div>
81
{{ end }}
82
{{ end }}
83
</div>
84
<div id="commit-log" class="flex-1">
85
{{ range .Commits }}
86
<div
87
class="relative
88
px-4
89
py-4
90
border-l
91
border-black
92
before:content-['']
93
before:absolute
94
before:w-1
95
before:h-1
96
before:bg-black
97
before:rounded-full
98
before:left-[-2.2px]
99
before:top-1/2
100
before:-translate-y-1/2
101
">
102
103
<div id="commit-message">
104
{{ $messageParts := splitN .Message "\n\n" 2 }}
105
<div class="text-base cursor-pointer">
106
{{ index $messageParts 0 }}
107
{{ if gt (len $messageParts) 1 }}
108
<div class="text-sm inline rounded-sm bg-gray-300 text-gray-700 px-1"
109
hx-on:click="this.nextElementSibling.classList.toggle('hidden')">...</div>
110
<div class="hidden mt-1 text-sm">{{ index $messageParts 1 }}</div>
111
{{ end }}
112
</div>
113
</div>
114
115
<div class="text-xs text-gray-500">
116
<span class="font-mono">
117
<a
118
href="/{{ $.RepoInfo.FullName }}/commit/{{ .Hash.String }}"
119
class="text-gray-500 no-underline hover:underline"
120
>{{ slice .Hash.String 0 8 }}</a
121
>
122
</span>
123
·
124
<span>
125
<a
126
href="mailto:{{ .Author.Email }}"
127
class="text-gray-500 no-underline hover:underline"
128
>{{ .Author.Name }}</a
129
>
130
</span>
131
·
132
<span>{{ timeFmt .Author.When }}</span>
133
</div>
134
</div>
135
{{ end }}
136
</div>
137
</div>
138
</section>
139
{{- if .Readme }}
140
<article class="readme">
141
{{- .Readme -}}
142
</article>
143
{{- end -}}
144
{{- end -}}
145
146
147
<div class="clone-url">
148
<strong>clone</strong>
149
<pre>
150
git clone https://tangled.sh/{{ .RepoInfo.OwnerWithAt }}/{{ .RepoInfo.Name }}
151
</pre
152
>
153
</div>
154
</main>
155
{{ end }}
156