blob.html
·
106 строк
·
4.3 KB
| 1 | {{define "content"}} |
| 2 | <div class="container"> |
| 3 | {{template "repo_header" .}} |
| 4 | |
| 5 | <div class="flex items-center justify-between flex-wrap gap-2 mb-3"> |
| 6 | <div class="flex items-center gap-2 flex-wrap"> |
| 7 | <div class="dropdown" data-dropdown> |
| 8 | <button type="button" class="btn btn-outline btn-sm font-mono" data-dropdown-trigger aria-haspopup="true" aria-expanded="false"> |
| 9 | {{icon "git-branch" "size-3.5"}} |
| 10 | <span>{{.Ref}}</span> |
| 11 | {{icon "chevron-down" "size-3.5"}} |
| 12 | </button> |
| 13 | <div class="dropdown-menu" data-dropdown-menu role="menu" style="min-width:13rem;"> |
| 14 | <div class="palette-group-title">{{t .Lang "repo.branches"}}</div> |
| 15 | {{range .Branches}} |
| 16 | <a href="/{{$.Repo.OwnerUsername}}/{{$.Repo.Name}}/blob/{{.}}/{{$.SubPath}}" class="dropdown-item font-mono {{if eq . $.Ref}}active{{end}}" role="menuitem"> |
| 17 | <span class="flex items-center gap-2">{{icon "git-branch" "size-3.5"}} {{.}}</span> |
| 18 | {{if eq . $.Ref}}{{icon "check" "size-3.5"}}{{end}} |
| 19 | </a> |
| 20 | {{end}} |
| 21 | {{if .Tags}} |
| 22 | <hr class="separator" style="margin:0.25rem 0;"> |
| 23 | <div class="palette-group-title">{{t .Lang "repo.tags"}}</div> |
| 24 | {{range .Tags}} |
| 25 | <a href="/{{$.Repo.OwnerUsername}}/{{$.Repo.Name}}/blob/{{.}}/{{$.SubPath}}" class="dropdown-item font-mono {{if eq . $.Ref}}active{{end}}" role="menuitem"> |
| 26 | <span class="flex items-center gap-2">{{icon "tag" "size-3.5"}} {{.}}</span> |
| 27 | {{if eq . $.Ref}}{{icon "check" "size-3.5"}}{{end}} |
| 28 | </a> |
| 29 | {{end}} |
| 30 | {{end}} |
| 31 | </div> |
| 32 | </div> |
| 33 | |
| 34 | <nav class="breadcrumb font-mono text-xs" aria-label="File breadcrumb"> |
| 35 | <a href="/{{.Repo.OwnerUsername}}/{{.Repo.Name}}/tree/{{.Ref}}" class="text-muted">{{.Repo.Name}}</a> |
| 36 | {{range .Breadcrumbs}} |
| 37 | <span class="breadcrumb-sep">/</span> |
| 38 | {{if .IsLast}} |
| 39 | <span class="font-semibold">{{.Name}}</span> |
| 40 | {{else}} |
| 41 | <a href="/{{$.Repo.OwnerUsername}}/{{$.Repo.Name}}/tree/{{$.Ref}}/{{.Path}}" class="text-muted">{{.Name}}</a> |
| 42 | {{end}} |
| 43 | {{end}} |
| 44 | </nav> |
| 45 | </div> |
| 46 | |
| 47 | <div class="flex items-center gap-1.5"> |
| 48 | <button type="button" class="btn btn-outline btn-sm" data-open-palette="file:"> |
| 49 | {{icon "search" "size-3.5"}} |
| 50 | <kbd class="kbd">t</kbd> |
| 51 | </button> |
| 52 | </div> |
| 53 | </div> |
| 54 | |
| 55 | <div class="card"> |
| 56 | <div class="card-header" style="padding:0.5rem 0.8rem;"> |
| 57 | <div class="flex items-center gap-2 text-xs text-muted font-mono"> |
| 58 | {{icon "file-code" "size-4"}} |
| 59 | <span class="font-semibold" style="color:hsl(var(--foreground));">{{.Blob.Name}}</span> |
| 60 | <span>·</span> |
| 61 | {{if not .Blob.IsBinary}} |
| 62 | <span>{{.Blob.LineCount}} {{pluralT .Lang .Blob.LineCount "repo.lines"}}</span> |
| 63 | <span>·</span> |
| 64 | {{end}} |
| 65 | <span>{{formatSize .Blob.Size}}</span> |
| 66 | </div> |
| 67 | |
| 68 | <div class="flex items-center gap-1.5"> |
| 69 | {{if not .Blob.IsBinary}} |
| 70 | <button type="button" class="btn btn-outline btn-sm" data-copy="{{.RawText}}" aria-label="{{t .Lang "common.copy"}}"> |
| 71 | {{icon "copy" "size-3.5"}} |
| 72 | <span>{{t .Lang "common.copy"}}</span> |
| 73 | </button> |
| 74 | {{end}} |
| 75 | <a href="/{{.Repo.OwnerUsername}}/{{.Repo.Name}}/raw/{{.Ref}}/{{.SubPath}}" class="btn btn-outline btn-sm"> |
| 76 | {{icon "download" "size-3.5"}} |
| 77 | <span>{{t .Lang "repo.raw"}}</span> |
| 78 | </a> |
| 79 | </div> |
| 80 | </div> |
| 81 | |
| 82 | {{if .Blob.IsBinary}} |
| 83 | <div class="card-body text-center py-2 text-sm text-muted"> |
| 84 | <p>{{t .Lang "repo.binary_notice"}} ({{formatSize .Blob.Size}})</p> |
| 85 | <a href="/{{.Repo.OwnerUsername}}/{{.Repo.Name}}/raw/{{.Ref}}/{{.SubPath}}" class="btn btn-secondary btn-sm"> |
| 86 | {{icon "download" "size-3.5"}} |
| 87 | <span>{{t .Lang "repo.download_raw"}}</span> |
| 88 | </a> |
| 89 | </div> |
| 90 | {{else}} |
| 91 | <div style="overflow-x:auto;"> |
| 92 | <table class="code-table chroma"> |
| 93 | <tbody> |
| 94 | {{range .HighlightedLines}} |
| 95 | <tr id="L{{.Num}}"> |
| 96 | <td class="code-ln"><a href="#L{{.Num}}">{{.Num}}</a></td> |
| 97 | <td class="code-line">{{.HTML}}</td> |
| 98 | </tr> |
| 99 | {{end}} |
| 100 | </tbody> |
| 101 | </table> |
| 102 | </div> |
| 103 | {{end}} |
| 104 | </div> |
| 105 | </div> |
| 106 | {{end}} |