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