git-preview @ main

static git web frontend but with images and html previews + code truncation

templates/commit.html

 1{{ define "commit" }}
 2<html>
 3{{ template "head" . }}
 4
 5  {{ template "repoheader" . }}
 6  <body>
 7    {{ template "nav" . }}
 8    <main>
 9      <section class="commit">
10        <pre>
11          {{- .commit.Message -}}
12        </pre>
13        <div class="commit-info">
14          <div>{{ .commit.Author.When.Format "Mon, 02 Jan 2006" }}</div>
15        </div>
16
17        <div class="diff-stat">
18          <div>
19          {{ .stat.FilesChanged }} files changed,
20          {{ .stat.Insertions }} insertions(+),
21          {{ .stat.Deletions }} deletions(-)
22          </div>
23        </div>
24      </section>
25      {{ template "showcase" . }}
26      <section>
27        {{ range .diff }}
28          <div>
29            <div class="diff">
30            {{ if .IsNew }}
31            <span class="diff-type">A</span>
32            {{ end }}
33            {{ if .IsDelete }}
34            <span class="diff-type">D</span>
35            {{ end }}
36            {{ if not (or .IsNew .IsDelete) }}
37            <span class="diff-type">M</span>
38            {{ end }}
39            {{ .Name }}
40          {{ if .IsBinary }}
41          <p>Not showing binary file.</p>
42          {{ else }}
43            <pre>
44            {{- range .Fragments -}}
45            <p>{{- .Header -}}</p>
46            {{- range .Lines -}}
47              {{- if eq .Op.String "+" -}}
48              <span class="diff-add">{{ .String }}</span>
49              {{- end -}}
50              {{- if eq .Op.String "-" -}}
51              <span class="diff-del">{{ .String }}</span>
52              {{- end -}}
53              {{- if eq .Op.String " " -}}
54              <span class="diff-noop">{{ .String }}</span>
55              {{- end -}}
56            {{- end -}}
57            {{- end -}}
58          {{- end -}}
59            </pre>
60            {{ if .Truncated }}
61            <p class="diff-truncated">&hellip; preview truncated</p>
62            {{ end }}
63          </div>
64          </div>
65        {{ end }}
66        {{ if .hiddenfiles }}
67        <p class="diff-truncated">&hellip; and {{ .hiddenfiles }} more changed files not shown in this preview</p>
68        {{ end }}
69      </section>
70    </main>
71  </body>
72</html>
73{{ end }}