all repos

mugit @ b883855

🐮 git server that your cow will love

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

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