all repos

mugit @ dbbfe179a0155d3adc12fdd9c960ae907b7ab7fe

๐Ÿฎ git server that your cow will love

mugit/web/templates/repo_commit.html (view raw)

Oleksandr Smirnov Oleksandr Smirnov
olexsmir@gmail.com
ui: add spacing between git operation and the line contents, 2 months ago
1
{{ define "_diff_type" }}
2
{{ if .IsNew }}<span class="diff-type diff-add">A</span>
3
{{ else if .IsDelete }}<span class="diff-type diff-del">D</span>
4
{{ else }}<span class="diff-type diff-mod">M</span>{{ end }}
5
{{ end }}
6
7
{{ define "repo_commit" }}
8
{{ $commit := .P.Diff.Commit }}
9
{{ $diff := .P.Diff.Diff }}
10
{{ $stat := .P.Diff.Stat }}
11
{{ $parents := .P.Diff.Parents }}
12
<html>
13
  <head>
14
    {{ template "head" . }}
15
    <title>{{ .RepoName }}: {{ $commit.HashShort }}</title>
16
  </head>
17
  <body>
18
    {{ template "repo_header" . }}
19
    <main>
20
      <section class="commit">
21
        <div class="commit-refs">
22
          <span class="diff-mod">{{ $stat.FilesChanged }} files changed</span>,
23
          <span class="diff-add">{{ $stat.Insertions }} insertions(+)</span>,
24
          <span class="diff-del">{{ $stat.Deletions }} deletions(-)</span>
25
        </div>
26
27
        <div class="box">
28
          <pre class="commit-message">
29
            {{- if $commit.Message }}{{- $commit.Message -}}
30
            {{- else -}}<span class="muted">Empty message</span>{{- end -}}
31
          </pre>
32
          <div>
33
            <strong>Author:</strong>
34
            {{ $commit.AuthorName }}
35
            <a href="mailto:{{ $commit.AuthorEmail }}" class="commit-email">{{ $commit.AuthorEmail }}</a>
36
          </div>
37
          {{ if ne $commit.AuthorEmail $commit.CommitterEmail }}
38
          <div>
39
            <strong>Committed by:</strong>
40
            {{ $commit.CommitterName }}
41
            <a href="mailto:{{ $commit.CommitterEmail }}" class="commit-email">{{ $commit.CommitterEmail }}</a>
42
          </div>
43
          {{ end }}
44
          <div>
45
            <strong>Committed at:</strong>
46
            {{ humanizeTime $commit.Committed }}
47
          </div>
48
          {{ if $commit.ChangeID -}}
49
          <div>
50
            <strong>Change ID:</strong>
51
            {{ $commit.ChangeID }}
52
          </div>
53
          {{- end }}
54
          {{ if $parents }}
55
          <div>
56
            <strong>Parent:</strong>
57
            {{ range $i, $p := $parents -}}
58
            {{ if $i }}, {{ end -}}
59
            <a class="link" href="/{{ $.RepoName }}/commit/{{ $p }}">{{ $p }}</a>
60
            {{- end }}
61
          </div>
62
          {{ end }}
63
        </div>
64
65
        {{ if gt (len $diff) 1 -}}
66
        <div class="jump">
67
          <strong>jump to</strong>
68
          <table class="table jump-table">
69
            <tbody>
70
              {{ range $diff }}
71
              {{ $path := .Name.New }}
72
              {{ if not $path }}{{ $path = .Name.Old }}{{ end }}
73
              <tr>
74
                <td class="mono">{{ template "_diff_type" . }}</td>
75
                <td class="fill">
76
                  <a href="#{{ $path }}">
77
                    {{ if .IsRename }}{{ .Name.Old }} &#8594; {{ .Name.New }}
78
                    {{ else }}{{ $path }}{{ end }}
79
                  </a>
80
                </td>
81
              </tr>
82
              {{ end }}
83
            </tbody>
84
          </table>
85
        </div>
86
        {{ end }}
87
      </section>
88
89
      <section>
90
        {{ $this := $commit.Hash }}
91
        {{ $parent := "" }}
92
        {{ if $parents }}{{ $parent = index $parents 0 }}{{ end }}
93
        {{ range $diff }}
94
        {{ $path := .Name.New }}
95
        {{ if not $path }}{{ $path = .Name.Old }}{{ end }}
96
        <div id="{{ $path }}">
97
          <div class="diff">
98
            {{ template "_diff_type" . }}
99
100
            {{ $name := .Name.New }}{{ $hash := $this }}
101
            {{ if or .IsDelete .IsRename }}{{ $name = .Name.Old }}{{ $hash = $parent }}{{ end }}
102
            {{ if $hash }}<a href="/{{ $.RepoName }}/blob/{{ $hash }}/{{ $name }}">{{ $name }}</a>{{ else }}{{ $name }}{{ end }}
103
            {{ if .IsRename }} &#8594; <a href="/{{ $.RepoName }}/blob/{{ $this }}/{{ .Name.New }}">{{ .Name.New }}</a>{{ end }}
104
105
            {{ if .IsBinary }}<p>Not showing binary file.</p>
106
            {{ else }}
107
            <pre>
108
              {{- range .TextFragments -}}
109
              <span class="diff-line diff-noop diff-separator">ยทยทยท</span>
110
              {{- $o := .OldPosition -}}
111
              {{- $n := .NewPosition -}}
112
              {{- range .Lines -}}
113
              {{- $op := .Op.String -}}
114
115
              {{- if eq $op "+" -}}
116
              <span class="diff-line diff-add" id="{{ $path }}-N{{ $n }}">
117
                <span class="line-number"></span>
118
                <a class="line-number" href="#{{ $path }}-N{{ $n }}">{{ $n }}</a>
119
                <span><span class="diff-op">{{ $op }}</span>{{ .Line }}</span>
120
              </span>
121
              {{- $n = inc64 $n -}}
122
123
              {{- else if eq $op "-" -}}
124
              <span class="diff-line diff-del" id="{{ $path }}-O{{ $o }}">
125
                <a class="line-number" href="#{{ $path }}-O{{ $o }}">{{ $o }}</a>
126
                <span class="line-number"></span>
127
                <span><span class="diff-op">{{ $op }}</span>{{ .Line }}</span>
128
              </span>
129
              {{- $o = inc64 $o -}}
130
131
              {{- else -}}
132
              <span class="diff-line diff-noop" id="{{ $path }}-L{{ $o }}">
133
                <a class="line-number" href="#{{ $path }}-L{{ $o }}">{{ $o }}</a>
134
                <a class="line-number" href="#{{ $path }}-L{{ $o }}">{{ $n }}</a>
135
                <span><span class="diff-op">{{ $op }}</span>{{ .Line }}</span>
136
              </span>
137
              {{- $o = inc64 $o -}}
138
              {{- $n = inc64 $n -}}
139
              {{- end -}}
140
141
              {{- end -}}
142
              {{- end -}}
143
            </pre>
144
            {{ end }}
145
          </div>
146
        </div>
147
        {{ end }}
148
      </section>
149
    </main>
150
  </body>
151
</html>
152
{{ end }}