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

templates/views/commit.html

main · 2.1 KB · 53 lines raw

1 {{ define "commit.html" }}{{ template "base" . }}{{ end }}
2 {{ define "styles" }}
3 <link rel="stylesheet" href="{{ static "css/diff.css" }}">
4 <link rel="stylesheet" href="{{ static "css/readme.css" }}">
5 {{ end }}
6 {{ define "main" }}
7 {{ $slug := print "/" .Info.Slug }}
8 {{ $c := mod "commit" }}
9 {{ $d := mod "diff" }}
10
11 <header class="hero">
12 <div class="hero-inner">
13 <h1 class="page-title">{{ $c.Subject }}</h1>
14 <p class="page-subtitle">
15 <code style="color:var(--accent);">{{ trunc 12 $c.SHA }}</code>
16 <span class="text-muted">&middot; {{ $c.Author }} &middot; <time datetime="{{ rfc3339 $c.When }}">{{ date $c.When }}</time></span>
17 </p>
18 </div>
19 </header>
20
21 {{ with $c.Body }}
22 <div class="readme"><pre style="white-space:pre-wrap;margin:0;">{{ . }}</pre></div>
23 {{ end }}
24
25 <div class="chips" style="margin-bottom:1rem;">
26 {{ with $c.Parents }}
27 {{ $multi := gt (len $c.Parents) 1 }}
28 {{ range . }}
29 <a class="chip" href="{{ $slug }}/commit/{{ . }}">parent {{ trunc 12 . }}</a>
30 {{/* For a merge commit, each parent gives a genuinely different diff.
31 For an ordinary single-parent commit it's the same diff already
32 rendered below, so skip the redundant chip there. */}}
33 {{ if $multi }}<a class="chip" href="{{ $slug }}/compare/{{ . }}..{{ $c.SHA }}">diff vs {{ trunc 8 . }}</a>{{ end }}
34 {{ end }}
35 {{ end }}
36 <a class="chip" href="{{ $slug }}/tree/{{ $c.SHA }}">view tree</a>
37 </div>
38
39 <form class="compare-form" style="margin-bottom:1rem;"
40 onsubmit="var v=this.rev.value.trim(); if(v) location.href='{{ $slug }}/compare/'+encodeURIComponent(v)+'..{{ $c.SHA }}'; return false;">
41 <input type="text" name="rev" class="compare-input" placeholder="compare against a branch, tag, or commit&hellip;" required>
42 <button type="submit" class="chip">Compare</button>
43 </form>
44
45 <article class="card">
46 <header class="page-head">
47 <h2 class="page-subtitle">Changed files</h2>
48 </header>
49 {{ template "diffstat" (dict "Base" $slug "Ref" $c.SHA "Diff" $d) }}
50 </article>
51
52 {{ with $d.Patch }}<div class="diff">{{ patch . }}</div>{{ end }}
53 {{ end }}