1<!DOCTYPE html>
  2<html>
  3	<head>
  4		<title>Commit {{printf "%.7s" .Commit.Hash}} - {{.Repo.Name}}</title>
  5		<link rel="stylesheet" href="/static/style.css">
  6		<link rel="shortcut icon" href="/static/favicon.png">
  7	</head>
  8	<body>
  9		{{template "nav-main.html" .}}
 10
 11		<main>
 12			{{template "nav-repository.html" .}}
 13	
 14			<div>
 15				{{$lines := split .Commit.Message "\n"}}
 16				<h3 class="margin-none padding-none">{{index $lines 0}}</h3>
 17				{{$hasBody := false}}{{range $i, $line := $lines}}{{if and (gt $i 0) (ne $line "")}}{{$hasBody = true}}{{end}}{{end}}
 18				{{if $hasBody}}
 19				<p>
 20				{{range $i, $line := $lines}}{{if and (gt $i 0) (ne $line "")}}
 21					{{$line}}<br>
 22				{{end}}{{end}}
 23				</p>
 24				{{end}}
 25			</div>
 26
 27			<table class="commit-info">
 28				<tr>
 29					<td>Author</td>
 30					<td>{{.Commit.AuthorName}} &lt;{{.Commit.AuthorEmail}}&gt;</td>
 31					<td>{{.Commit.AuthorDate.Format "2006-01-02 15:04:05 -0700"}}</td>
 32				</tr>
 33				<tr>
 34					<td>Committer</td>
 35					<td>{{.Commit.CommitterName}} &lt;{{.Commit.CommitterEmail}}&gt;</td>
 36					<td>{{.Commit.CommitterDate.Format "2006-01-02 15:04:05 -0700"}}</td>
 37				</tr>
 38				<tr>
 39					<td>Commit</td>
 40					<td colspan="2"><code>{{.Commit.Hash}}</code> (<a href="/r/{{$.Repo.Name}}/c/{{.Commit.Hash}}/patch">patch</a>)</td>
 41				</tr>
 42			</table>
 43
 44			<div class="diffstat">
 45				<table class="diffstat-table">
 46					{{range .FileDiffs}}
 47					<tr>
 48						<td width="100" class=""><code>{{.Mode}}</code></td>
 49						<td>
 50							{{if .Deleted}}
 51							<a href="#diff-{{.Name}}">{{.Name}}</a>
 52							{{else}}
 53							<a href="/r/{{$.Repo.Name}}/blob/{{.Name}}?ref={{$.Commit.Hash}}">{{.Name}}</a>
 54							{{end}}
 55						</td>
 56						<td>
 57							{{if .IsBinary}} bin {{humanize .OldSize}} -> {{humanize .NewSize}} {{else}} {{add .Addition .Deletion}} {{end}}
 58						</td>
 59						<td class="bar">
 60							<a href="#diff-{{.Name}}" style="text-decoration: none;">
 61								{{if not .IsBinary}}
 62								<svg width="200" height="12">
 63									{{$total := add .Addition .Deletion}}
 64									{{if gt $total 0}}
 65									{{$max := $.MaxChanges}}
 66									{{if eq $max 0}}{{$max = 1}}{{end}}
 67									{{$scaledTotal := multiply (divide (float64 $total) (float64 $max)) 200.0}}
 68									{{$addWidth := multiply (divide (float64 .Addition) (float64 $total)) $scaledTotal}}
 69									{{$delWidth := multiply (divide (float64 .Deletion) (float64 $total)) $scaledTotal}}
 70									<rect x="0" y="0" width="{{$addWidth}}" height="12" fill="#2cbe4e" />
 71									<rect x="{{$addWidth}}" y="0" width="{{$delWidth}}" height="12" fill="#cb2431" />
 72									{{end}}
 73								</svg>
 74								{{end}}
 75							</a>
 76						</td>
 77					</tr>
 78					{{end}}
 79				</table>
 80				<div class="summary">
 81					{{len .FileDiffs}} files changed, {{.Commit.Additions}} insertions, {{.Commit.Deletions}} deletions
 82				</div>
 83			</div>
 84
 85			<div class="file-diffs">
 86				{{if .Commit.TooLarge}}
 87				<p class="text-center padding-none margin-none"><b>Commit too large to display</b></p>
 88				{{else}}
 89				{{range .FileDiffs}}
 90				<table class="diff-table">
 91					<tr class="diff-fname">
 92						<td colspan="4">
 93							diff --git a/{{.Name}} b/{{.Name}}
 94						</td>
 95					</tr>
 96					<colgroup>
 97						<col style="width: 30px;">
 98						<col style="width: calc(50% - 30px);">
 99						<col style="width: 30px;">
100						<col style="width: calc(50% - 30px);">
101					</colgroup>
102					{{if .TooLarge}}
103					<tr class="diff-gap">
104						<td colspan="4" class="text-center"><b>Changes too big to display</b></td>
105					</tr>
106					{{else}}
107					{{range .Lines}}
108					{{if eq .Type "gap"}}
109					<tr class="diff-gap">
110						<td colspan="4" class="text-center"><small>...</small></td>
111					</tr>
112					{{else}}
113					<tr class="diff-{{.Type}}">
114						<td class="ln">{{.LeftNo}}</td>
115						<td class="code"><pre>{{if .Left}}{{.Left}}{{else}} &nbsp;{{end}}</pre></td>
116						<td class="ln">{{.RightNo}}</td>
117						<td class="code"><pre>{{if .Right}}{{.Right}}{{else}} &nbsp;{{end}}</pre></td>
118					</tr>
119					{{end}}
120					{{end}}
121					{{end}}
122				</table>
123				{{else}}
124				<p>No changes in this commit.</p>
125				{{end}}
126				{{end}}
127			</div>
128		</main>
129
130		{{template "footer.html" .}}
131	</body>
132</html>