BlueGit

timfa bluegit

Files

bluegit / internal / server / templates / commit.html

commit.html

feat: toon een commit zoals GitLab
timfa project_87923614_bot_3aff574f6f98414b945a8799374f9092 · pushed by timfa · 3 weeks ago
dc9d9b26 History
commit.html 4.9 KiB Download Raw
1{{define "commit"}}
2{{template "layout-start" .}}
3<article class="commitpage">
4<header class="commithead"><h1>{{.Commit.Subject}}</h1></header>
5{{if .Commit.Body}}<pre class="commitmsg">{{.Commit.Body}}</pre>{{end}}
6<section class="card commitmeta">
7 <div class="projhead">
8 {{template "avatar" .Commit}}
9 <div>
10 <p>{{template "commitwho" .Commit}}</p>
11 <p class="muted">{{t "commit.authored"}} {{.Commit.Date}}{{if .Commit.When}} · {{.Commit.When}}{{end}}</p>
12 </div>
13 </div>
14 <dl class="commitfacts">
15 <div>
16 <dt>{{t "commit.sha"}}</dt>
17 <dd><code class="sha">{{.Commit.SHA}}</code> <button type="button" class="iconbtn" data-copy="{{.Commit.SHA}}" aria-label="{{t "action.copy"}}">{{t "action.copy"}}</button></dd>
18 </div>
19 {{if .CommitDiff.Parents}}
20 <div>
21 <dt>{{if eq (len .CommitDiff.Parents) 1}}{{t "commit.parent"}}{{else}}{{t "commit.parents"}}{{end}}</dt>
22 <dd class="parents">{{range .CommitDiff.Parents}}<a href="/{{$.Repo.FullPath}}/-/commit/{{.SHA}}"><code>{{.Short}}</code></a>{{end}}</dd>
23 </div>
24 {{end}}
25 {{if .Commit.PipeStatus}}
26 <div>
27 <dt>{{t "pipe.one"}}</dt>
28 <dd><a class="status {{.Commit.PipeStatus}}" href="/{{$.Repo.FullPath}}/-/pipelines/{{.Commit.PipeID}}"><span class="mark"></span>{{.Commit.PipeLabel}}</a></dd>
29 </div>
30 {{end}}
31 </dl>
32</section>
33{{if not .CommitDiff.Files}}
34<p class="muted">{{t "commit.empty"}}</p>
35{{else}}
36<div class="commitdiff" id="commitdiff" data-commit-diff data-mode="inline">
37<script src="/assets/commit-mode.js"></script>
38<div class="commitbar diffbar">
39 <div class="grow">
40 <strong>{{tn .CommitDiff.FilesN "commit.file.one" "commit.file.many"}}</strong>
41 <span class="addstat">+{{.CommitDiff.Added}}</span>
42 <span class="delstat">−{{.CommitDiff.Deleted}}</span>
43 </div>
44 <div class="diffswitch" role="group" aria-label="{{t "commit.view"}}">
45 <button type="button" data-diff-mode="inline" aria-pressed="true">{{t "commit.inline"}}</button>
46 <button type="button" data-diff-mode="side" aria-pressed="false">{{t "commit.side"}}</button>
47 </div>
48</div>
49<div class="commitlayout">
50 <nav class="commitfiles" aria-label="{{t "commit.changed"}}">
51 <h2>{{t "commit.changed"}}</h2>
52 <ul>
53 {{range .CommitDiff.Tree}}
54 <li class="d{{.Depth}}">
55 {{if .Dir}}{{template "ficon" .Icon}}<span>{{.Name}}</span>{{else}}<a href="#{{.Anchor}}" data-diff-link="{{.Anchor}}">{{template "ficon" .Icon}}<span class="name">{{.Name}}</span></a> <span class="addstat">+{{.Added}}</span><span class="delstat">−{{.Deleted}}</span>{{end}}
56 </li>
57 {{end}}
58 </ul>
59 </nav>
60 <div class="commitdiffs">
61 {{range .CommitDiff.Files}}
62 <section class="commitfile" id="{{.Anchor}}" data-path="{{.Path}}" data-collapsed="{{if .Collapsed}}1{{else}}0{{end}}">
63 <header>
64 {{if .HasBody}}<button type="button" class="ghost" data-toggle-diff data-show="{{t "commit.show"}}" data-hide="{{t "commit.hide"}}" aria-expanded="{{if .Collapsed}}false{{else}}true{{end}}">{{if .Collapsed}}{{t "commit.show"}}{{else}}{{t "commit.hide"}}{{end}}</button>{{end}}
65 <span class="path">{{if .OldPath}}<span class="oldpath">{{.OldPath}}</span> <span aria-hidden="true">→</span> {{end}}{{if .FileURL}}<a href="{{.FileURL}}">{{.Path}}</a>{{else}}{{.Path}}{{end}}</span>
66 {{if eq .Status "added"}}<span class="pill">{{t "commit.added"}}</span>{{else if eq .Status "deleted"}}<span class="pill">{{t "commit.deleted"}}</span>{{else if eq .Status "renamed"}}<span class="pill">{{t "commit.renamed"}}</span>{{end}}
67 {{if .Binary}}<span class="pill">{{t "commit.binary"}}</span>{{end}}
68 <span class="counts"><span class="addstat">+{{.Added}}</span> <span class="delstat">−{{.Deleted}}</span></span>
69 </header>
70 {{if .HasBody}}
71 <div class="diffbody">
72 {{if .Binary}}<p class="muted binaryhint">{{t "commit.binaryHint"}}</p>{{else}}
73 <div class="unified">
74 {{range .Lines}}
75 <div class="commitline kind-{{.Kind}}">
76 <span class="ln">{{if .Old}}{{.Old}}{{end}}</span>
77 <span class="ln">{{if .New}}{{.New}}{{end}}</span>
78 <code>{{.HTML}}</code>
79 </div>
80 {{end}}
81 </div>
82 <div class="split">
83 {{range .Pairs}}
84 {{if .Hunk}}<div class="commitline kind-hunk"><code>{{.Hunk}}</code></div>{{else}}
85 <div class="pair">
86 <div class="half kind-{{if .LKind}}{{.LKind}}{{else}}empty{{end}}"><span class="ln">{{if .LNo}}{{.LNo}}{{end}}</span><code>{{.LHTML}}</code></div>
87 <div class="half kind-{{if .RKind}}{{.RKind}}{{else}}empty{{end}}"><span class="ln">{{if .RNo}}{{.RNo}}{{end}}</span><code>{{.RHTML}}</code></div>
88 </div>
89 {{end}}
90 {{end}}
91 </div>
92 {{end}}
93 </div>
94 {{end}}
95 </section>
96 {{end}}
97 </div>
98</div>
99</div>
100<script src="/assets/commit.js"></script>
101{{end}}
102</article>
103<script src="/assets/repo.js"></script>
104{{template "layout-end" .}}
105{{end}}