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

templates/views/blob.html

c0427d5fc7c0fcf8606c546071085e8af231fb81 · 2.7 KB · 58 lines raw

1 {{ define "blob.html" }}{{ template "base" . }}{{ end }}
2 {{ define "styles" }}<link rel="stylesheet" href="/static/css/blob.css">{{ end }}
3 {{ define "main" }}
4 {{ $slug := print "/" .Info.Slug }}
5 {{ $b := mod "blob" }}
6
7 <header class="hero">
8 <div class="hero-inner">
9 <h1 class="page-title">{{ $b.Path }}</h1>
10 <p class="page-subtitle">
11 <code style="color:var(--accent);">{{ .Ref }}</code>
12 {{ if not $b.Submodule }}
13 <span class="text-muted">&middot; {{ bytes64 $b.Size }}{{ if not $b.Binary }} &middot; {{ len $b.Lines }} lines{{ end }}</span>
14 <a class="chip" style="margin-left:.5rem;" href="{{ $slug }}/raw/{{ .Ref }}/{{ $b.Path }}">raw</a>
15 {{ end }}
16 </p>
17 </div>
18 </header>
19
20 {{ if $b.Submodule }}
21 <div class="notice">
22 This is a submodule, pinned at
23 <code>{{ if $b.Submodule.Remote }}{{ $b.Submodule.Remote }}:{{ end }}{{ $b.Submodule.SHA }}</code>.
24 </div>
25 {{ else if $b.Binary }}
26 <div class="notice">This is a binary file. Fetch it with <a href="{{ $slug }}/raw/{{ .Ref }}/{{ $b.Path }}">raw</a>.</div>
27 {{ else }}
28 {{ if $b.Oversize }}
29 <div class="notice">
30 This {{ if eq $b.Lang "json" }}JSON{{ else }}YAML{{ end }} file is {{ bytes64 $b.Size }},
31 over the {{ bytes64 $b.StructuredLimit }} limit for parsing. It is shown as plain numbered lines.
32 <a href="{{ $slug }}/raw/{{ .Ref }}/{{ $b.Path }}">Fetch the raw file</a> to work with it locally.
33 </div>
34 {{ end }}
35 {{ if $b.ParseErr }}
36 <div class="notice notice-warn">
37 Invalid {{ if eq $b.Lang "json" }}JSON{{ else }}YAML{{ end }}
38 {{ if $b.ParseErr.Line }}&mdash; <a href="#L{{ $b.ParseErr.Line }}">line {{ $b.ParseErr.Line }}</a>{{ end }}:
39 <code>{{ $b.ParseErr.Msg }}</code>
40 </div>
41 {{ end }}
42 <div class="source{{ if $b.Structured }} structured{{ end }}" data-lang="{{ $b.Lang }}">
43 <table><tbody>
44 {{ range $b.Lines }}
45 <tr id="L{{ .N }}" data-n="{{ .N }}"
46 {{- if .FoldTo }} data-fold-to="{{ .FoldTo }}"{{ end }}
47 {{- if .Depth }} data-depth="{{ .Depth }}"{{ end }}
48 {{- with .Key }} data-key="{{ . }}"{{ end }}>
49 <td class="ln"><a href="#L{{ .N }}">{{ .N }}</a></td>
50 <td class="lc">{{ .Text }}{{ with .Anchor }}{{ if .Uses }}<span class="anchor-uses">{{ .Uses }} use{{ if ne .Uses 1 }}s{{ end }}</span>{{ end }}{{ end }}{{ with .Ref }}<a class="aref" href="#L{{ .Line }}" title="&amp;{{ .Name }} &mdash; line {{ .Line }}{{ with .Preview }}&#10;&#10;{{ . }}{{ end }}">&rarr;&nbsp;{{ .Line }}</a>{{ end }}</td>
51 </tr>
52 {{ end }}
53 </tbody></table>
54 </div>
55 {{ end }}
56 {{ end }}
57
58 {{ define "scripts" }}{{ if (mod "blob").Structured }}<script src="/static/js/structured.js" defer></script>{{ end }}{{ end }}