upstream
1{{- /*gotype: github.com/antonmedv/gitmal/pkg/templates.CommitParams*/ -}}
2{{ define "head" }}
3 <style>
4 h1 code {
5 border-radius: var(--border-radius);
6 background: var(--c-bg-alt);
7 padding: 4px 8px;
8 font-family: var(--font-family-mono), monospace;
9 font-weight: 500;
10 }
11
12 .commit {
13 display: flex;
14 flex-direction: column;
15 gap: 16px;
16 margin-bottom: 16px;
17 }
18
19 .commit-info {
20 display: flex;
21 flex-direction: row;
22 gap: 8px;
23 align-items: flex-end;
24 }
25
26 .commit-author {
27 color: var(--c-text-1);
28 font-weight: 600;
29 min-width: 0;
30 overflow-wrap: break-word;
31 }
32
33 .commit-date {
34 color: var(--c-text-2);
35 font-size: 12px;
36 font-family: var(--font-family-mono), monospace;
37 }
38
39 .commit-message {
40 border: 1px solid var(--c-border);
41 border-radius: var(--border-radius);
42 padding: 16px;
43 }
44
45 .ref-badges {
46 display: inline-flex;
47 gap: 6px;
48 margin-left: 8px;
49 }
50
51 .badge {
52 font-size: 12px;
53 color: var(--c-text-2);
54 border: 1px solid var(--c-border);
55 padding: 2px 6px;
56 border-radius: 999px;
57 white-space: nowrap;
58 }
59
60 .commit-subject {
61 font-size: 16px;
62 font-weight: 600;
63 line-height: 1.3;
64 hyphens: auto;
65 }
66
67 .commit-body {
68 margin-top: 16px;
69 white-space: pre-wrap;
70 line-height: 1.5;
71 hyphens: auto;
72 }
73
74 .commit-subinfo {
75 display: flex;
76 flex-direction: row;
77 gap: 16px;
78 justify-content: space-between;
79 }
80
81 .commit-layout {
82 display: grid;
83 grid-template-columns: 1fr;
84 gap: 16px;
85 }
86
87 @media (min-width: 960px) {
88 .commit-layout {
89 grid-template-columns: 300px 1fr;
90 align-items: start;
91 }
92
93 .files-tree {
94 position: sticky;
95 top: 16px;
96 }
97
98 .files-tree-content {
99 max-height: calc(100vh - var(--header-height) - 40px);
100 overflow: auto;
101 }
102 }
103
104 .files-tree {
105 border: 1px solid var(--c-border);
106 border-radius: var(--border-radius);
107 }
108
109 .files-tree-header {
110 display: flex;
111 flex-direction: row;
112 align-items: center;
113 padding-inline: 16px;
114 height: var(--header-height);
115 border-bottom: 1px solid var(--c-border);
116 border-top-left-radius: var(--border-radius);
117 border-top-right-radius: var(--border-radius);
118 background: var(--c-bg-alt);
119 font-size: 14px;
120 font-weight: 600;
121 }
122
123 .files-tree-content {
124 display: block;
125 padding-block: 6px;
126 }
127
128 .tree .children {
129 margin-left: 16px;
130 border-left: 1px dashed var(--c-border);
131 }
132
133 .tree .node {
134 display: flex;
135 align-items: center;
136 gap: 8px;
137 padding: 10px 16px;
138 }
139
140 .tree .file-name {
141 flex: 1;
142 font-weight: 500;
143 color: var(--c-text-1);
144 cursor: pointer;
145 }
146
147 .tree .file-name:hover {
148 color: var(--c-brand-2);
149 text-decoration: underline;
150 }
151
152 .tree .dir {
153 color: var(--c-dir);
154 }
155
156 .tree .file-added {
157 color: var(--c-green);
158 }
159
160 .tree .file-deleted {
161 color: var(--c-red);
162 }
163
164 .tree .file-renamed {
165 color: var(--c-yellow);
166 }
167
168 /* Per-file sections */
169
170 .files {
171 min-width: 0;
172 }
173
174 .file-section + .file-section {
175 margin-top: 16px;
176 }
177
178 pre {
179 border: 1px solid var(--c-border);
180 border-top: none;
181 border-bottom-left-radius: var(--border-radius);
182 border-bottom-right-radius: var(--border-radius);
183 }
184
185 pre {
186 margin: 0;
187 padding: 8px 16px;
188 overflow-x: auto;
189 white-space: pre;
190 word-spacing: normal;
191 word-break: normal;
192 word-wrap: normal;
193 tab-size: 4;
194 font-family: var(--font-family-mono), monospace;
195 }
196
197 pre > code {
198 display: block;
199 padding: 0 16px;
200 width: fit-content;
201 min-width: 100%;
202 line-height: var(--code-line-height);
203 font-size: var(--code-font-size);
204 }
205
206 .binary-file {
207 padding: 8px 16px;
208 font-style: italic;
209 }
210
211 .border {
212 border: 1px solid var(--c-border);
213 border-top: none;
214 border-bottom-left-radius: 6px;
215 border-bottom-right-radius: 6px;
216 }
217
218 {{ .DiffCSS }}
219 </style>
220{{ end }}
221
222{{ define "body" }}
223 <h1>Commit <code>{{ .Commit.ShortHash }}</code></h1>
224
225 <div class="commit">
226 <div class="commit-info">
227 <div class="commit-author">{{ .Commit.Author }} <{{ .Commit.Email }}></div>
228 <div class="commit-date">{{ .Commit.Date | FormatDate }}</div>
229 </div>
230 <div class="commit-message">
231 <div class="commit-subject">
232 {{ .Commit.Subject }}
233 {{ if .Commit.RefNames }}
234 <span class="ref-badges">
235 {{ range .Commit.RefNames }}
236 {{ if or (eq .Kind "Branch") (eq .Kind "Tag") }}
237 <span class="badge">{{ if eq .Kind "Tag" }}tag: {{ end }}{{ .Name }}</span>
238 {{ end }}
239 {{ end }}
240 </span>
241 {{ end }}
242 </div>
243 {{ if .Commit.Body }}
244 <div class="commit-body">{{ .Commit.Body }}</div>
245 {{ end }}
246 </div>
247 <div class="commit-subinfo">
248 <div class="commit-branch">
249 {{ if .Commit.Branch }}
250 <a href="../commits/{{ .Commit.Branch.DirName }}/index.html" class="badge">{{ .Commit.Branch }}</a>
251 {{ end }}
252 </div>
253 {{ if .Commit.Parents }}
254 <div class="commit-parents">
255 {{ if eq (len .Commit.Parents) 1 }}
256 1 parent
257 {{ else }}
258 {{ .Commit.Parents | len }} parents
259 {{ end }}
260 {{ range $i, $p := .Commit.Parents }}
261 {{ if gt $i 0 }}, {{ end }}
262 <a href="{{ $p }}.html"><code>{{ $p | ShortHash }}</code></a>
263 {{ end }}
264 </div>
265 {{ end }}
266 </div>
267 </div>
268
269 <div class="commit-layout">
270 <div class="files-tree">
271 <div class="files-tree-header">Changed files ({{ len .FileViews }})</div>
272 <div class="files-tree-content">
273 {{ if .FileTree }}
274 <div class="tree">
275 {{ template "file_tree" (FileTreeParams .FileTree) }}
276 </div>
277 {{ else }}
278 <div style="color: var(--c-text-3)">(no files)</div>
279 {{ end }}
280 </div>
281 </div>
282
283 <div class="files">
284 {{ range .FileViews }}
285 <section id="{{ .Path }}" class="file-section">
286 <div class="header-container">
287 <header class="file-header">
288 {{ if .IsRename }}
289 <div class="path">{{ .OldName }} → {{ .NewName }}</div>
290 {{ else }}
291 <div class="path">{{ .Path }}</div>
292 {{ end }}
293 <button class="goto-top" onclick="window.scrollTo({top: 0, behavior: 'smooth'})">
294 <svg aria-hidden="true" focusable="false" width="16" height="16">
295 <use xlink:href="#arrow-top"></use>
296 </svg>
297 Top
298 </button>
299 </header>
300 </div>
301 {{ if .IsBinary }}
302 <div class="binary-file border">Binary file</div>
303 {{ else if (and .IsRename (not .HasChanges)) }}
304 <div class="binary-file border">File renamed without changes</div>
305 {{ else }}
306 <div class="file-diff">
307 {{ .HTML }}
308 </div>
309 {{ end }}
310 </section>
311 {{ end }}
312 </div>
313 </div>
314{{ end }}