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 <div class="flex items-center justify-between pb-5"> 33 {{ block "branchSelector" . }}{{ end }} 34 <div class="flex md:hidden items-center gap-4"> 35 <a href="/{{ .RepoInfo.FullName }}/commits/{{ .Ref | urlquery }}" class="inline-flex items-center text-sm gap-1"> 36 {{ i "git-commit-horizontal" "w-4" "h-4" }} {{ .TotalCommits }} 37 </a> 38 <a href="/{{ .RepoInfo.FullName }}/branches" class="inline-flex items-center text-sm gap-1"> 39 {{ i "git-branch" "w-4" "h-4" }} {{ len .Branches }} 40 </a> 41 <a href="/{{ .RepoInfo.FullName }}/tags" class="inline-flex items-center text-sm gap-1"> 42 {{ i "tags" "w-4" "h-4" }} {{ len .Tags }} 43 </a> 44 </div> 45 </div> 46 <div class="grid grid-cols-1 md:grid-cols-2 gap-2"> 47 {{ block "fileTree" . }}{{ end }} 48 {{ block "rightInfo" . }}{{ end }} 49 </div> 50 </main> 51{{ end }} 52 53{{ define "branchSelector" }} 54 <select 55 onchange="window.location.href = '/{{ .RepoInfo.FullName }}/tree/' + encodeURIComponent(this.value)" 56 class="p-1 border max-w-32 border-gray-200 bg-white dark:bg-gray-800 dark:text-white dark:border-gray-700" 57 > 58 <optgroup label="branches ({{len .Branches}})" class="bold text-sm"> 59 {{ range .Branches }} 60 <option 61 value="{{ .Reference.Name }}" 62 class="py-1" 63 {{ if eq .Reference.Name $.Ref }} 64 selected 65 {{ end }} 66 > 67 {{ .Reference.Name }} 68 </option> 69 {{ end }} 70 </optgroup> 71 <optgroup label="tags ({{len .Tags}})" class="bold text-sm"> 72 {{ range .Tags }} 73 <option 74 value="{{ .Reference.Name }}" 75 class="py-1" 76 {{ if eq .Reference.Name $.Ref }} 77 selected 78 {{ end }} 79 > 80 {{ .Reference.Name }} 81 </option> 82 {{ else }} 83 <option class="py-1" disabled>no tags found</option> 84 {{ end }} 85 </optgroup> 86 </select> 87{{ end }} 88 89{{ define "fileTree" }} 90 <div 91 id="file-tree" 92 class="col-span-1 pr-2 md:border-r md:border-gray-200 dark:md:border-gray-700" 93 > 94 {{ $containerstyle := "py-1" }} 95 {{ $linkstyle := "no-underline hover:underline dark:text-white" }} 96 97 {{ range .Files }} 98 {{ if not .IsFile }} 99 <div class="{{ $containerstyle }}"> 100 <div class="flex justify-between items-center"> 101 <a 102 href="/{{ $.RepoInfo.FullName }}/tree/{{ $.Ref | urlquery }}/{{ .Name }}" 103 class="{{ $linkstyle }}" 104 > 105 <div class="flex items-center gap-2"> 106 {{ i "folder" "size-4 fill-current" }} 107 {{ .Name }} 108 </div> 109 </a> 110 111 <time class="text-xs text-gray-500 dark:text-gray-400" 112 >{{ timeFmt .LastCommit.When }}</time 113 > 114 </div> 115 </div> 116 {{ end }} 117 {{ end }} 118 119 {{ range .Files }} 120 {{ if .IsFile }} 121 <div class="{{ $containerstyle }}"> 122 <div class="flex justify-between items-center"> 123 <a 124 href="/{{ $.RepoInfo.FullName }}/blob/{{ $.Ref | urlquery }}/{{ .Name }}" 125 class="{{ $linkstyle }}" 126 > 127 <div class="flex items-center gap-2"> 128 {{ i "file" "size-4" }}{{ .Name }} 129 </div> 130 </a> 131 132 <time class="text-xs text-gray-500 dark:text-gray-400" 133 >{{ timeFmt .LastCommit.When }}</time 134 > 135 </div> 136 </div> 137 {{ end }} 138 {{ end }} 139 </div> 140{{ end }} 141 142{{ define "rightInfo" }} 143 <div id="right-info" class="hidden md:block col-span-1"> 144 {{ block "commitLog" . }} {{ end }} 145 {{ block "branchList" . }} {{ end }} 146 {{ block "tagList" . }} {{ end }} 147 </div> 148{{ end }} 149 150{{ define "commitLog" }} 151<div id="commit-log" class="md:col-span-1 px-2 pb-4"> 152 <div class="flex justify-between items-center"> 153 <a href="/{{ .RepoInfo.FullName }}/commits/{{ .Ref | urlquery }}" class="flex text-black dark:text-white items-center gap-4 pb-2 no-underline hover:no-underline group"> 154 <div class="flex gap-2 items-center font-bold"> 155 {{ i "logs" "w-4 h-4" }} commits 156 </div> 157 <span class="hidden group-hover:flex gap-2 items-center text-sm text-gray-500 dark:text-gray-400 "> 158 view {{ .TotalCommits }} commits {{ i "chevron-right" "w-4 h-4" }} 159 </span> 160 </a> 161 </div> 162 <div class="flex flex-col gap-6"> 163 {{ range .CommitsTrunc }} 164 <div> 165 <div id="commit-message"> 166 {{ $messageParts := splitN .Message "\n\n" 2 }} 167 <div class="text-base cursor-pointer"> 168 <div> 169 <div> 170 <a 171 href="/{{ $.RepoInfo.FullName }}/commit/{{ .Hash.String }}" 172 class="inline no-underline hover:underline dark:text-white" 173 >{{ index $messageParts 0 }}</a 174 > 175 {{ if gt (len $messageParts) 1 }} 176 177 <button 178 class="py-1/2 px-1 bg-gray-200 hover:bg-gray-400 rounded dark:bg-gray-700 dark:hover:bg-gray-600" 179 hx-on:click="this.parentElement.nextElementSibling.classList.toggle('hidden')" 180 > 181 {{ i "ellipsis" "w-3 h-3" }} 182 </button> 183 {{ end }} 184 </div> 185 {{ if gt (len $messageParts) 1 }} 186 <p 187 class="hidden mt-1 text-sm cursor-text pb-2 dark:text-gray-300" 188 > 189 {{ nl2br (index $messageParts 1) }} 190 </p> 191 {{ end }} 192 </div> 193 </div> 194 </div> 195 196 <div class="text-xs text-gray-500 dark:text-gray-400"> 197 <span class="font-mono"> 198 <a 199 href="/{{ $.RepoInfo.FullName }}/commit/{{ .Hash.String }}" 200 class="text-gray-500 dark:text-gray-400 no-underline hover:underline" 201 >{{ slice .Hash.String 0 8 }}</a 202 ></span 203 > 204 <span 205 class="mx-2 before:content-['·'] before:select-none" 206 ></span> 207 <span> 208 {{ $didOrHandle := index $.EmailToDidOrHandle .Author.Email }} 209 <a 210 href="{{ if $didOrHandle }} 211 /{{ $didOrHandle }} 212 {{ else }} 213 mailto:{{ .Author.Email }} 214 {{ end }}" 215 class="text-gray-500 dark:text-gray-400 no-underline hover:underline" 216 >{{ if $didOrHandle }} 217 {{ $didOrHandle }} 218 {{ else }} 219 {{ .Author.Name }} 220 {{ end }}</a 221 > 222 </span> 223 <div 224 class="inline-block px-1 select-none after:content-['·']" 225 ></div> 226 <span>{{ timeFmt .Author.When }}</span> 227 {{ $tagsForCommit := index $.TagMap .Hash.String }} 228 {{ if gt (len $tagsForCommit) 0 }} 229 <div 230 class="inline-block px-1 select-none after:content-['·']" 231 ></div> 232 {{ end }} 233 {{ range $tagsForCommit }} 234 <span 235 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" 236 > 237 {{ . }} 238 </span> 239 {{ end }} 240 </div> 241 </div> 242 {{ end }} 243 </div> 244</div> 245{{ end }} 246 247{{ define "branchList" }} 248 {{ if gt (len .BranchesTrunc) 0 }} 249 <div id="branches" class="md:col-span-1 px-2 py-4 border-t border-gray-200 dark:border-gray-700"> 250 <a href="/{{ .RepoInfo.FullName }}/branches" class="flex text-black dark:text-white items-center gap-4 pb-2 no-underline hover:no-underline group"> 251 <div class="flex gap-2 items-center font-bold"> 252 {{ i "git-branch" "w-4 h-4" }} branches 253 </div> 254 <span class="hidden group-hover:flex gap-2 items-center text-sm text-gray-500 dark:text-gray-400 "> 255 view {{ len .Branches }} branches {{ i "chevron-right" "w-4 h-4" }} 256 </span> 257 </a> 258 <div class="flex flex-col gap-1"> 259 {{ range .BranchesTrunc }} 260 <div class="text-base flex items-center gap-2"> 261 <a href="/{{ $.RepoInfo.FullName }}/tree/{{ .Reference.Name | urlquery }}" 262 class="inline no-underline hover:underline dark:text-white"> 263 {{ .Reference.Name }} 264 </a> 265 {{ if .Commit }} 266 <span class="px-1 text-gray-500 dark:text-gray-400 select-none after:content-['·']"></span> 267 <time class="text-xs text-gray-500 dark:text-gray-400">{{ timeFmt .Commit.Author.When }}</time> 268 {{ end }} 269 {{ if .IsDefault }} 270 <span class="px-1 text-gray-500 dark:text-gray-400 select-none after:content-['·']"></span> 271 <span class="bg-gray-200 dark:bg-gray-700 rounded py-1/2 px-1 text-xs font-mono">default</span> 272 {{ end }} 273 </div> 274 {{ end }} 275 </div> 276 </div> 277 {{ end }} 278{{ end }} 279 280{{ define "tagList" }} 281 {{ if gt (len .TagsTrunc) 0 }} 282 <div id="tags" class="md:col-span-1 px-2 py-4 border-t border-gray-200 dark:border-gray-700"> 283 <div class="flex justify-between items-center"> 284 <a href="/{{ .RepoInfo.FullName }}/tags" class="flex text-black dark:text-white items-center gap-4 pb-2 no-underline hover:no-underline group"> 285 <div class="flex gap-2 items-center font-bold"> 286 {{ i "tags" "w-4 h-4" }} tags 287 </div> 288 <span class="hidden group-hover:flex gap-2 items-center text-sm text-gray-500 dark:text-gray-400 "> 289 view {{ len .Tags }} tags {{ i "chevron-right" "w-4 h-4" }} 290 </span> 291 </a> 292 </div> 293 <div class="flex flex-col gap-1"> 294 {{ range $idx, $tag := .TagsTrunc }} 295 {{ with $tag }} 296 <div> 297 <div class="text-base flex items-center gap-2"> 298 <a href="/{{ $.RepoInfo.FullName }}/tree/{{ .Reference.Name | urlquery }}" 299 class="inline no-underline hover:underline dark:text-white"> 300 {{ .Reference.Name }} 301 </a> 302 </div> 303 <div> 304 {{ with .Tag }} 305 <time class="text-xs text-gray-500 dark:text-gray-400">{{ timeFmt .Tagger.When }}</time> 306 {{ end }} 307 {{ if eq $idx 0 }} 308 <span class="px-1 text-gray-500 dark:text-gray-400 select-none after:content-['·']"></span> 309 <span class="bg-gray-200 dark:bg-gray-700 rounded py-1/2 px-1 text-xs font-mono">latest</span> 310 {{ end }} 311 </div> 312 </div> 313 {{ end }} 314 {{ end }} 315 </div> 316 </div> 317 {{ end }} 318{{ end }} 319 320{{ define "repoAfter" }} 321 {{- if .HTMLReadme }} 322 <section 323 class="p-6 mt-4 rounded-br rounded-bl bg-white dark:bg-gray-800 dark:text-white w-full mx-auto overflow-auto {{ if not .Raw }} 324 prose dark:prose-invert dark:[&_pre]:bg-gray-900 325 dark:[&_code]:text-gray-300 dark:[&_pre_code]:bg-gray-900 326 dark:[&_pre]:border dark:[&_pre]:border-gray-700 327 {{ end }}" 328 > 329 <article class="{{ if .Raw }}whitespace-pre{{ end }}"> 330 {{ if .Raw }} 331 <pre 332 class="dark:bg-gray-900 dark:text-gray-200 dark:border dark:border-gray-700 dark:p-4 dark:rounded" 333 > 334{{ .HTMLReadme }}</pre 335 > 336 {{ else }} 337 {{ .HTMLReadme }} 338 {{ end }} 339 </article> 340 </section> 341 {{- end -}} 342 343 {{ template "repo/fragments/cloneInstructions" . }} 344{{ end }}