all repos

mugit @ fc51f8d

🐮 git server that your cow will love

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

Oleksandr Smirnov Oleksandr Smirnov
olexsmir@gmail.com
i dont like duplication, 3 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="diff-type">{{ 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
            {{ if .IsNew }}<a href="/{{ $.RepoName }}/blob/{{ $this }}/{{ .Name.New }}">{{ .Name.New }}</a>{{ else }}
101
            {{ if $parent }}<a href="/{{ $.RepoName }}/blob/{{ $parent }}/{{ .Name.New }}">{{ .Name.New }}</a>
102
            {{ else }}{{ .Name.Old }}{{ end }}
103
            {{ if .IsRename }}&#8594;<a href="/{{ $.RepoName }}/blob/{{ $this }}/{{ .Name.New }}">{{ .Name.New }}</a>{{ end }}
104
            {{ end }}
105
106
            {{ if .IsBinary }}<p>Not showing binary file.</p>
107
            {{ else }}
108
            <pre>
109
              {{- range .TextFragments -}}
110
              <p>{{- .Header -}}</p>
111
              {{- range .Lines -}}
112
              {{- if eq .Op.String "+" -}}<span class="diff-add">{{ .String }}</span>
113
              {{- else if eq .Op.String "-" -}}<span class="diff-del">{{ .String }}</span>
114
              {{- else -}}<span class="diff-noop">{{ .String }}</span>
115
              {{- end -}}
116
              {{- end -}}
117
              {{- end -}}
118
            </pre>
119
            {{ end }}
120
          </div>
121
        </div>
122
        {{ end }}
123
      </section>
124
    </main>
125
  </body>
126
</html>
127
{{ end }}