Migration This is my new public git source viewer. Source coming soon. Please contact with concerns/bugs. Contact me

templates/layouts/partials.html

d658fcc4ea9f3bb562fd00dce8f863934560c56c · 2.8 KB · 76 lines raw

1 {{/* {{ template "tree-table" (dict "Base" "/slug" "Ref" ref "Entries" entries) }} */}}
2 {{ define "tree-table" }}
3 <div class="table-wrap">
4 <table class="table">
5 <thead>
6 <tr><th>Name</th><th>Type</th><th class="text-right">Size</th></tr>
7 </thead>
8 <tbody>
9 {{ $ := . }}{{ range .Entries }}
10 <tr>
11 <td>
12 {{ if .IsDir }}<a href="{{ $.Base }}/tree/{{ $.Ref }}/{{ .Path }}">{{ .Name }}</a>
13 {{ else }}<a href="{{ $.Base }}/blob/{{ $.Ref }}/{{ .Path }}">{{ .Name }}</a>{{ end }}
14 </td>
15 <td class="text-sm">{{ if .IsDir }}<span class="chip chip-branch">dir</span>{{ else if .IsSubmodule }}<span class="chip chip-tag">submodule</span>{{ else }}<span class="chip chip-tag">file</span>{{ end }}</td>
16 <td class="text-right text-sm text-muted">{{ if .IsDir }}&mdash;{{ else }}{{ bytes .Size }}{{ end }}</td>
17 </tr>
18 {{ else }}
19 <tr><td class="text-center text-muted" colspan="3">This directory is empty.</td></tr>
20 {{ end }}
21 </tbody>
22 </table>
23 </div>
24 {{ end }}
25
26 {{/* {{ template "commit-table" (dict "Base" "/slug" "Commits" commits) }} */}}
27 {{ define "commit-table" }}
28 <div class="table-wrap">
29 <table class="table">
30 <thead>
31 <tr><th>Hash</th><th>Subject</th><th>Author</th><th class="text-right">Date</th></tr>
32 </thead>
33 <tbody>
34 {{ $ := . }}{{ range .Commits }}
35 <tr>
36 <td class="font-mono text-sm"><a href="{{ $.Base }}/commit/{{ .SHA }}">{{ .Short }}</a></td>
37 <td><a href="{{ $.Base }}/commit/{{ .SHA }}">{{ trunc 78 .Subject }}</a></td>
38 <td class="text-sm">{{ .Author }}</td>
39 <td class="text-right text-sm text-muted"><time datetime="{{ rfc3339 .When }}">{{ date .When }}</time></td>
40 </tr>
41 {{ else }}
42 <tr><td class="text-center text-muted" colspan="4">No commits on this ref yet.</td></tr>
43 {{ end }}
44 </tbody>
45 </table>
46 </div>
47 {{ end }}
48
49 {{/* {{ template "diffstat" (dict "Base" "/slug" "Ref" sha "Diff" d) }} */}}
50 {{ define "diffstat" }}
51 {{ $ := . }}
52 {{ with .Diff.Stats }}
53 <div class="table-wrap">
54 <table class="table">
55 <thead>
56 <tr><th>File</th><th>Changes</th><th></th></tr>
57 </thead>
58 <tbody>
59 {{ range . }}
60 <tr>
61 <td><a href="{{ $.Base }}/blob/{{ $.Ref }}/{{ .Path }}">{{ .Path }}</a></td>
62 <td class="text-sm">
63 {{ if eq .Status "B" }}<span class="text-muted">binary</span>
64 {{ else }}<span style="color:var(--add);">+{{ .Added }}</span> <span style="color:var(--del);">&minus;{{ .Deleted }}</span>{{ end }}
65 </td>
66 <td class="text-right"><a class="chip" href="{{ $.Base }}/raw/{{ $.Ref }}/{{ .Path }}">raw</a></td>
67 </tr>
68 {{ end }}
69 </tbody>
70 </table>
71 </div>
72 {{ else }}
73 <p class="text-muted">No files changed.</p>
74 {{ end }}
75 {{ if .Diff.Truncated }}<div class="notice">This diff exceeds the size limit and is shown in part. Fetch the file with <code>raw</code> to see all of it.</div>{{ end }}
76 {{ end }}