131 lines
4.2 kB
1
{{ define "title" }} commit {{ .Diff.Commit.This }} {{ end }}
2
3
{{ define "repoContent" }}
4
5
{{ $repo := .RepoInfo.FullName }}
6
{{ $commit := .Diff.Commit }}
7
{{ $stat := .Diff.Stat }}
8
{{ $diff := .Diff.Diff }}
9
10
<section class="commit">
11
<div id="commit-message">
12
{{ $messageParts := splitN $commit.Message "\n\n" 2 }}
13
<div>
14
{{ index $messageParts 0 }}
15
{{ if gt (len $messageParts) 1 }}
16
<p class="mt-1 cursor-text pb-2">{{ nl2br (unwrapText (index $messageParts 1)) }}</p>
17
{{ end }}
18
</div>
19
</div>
20
21
<p class="text-sm text-gray-500">
22
<a href="mailto:{{ $commit.Author.Email }}" class="no-underline hover:underline text-gray-500">
23
{{ $commit.Author.Name }}
24
</a>
25
·
26
{{ timeFmt $commit.Author.When }}
27
·
28
<span class="font-mono">{{ $stat.FilesChanged }}</span> files <span class="font-mono">(+{{ $stat.Insertions }}, -{{ $stat.Deletions }})</span>
29
·
30
<a href="/{{ $repo }}/commit/{{ $commit.This }}" class="no-underline hover:underline text-gray-500">
31
{{ slice $commit.This 0 8 }}
32
</a>
33
{{ if $commit.Parent }}
34
<--
35
<a href="/{{ $repo }}/commit/{{ $commit.Parent }}" class="no-underline hover:underline text-gray-500">
36
{{ slice $commit.Parent 0 8 }}
37
</a>
38
{{ end }}
39
</p>
40
41
<div class="diff-stat">
42
<br>
43
<strong>jump to</strong>
44
{{ range $diff }}
45
<ul>
46
<li><a href="#file-{{ .Name.New }}">{{ .Name.New }}</a></li>
47
</ul>
48
{{ end }}
49
</div>
50
</section>
51
52
{{end}}
53
54
{{ define "repoAfter" }}
55
56
{{ $repo := .RepoInfo.FullName }}
57
{{ $commit := .Diff.Commit }}
58
{{ $stat := .Diff.Stat }}
59
{{ $diff := .Diff.Diff }}
60
61
{{ $this := $commit.This }}
62
{{ $parent := $commit.Parent }}
63
64
{{ range $diff }}
65
<section class="mt-4 border border-black w-full mx-auto">
66
<div id="file-{{ .Name.New }}">
67
<div id="diff-file">
68
<details open>
69
<summary class="list-none cursor-pointer sticky top-0">
70
<div id="diff-file-header" class="border-b cursor-pointer bg-white border-black flex justify-between">
71
<div id="left-side-items" class="p-2">
72
{{ if .IsNew }}
73
<span class="diff-type">A</span>
74
{{ end }}
75
{{ if .IsDelete }}
76
<span class="diff-type">D</span>
77
{{ end }}
78
{{ if not (or .IsNew .IsDelete) }}
79
<span class="diff-type">M</span>
80
{{ end }}
81
82
{{ if .Name.Old }}
83
<a href="/{{ $repo }}/blob/{{ $parent }}/{{ .Name.Old }}" class="no-underline hover:underline">{{ .Name.Old }}</a>
84
{{ if .Name.New }}
85
→
86
<a href="/{{ $repo }}/blob/{{ $this }}/{{ .Name.New }}" class="no-underline hover:underline">{{ .Name.New }}</a>
87
{{ end }}
88
{{ else }}
89
<a href="/{{ $repo }}/blob/{{ $this }}/{{ .Name.New }}" class="no-underline hover:underline">{{ .Name.New }}</a>
90
{{- end -}}
91
</div>
92
93
<div id="right-side-items" class="p-2">
94
<a href="#file-{{ .Name.New }}" class="no-underline hover:underline">to top of file</a>
95
</div>
96
97
</div>
98
</summary>
99
100
{{ if .IsBinary }}
101
<p>Not showing binary file.</p>
102
{{ else }}
103
<pre class="overflow-auto">
104
{{- range .TextFragments -}}
105
<div class="bg-gray-100 text-gray-500">{{ .Header }}</div>
106
{{- range .Lines -}}
107
{{- if eq .Op.String "+" -}}
108
<div class="bg-green-100 text-green-700">{{ .String }}</div>
109
{{- end -}}
110
111
{{- if eq .Op.String "-" -}}
112
<div class="bg-red-100 text-red-700">{{ .String }}</div>
113
{{- end -}}
114
115
{{- if eq .Op.String " " -}}
116
<div class="text-gray-500">{{ .String }}</div>
117
{{- end -}}
118
119
{{- end -}}
120
{{- end -}}
121
</pre>
122
{{- end -}}
123
124
</details>
125
126
</div>
127
</div>
128
</section>
129
{{ end }}
130
131
{{end}}
132