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