Migration
This is my new public git source viewer. Source coming soon. Please contact with concerns/bugs.
Contact me
templates/views/tree.html
83aa601b98007ead72afeadb131a93d5694e04ca
· 3.2 KB · 90 lines
raw
| 1 | {{ define "tree.html" }}{{ template "base" . }}{{ end }} |
| 2 | {{ define "styles" }} |
| 3 | <link rel="stylesheet" href="/static/css/repo.css"> |
| 4 | <link rel="stylesheet" href="/static/css/readme.css"> |
| 5 | {{ end }} |
| 6 | {{ define "main" }} |
| 7 | {{ $slug := print "/" .Info.Slug }} |
| 8 | {{ $root := eq .Path "" }} |
| 9 | |
| 10 | {{ if $root }} |
| 11 | {{ $m := mod "meta" }} |
| 12 | <header class="hero"> |
| 13 | <div class="hero-inner"> |
| 14 | <h1 class="page-title">{{ $m.Title }}</h1> |
| 15 | {{ with $m.Description }}<p class="page-subtitle">{{ . }}</p>{{ end }} |
| 16 | </div> |
| 17 | </header> |
| 18 | |
| 19 | <div class="facts-bar"> |
| 20 | <div class="fact"> |
| 21 | <span class="fact-label">default branch</span> |
| 22 | <span class="fact-value"><a href="{{ $slug }}/tree/{{ $m.DefaultRef }}">{{ $m.DefaultRef }}</a></span> |
| 23 | </div> |
| 24 | <div class="fact"> |
| 25 | <span class="fact-label">updated</span> |
| 26 | <span class="fact-value">{{ with $m.LastCommit }}<time datetime="{{ rfc3339 . }}">{{ date . }}</time>{{ else }}<span class="muted">never</span>{{ end }}</span> |
| 27 | </div> |
| 28 | {{ with $m.Section }}<div class="fact"> |
| 29 | <span class="fact-label">section</span> |
| 30 | <span class="fact-value"><a href="/#{{ slug . }}">{{ . }}</a></span> |
| 31 | </div>{{ end }} |
| 32 | {{ with $m.Clone }}<div class="fact"> |
| 33 | <span class="fact-label">clone</span> |
| 34 | <span class="fact-value"><code>{{ . }}</code></span> |
| 35 | </div>{{ end }} |
| 36 | {{ with $m.Owner }}<div class="fact"> |
| 37 | <span class="fact-label">owner</span> |
| 38 | <span class="fact-value">{{ . }}</span> |
| 39 | </div>{{ end }} |
| 40 | </div> |
| 41 | |
| 42 | {{/* `with` on .Commits, not index 0 -- an empty repo has no commits and |
| 43 | indexing would abort the render. */}} |
| 44 | {{ with (mod "log" "1").Commits }}{{ with index . 0 }} |
| 45 | <a class="latest-commit" href="{{ $slug }}/commit/{{ .SHA }}"> |
| 46 | <span class="commit-hash">{{ .Short }}</span> |
| 47 | <span class="commit-msg">{{ trunc 88 .Subject }}</span> |
| 48 | <span class="commit-meta">{{ .Author }} · <time datetime="{{ rfc3339 .When }}">{{ date .When }}</time></span> |
| 49 | </a> |
| 50 | {{ end }}{{ end }} |
| 51 | {{ end }} |
| 52 | |
| 53 | {{/* An empty repo (unborn HEAD) has no commit to list a tree at -- mod |
| 54 | "tree" would 404 on it, where this page used to render fine. Only call |
| 55 | it once there's a real commit to resolve against. */}} |
| 56 | {{ if .Commit }} |
| 57 | {{ $tree := mod "tree" }} |
| 58 | {{ if $root }} |
| 59 | <p class="text-muted"> |
| 60 | <code style="color:var(--accent);">{{ .Ref }}</code> |
| 61 | · {{ len $tree.Entries }} entries |
| 62 | </p> |
| 63 | {{ else }} |
| 64 | <header class="hero"> |
| 65 | <div class="hero-inner"> |
| 66 | <h1 class="page-title">Files</h1> |
| 67 | <p class="page-subtitle"> |
| 68 | <code style="color:var(--accent);">{{ .Ref }}</code> |
| 69 | <span class="text-muted">· {{ len $tree.Entries }} entries{{ with $tree.Path }} in <code>{{ . }}</code>{{ end }}</span> |
| 70 | </p> |
| 71 | </div> |
| 72 | </header> |
| 73 | {{ end }} |
| 74 | |
| 75 | {{ template "tree-table" (dict "Base" $slug "Ref" .Ref "Entries" $tree.Entries) }} |
| 76 | {{ end }} |
| 77 | |
| 78 | {{ if $root }} |
| 79 | {{ with modOr "readme" }} |
| 80 | <div class="readme">{{ .HTML }}</div> |
| 81 | {{ end }} |
| 82 | {{ end }} |
| 83 | |
| 84 | {{/* Everything else moved to its own page. Modules are lazy, so the ones |
| 85 | this view no longer calls cost nothing -- to put authors back, this is |
| 86 | the entire change: |
| 87 | {{ with mod "authors" }} |
| 88 | <ul class="chips">{{ range . }}<li class="chip">{{ .Name }} <b>{{ .Commits }}</b></li>{{ end }}</ul> |
| 89 | {{ end }} */}} |
| 90 | {{ end }} |