1{{ define "title" }}{{ .RepoInfo.FullName }} at {{ .Ref }}{{ end }}
2
3
4{{ define "extrameta" }}
5 <meta name="vcs:clone" content="https://tangled.sh/{{ .RepoInfo.FullName }}"/>
6 <meta name="forge:summary" content="https://tangled.sh/{{ .RepoInfo.FullName }}">
7 <meta name="forge:dir" content="https://tangled.sh/{{ .RepoInfo.FullName }}/tree/{ref}/{path}">
8 <meta name="forge:file" content="https://tangled.sh/{{ .RepoInfo.FullName }}/blob/{ref}/{path}">
9 <meta name="forge:line" content="https://tangled.sh/{{ .RepoInfo.FullName }}/blob/{ref}/{path}#L{line}">
10 <meta name="go-import" content="tangled.sh/{{ .RepoInfo.FullNameWithoutAt }} git https://tangled.sh/{{ .RepoInfo.FullName }}">
11{{ end }}
12
13
14{{ define "repoContent" }}
15 <main>
16 {{ block "branchSelector" . }} {{ end }}
17 <div class="grid grid-cols-1 md:grid-cols-2 gap-2">
18 {{ block "fileTree" . }} {{ end }}
19 {{ block "commitLog" . }} {{ end }}
20 </div>
21 </main>
22{{ end }}
23
24{{ define "branchSelector" }}
25<div class="flex justify-between pb-5">
26 <select
27 onchange="window.location.href = '/{{ .RepoInfo.FullName }}/tree/' + encodeURIComponent(this.value)"
28 class="p-1 border border-gray-200 bg-white dark:bg-gray-800 dark:text-white dark:border-gray-700"
29 >
30 <optgroup label="branches" class="bold text-sm">
31 {{ range .Branches }}
32 <option
33 value="{{ .Reference.Name }}"
34 class="py-1"
35 {{ if eq .Reference.Name $.Ref }}
36 selected
37 {{ end }}
38 >
39 {{ .Reference.Name }}
40 </option>
41 {{ end }}
42 </optgroup>
43 <optgroup label="tags" class="bold text-sm">
44 {{ range .Tags }}
45 <option
46 value="{{ .Reference.Name }}"
47 class="py-1"
48 {{ if eq .Reference.Name $.Ref }}
49 selected
50 {{ end }}
51 >
52 {{ .Reference.Name }}
53 </option>
54 {{ else }}
55 <option class="py-1" disabled>no tags found</option>
56 {{ end }}
57 </optgroup>
58 </select>
59 <a
60 href="/{{ .RepoInfo.FullName }}/commits/{{ .Ref | urlquery }}"
61 class="ml-2 no-underline flex items-center gap-2 text-sm uppercase font-bold dark:text-white"
62 >
63 {{ i "logs" "w-4 h-4" }}
64 {{ .TotalCommits }}
65 {{ if eq .TotalCommits 1 }}commit{{ else }}commits{{ end }}
66 </a>
67</div>
68{{ end }}
69
70{{ define "fileTree" }}
71<div id="file-tree" class="col-span-1 pr-2 md:border-r md:border-gray-200 dark:md:border-gray-700">
72 {{ $containerstyle := "py-1" }}
73 {{ $linkstyle := "no-underline hover:underline dark:text-white" }}
74
75 {{ range .Files }}
76 {{ if not .IsFile }}
77 <div class="{{ $containerstyle }}">
78 <div class="flex justify-between items-center">
79 <a
80 href="/{{ $.RepoInfo.FullName }}/tree/{{ $.Ref | urlquery }}/{{ .Name }}"
81 class="{{ $linkstyle }}"
82 >
83 <div class="flex items-center gap-2">
84 {{ i "folder" "w-3 h-3 fill-current" }}
85 {{ .Name }}
86 </div>
87 </a>
88
89 <time class="text-xs text-gray-500 dark:text-gray-400"
90 >{{ timeFmt .LastCommit.When }}</time
91 >
92 </div>
93 </div>
94 {{ end }}
95 {{ end }}
96
97 {{ range .Files }}
98 {{ if .IsFile }}
99 <div class="{{ $containerstyle }}">
100 <div class="flex justify-between items-center">
101 <a
102 href="/{{ $.RepoInfo.FullName }}/blob/{{ $.Ref | urlquery }}/{{ .Name }}"
103 class="{{ $linkstyle }}"
104 >
105 <div class="flex items-center gap-2">
106 {{ i "file" "w-3 h-3" }}{{ .Name }}
107 </div>
108 </a>
109
110 <time class="text-xs text-gray-500 dark:text-gray-400"
111 >{{ timeFmt .LastCommit.When }}</time
112 >
113 </div>
114 </div>
115 {{ end }}
116 {{ end }}
117</div>
118{{ end }}
119
120
121{{ define "commitLog" }}
122<div id="commit-log" class="hidden md:block md:col-span-1">
123 {{ range .Commits }}
124 <div class="relative px-2 pb-8">
125 <div id="commit-message">
126 {{ $messageParts := splitN .Message "\n\n" 2 }}
127 <div class="text-base cursor-pointer">
128 <div>
129 <div>
130 <a
131 href="/{{ $.RepoInfo.FullName }}/commit/{{ .Hash.String }}"
132 class="inline no-underline hover:underline dark:text-white"
133 >{{ index $messageParts 0 }}</a
134 >
135 {{ if gt (len $messageParts) 1 }}
136
137 <button
138 class="py-1/2 px-1 bg-gray-200 hover:bg-gray-400 rounded dark:bg-gray-700 dark:hover:bg-gray-600"
139 hx-on:click="this.parentElement.nextElementSibling.classList.toggle('hidden')"
140 >
141 {{ i "ellipsis" "w-3 h-3" }}
142 </button>
143 {{ end }}
144 </div>
145 {{ if gt (len $messageParts) 1 }}
146 <p
147 class="hidden mt-1 text-sm cursor-text pb-2 dark:text-gray-300"
148 >
149 {{ nl2br (unwrapText (index $messageParts 1)) }}
150 </p>
151 {{ end }}
152 </div>
153 </div>
154 </div>
155
156 <div class="text-xs text-gray-500 dark:text-gray-400">
157 <span class="font-mono">
158 <a
159 href="/{{ $.RepoInfo.FullName }}/commit/{{ .Hash.String }}"
160 class="text-gray-500 dark:text-gray-400 no-underline hover:underline"
161 >{{ slice .Hash.String 0 8 }}</a
162 >
163 </span>
164 <span
165 class="mx-2 before:content-['·'] before:select-none"
166 ></span>
167 <span>
168 {{ $didOrHandle := index $.EmailToDidOrHandle .Author.Email }}
169 <a
170 href="{{ if $didOrHandle }}/{{ $didOrHandle }}{{ else }}mailto:{{ .Author.Email }}{{ end }}"
171 class="text-gray-500 dark:text-gray-400 no-underline hover:underline"
172 >{{ if $didOrHandle }}{{ $didOrHandle }}{{ else }}{{ .Author.Name }}{{ end }}</a
173 >
174 </span>
175 <div
176 class="inline-block px-1 select-none after:content-['·']"
177 ></div>
178 <span>{{ timeFmt .Author.When }}</span>
179 {{ $tagsForCommit := index $.TagMap .Hash.String }}
180 {{ if gt (len $tagsForCommit) 0 }}
181 <div
182 class="inline-block px-1 select-none after:content-['·']"
183 ></div>
184 {{ end }}
185 {{ range $tagsForCommit }}
186 <span class="text-xs rounded bg-gray-100 dark:bg-gray-700 text-black dark:text-white font-mono px-2 mx-1/2 inline-flex items-center">
187 {{ . }}
188 </span>
189 {{ end }}
190 </div>
191 </div>
192 {{ end }}
193</div>
194{{ end }}
195
196
197{{ define "repoAfter" }}
198 {{- if .HTMLReadme }}
199 <section class="mt-4 p-6 rounded bg-white dark:bg-gray-800 dark:text-white w-full mx-auto overflow-auto {{ if not .Raw }} prose dark:prose-invert dark:[&_pre]:bg-gray-900 dark:[&_code]:text-gray-300 dark:[&_pre_code]:bg-gray-900 dark:[&_pre]:border dark:[&_pre]:border-gray-700 {{ end }}">
200 <article class="{{ if .Raw }}whitespace-pre{{end}}">
201 {{ if .Raw }}
202 <pre class="dark:bg-gray-900 dark:text-gray-200 dark:border dark:border-gray-700 dark:p-4 dark:rounded">{{ .HTMLReadme }}</pre>
203 {{ else }}
204 {{ .HTMLReadme }}
205 {{ end }}
206 </article>
207 </section>
208 {{- end -}}
209
210 {{ template "fragments/cloneInstructions" . }}
211{{ end }}