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

templates/views/blob.html

main · 3.3 KB · 69 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 {{ if $b.Image }}<a class="chip" style="margin-left:.5rem;" href="{{ $slug }}/raw/{{ .Ref }}/{{ $b.Path }}" download>download</a>{{ end }}
16 {{ end }}
17 </p>
18 </div>
19 </header>
20
21 {{ if $b.Submodule }}
22 <div class="notice">
23 This is a submodule, pinned at
24 <code>{{ if $b.Submodule.Remote }}{{ $b.Submodule.Remote }}:{{ end }}{{ $b.Submodule.SHA }}</code>.
25 </div>
26 {{ else if $b.Preview }}
27 <figure class="blob-image">
28 <img src="{{ $slug }}/raw/{{ .Ref }}/{{ $b.Path }}" alt="{{ $b.Path }}">
29 </figure>
30 {{ else if $b.Image }}
31 <div class="notice">
32 This image is {{ bytes64 $b.Size }}, over the {{ bytes64 $b.PreviewLimit }} preview limit.
33 <a href="{{ $slug }}/raw/{{ .Ref }}/{{ $b.Path }}" download>Download it</a> to view it locally.
34 </div>
35 {{ else if $b.Binary }}
36 <div class="notice">This is a binary file. Fetch it with <a href="{{ $slug }}/raw/{{ .Ref }}/{{ $b.Path }}">raw</a>.</div>
37 {{ else }}
38 {{ if $b.Oversize }}
39 <div class="notice">
40 This {{ if eq $b.Lang "json" }}JSON{{ else }}YAML{{ end }} file is {{ bytes64 $b.Size }},
41 over the {{ bytes64 $b.StructuredLimit }} limit for parsing. It is shown as plain numbered lines.
42 <a href="{{ $slug }}/raw/{{ .Ref }}/{{ $b.Path }}">Fetch the raw file</a> to work with it locally.
43 </div>
44 {{ end }}
45 {{ if $b.ParseErr }}
46 <div class="notice notice-warn">
47 Invalid {{ if eq $b.Lang "json" }}JSON{{ else }}YAML{{ end }}
48 {{ if $b.ParseErr.Line }}&mdash; <a href="#L{{ $b.ParseErr.Line }}">line {{ $b.ParseErr.Line }}</a>{{ end }}:
49 <code>{{ $b.ParseErr.Msg }}</code>
50 </div>
51 {{ end }}
52 <div class="source{{ if $b.Structured }} structured{{ end }}" data-lang="{{ $b.Lang }}">
53 <table><tbody>
54 {{ range $b.Lines }}
55 <tr id="L{{ .N }}" data-n="{{ .N }}"
56 {{- if .FoldTo }} data-fold-to="{{ .FoldTo }}"{{ end }}
57 {{- if .Depth }} data-depth="{{ .Depth }}"{{ end }}
58 {{- with .Key }} data-key="{{ . }}"{{ end }}
59 {{- with .Path }} data-path="{{ . }}"{{ end }}>
60 <td class="ln"><a href="#L{{ .N }}">{{ .N }}</a></td>
61 <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>
62 </tr>
63 {{ end }}
64 </tbody></table>
65 </div>
66 {{ end }}
67 {{ end }}
68
69 {{ define "scripts" }}{{ if (mod "blob").Structured }}<script src="{{ static "js/structured.js" }}" defer></script>{{ end }}{{ end }}