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