| 1 | {{define "blob.html"}}{{template "base.html" .}}{{end}} |
| 2 | {{define "title"}}{{.Path}} — {{.Repo.Name}} — {{.SiteName}}{{end}} |
| 3 | {{define "tabs"}} |
| 4 | <a href="/{{.Repo.Name}}" class="tab">home</a> |
| 5 | <a href="/{{.Repo.Name}}/log/{{.Ref}}" class="tab">log</a> |
| 6 | <a href="/{{.Repo.Name}}/refs" class="tab">refs</a> |
| 7 | {{end}} |
| 8 | {{define "content"}} |
| 9 | <nav class="breadcrumbs"> |
| 10 | {{range $i, $b := .Breadcrumbs}}{{if $i}} / {{end}}<a href="{{$b.Href}}">{{$b.Name}}</a>{{end}} |
| 11 | </nav> |
| 12 | |
| 13 | <div class="file-view"> |
| 14 | <header class="file-header"> |
| 15 | <span class="file-name">{{.Path}}</span> |
| 16 | <span class="file-meta">{{humanSize .Size}}</span> |
| 17 | {{if not .Binary}}<button type="button" class="copy-btn" data-raw="/{{.Repo.Name}}/raw/{{.Ref}}/{{.Path}}">copy</button>{{end}} |
| 18 | <a href="/{{.Repo.Name}}/raw/{{.Ref}}/{{.Path}}">raw</a> |
| 19 | </header> |
| 20 | {{if .Binary}} |
| 21 | <p class="empty">Binary file — <a href="/{{.Repo.Name}}/raw/{{.Ref}}/{{.Path}}">download raw</a>.</p> |
| 22 | {{else}} |
| 23 | <div class="blob-view">{{.HighlightedHTML}}</div> |
| 24 | {{end}} |
| 25 | </div> |
| 26 | <script> |
| 27 | document.querySelectorAll(".copy-btn").forEach(function (btn) { |
| 28 | btn.addEventListener("click", async function () { |
| 29 | try { |
| 30 | var res = await fetch(btn.dataset.raw); |
| 31 | var text = await res.text(); |
| 32 | await navigator.clipboard.writeText(text); |
| 33 | var prev = btn.textContent; |
| 34 | btn.textContent = "copied"; |
| 35 | setTimeout(function () { btn.textContent = prev; }, 1500); |
| 36 | } catch (e) { |
| 37 | btn.textContent = "failed"; |
| 38 | } |
| 39 | }); |
| 40 | }); |
| 41 | </script> |
| 42 | {{end}} |