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