| 1 | {{define "repo.html"}}{{template "base.html" .}}{{end}} |
| 2 | {{define "title"}}{{.Repo.Name}} — {{.SiteName}}{{end}} |
| 3 | {{define "tabs"}} |
| 4 | <a href="/{{.Repo.Name}}" class="tab active">home</a> |
| 5 | <a href="/{{.Repo.Name}}/log/{{.DefaultRef}}" class="tab">log</a> |
| 6 | <a href="/{{.Repo.Name}}/refs" class="tab">refs</a> |
| 7 | {{end}} |
| 8 | {{define "content"}} |
| 9 | {{if or .HasLatest .CloneHTTPSURL .CloneSSHURL}} |
| 10 | <div class="repo-head"> |
| 11 | {{if .HasLatest}} |
| 12 | <div class="last-commit"> |
| 13 | <span class="hash"><a href="/{{.Repo.Name}}/commit/{{.LatestCommit.SHA}}">{{.LatestCommit.ShortSHA}}</a></span> |
| 14 | <span class="subject">{{.LatestCommit.Subject}}</span> |
| 15 | <span class="author">{{.LatestCommit.Author}}</span> |
| 16 | <span class="date">{{timeAgo .LatestCommit.When}}</span> |
| 17 | </div> |
| 18 | {{end}} |
| 19 | {{if or .CloneHTTPSURL .CloneSSHURL}} |
| 20 | <div class="clone-dropdown"> |
| 21 | <button type="button" class="clone-toggle" aria-expanded="false">Clone</button> |
| 22 | <div class="clone-menu" hidden> |
| 23 | {{if .CloneHTTPSURL}} |
| 24 | <div class="clone-option"> |
| 25 | <span class="clone-label">HTTPS</span> |
| 26 | <code class="clone-url">{{.CloneHTTPSURL}}</code> |
| 27 | <button type="button" class="copy-btn clone-copy" data-clone="{{.CloneHTTPSURL}}">copy</button> |
| 28 | </div> |
| 29 | {{end}} |
| 30 | {{if .CloneSSHURL}} |
| 31 | <div class="clone-option"> |
| 32 | <span class="clone-label">SSH</span> |
| 33 | <code class="clone-url">{{.CloneSSHURL}}</code> |
| 34 | <button type="button" class="copy-btn clone-copy" data-clone="{{.CloneSSHURL}}">copy</button> |
| 35 | </div> |
| 36 | {{end}} |
| 37 | </div> |
| 38 | </div> |
| 39 | {{end}} |
| 40 | </div> |
| 41 | {{end}} |
| 42 | |
| 43 | <div class="repo-home"> |
| 44 | <aside class="file-tree"> |
| 45 | {{if .Entries}} |
| 46 | {{range .Entries}} |
| 47 | {{if .IsDir}} |
| 48 | <a class="tree-entry" href="/{{$.Repo.Name}}/tree/{{$.DefaultRef}}/{{.Path}}"> |
| 49 | <span class="name">{{.Name}}/</span> |
| 50 | </a> |
| 51 | {{else}} |
| 52 | <a class="tree-entry" href="/{{$.Repo.Name}}/blob/{{$.DefaultRef}}/{{.Path}}"> |
| 53 | <span class="name">{{.Name}}</span> |
| 54 | <span class="size">{{humanSize .Size}}</span> |
| 55 | </a> |
| 56 | {{end}} |
| 57 | {{end}} |
| 58 | {{else}} |
| 59 | <p class="empty">Empty repository.</p> |
| 60 | {{end}} |
| 61 | </aside> |
| 62 | |
| 63 | <section class="content-view"> |
| 64 | {{if .HasReadme}} |
| 65 | <article class="readme">{{.ReadmeHTML}}</article> |
| 66 | {{else}} |
| 67 | <p class="empty">No README.</p> |
| 68 | {{end}} |
| 69 | </section> |
| 70 | </div> |
| 71 | <script> |
| 72 | document.querySelectorAll(".clone-dropdown").forEach(function (dd) { |
| 73 | var toggle = dd.querySelector(".clone-toggle"); |
| 74 | var menu = dd.querySelector(".clone-menu"); |
| 75 | toggle.addEventListener("click", function (e) { |
| 76 | e.stopPropagation(); |
| 77 | var open = menu.hidden; |
| 78 | menu.hidden = !open; |
| 79 | toggle.setAttribute("aria-expanded", String(open)); |
| 80 | }); |
| 81 | document.addEventListener("click", function (e) { |
| 82 | if (!dd.contains(e.target)) { |
| 83 | menu.hidden = true; |
| 84 | toggle.setAttribute("aria-expanded", "false"); |
| 85 | } |
| 86 | }); |
| 87 | }); |
| 88 | document.querySelectorAll(".clone-copy").forEach(function (btn) { |
| 89 | btn.addEventListener("click", async function () { |
| 90 | try { |
| 91 | await navigator.clipboard.writeText(btn.dataset.clone); |
| 92 | var prev = btn.textContent; |
| 93 | btn.textContent = "copied"; |
| 94 | setTimeout(function () { btn.textContent = prev; }, 1500); |
| 95 | } catch (e) { |
| 96 | btn.textContent = "failed"; |
| 97 | } |
| 98 | }); |
| 99 | }); |
| 100 | </script> |
| 101 | {{end}} |