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