all repos

mugit @ 771137527ab793487a5b7bf5e233666a8997a892

🐮 git server that your cow will love

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

Oleksandr Smirnov Oleksandr Smirnov
olexsmir@gmail.com
ui: fix: show renamed files correctly in commit view, 4 months ago
1
{{ define "commit" }}
2
<html>
3
  <head>
4
    {{ template "head" . }}
5
    <title>{{ .name }}: {{ .commit.This }}</title>
6
  </head>
7
  {{ template "repo_header" . }}
8
  <body>
9
    <main>
10
      <section class="commit">
11
        <div class="box">
12
          <div class="commit-info">
13
            <span class="commit-date">{{ .commit.Author.When.Format "Mon, 02 Jan 2006 15:04:05 -0700" }}</span>
14
            {{ .commit.Author.Name }} <a href="mailto:{{ .commit.Author.Email }}" class="commit-email">{{ .commit.Author.Email }}</a>
15
          </div>
16
          <pre class="commit-message">{{- .commit.Message -}}</pre>
17
        </div>
18
19
        <table class="commit-refs">
20
          <tbody>
21
            <tr>
22
              <td class="label"><strong>commit</strong></td>
23
              <td>
24
                <span class="commit-hash">{{ .commit.This }}</span>
25
              </td>
26
            </tr>
27
            {{ if .commit.Parent }}
28
            <tr>
29
              <td class="label"><strong>parent</strong></td>
30
              <td>
31
                <span class="commit-hash">{{ .commit.Parent }}</span>
32
              </td>
33
            </tr>
34
            {{ end }}
35
          </tbody>
36
        </table>
37
38
        <div class="diff-stat">
39
          <div>
40
          {{ .stat.FilesChanged }} files changed,
41
          {{ .stat.Insertions }} insertions(+),
42
          {{ .stat.Deletions }} deletions(-)
43
          </div>
44
45
          <div class="jump">
46
            <strong>jump to</strong>
47
            <table class="jump-table">
48
              <tbody>
49
                {{ range .diff }}
50
                {{ $path := .Name.New }}
51
                {{ if not $path }}{{ $path = .Name.Old }}{{ end }}
52
                <tr>
53
                  <td class="diff-type">
54
                    {{ if .IsNew }}<span class="diff-type diff-add">A</span>{{ end }}
55
                    {{ if .IsDelete }}<span class="diff-type diff-del">D</span>{{ end }}
56
                    {{ if not (or .IsNew .IsDelete) }}<span class="diff-type diff-mod">M</span>{{ end }}
57
                  </td>
58
                  <td class="path">
59
                    <a href="#{{ $path }}">
60
                      {{ if and .Name.Old .Name.New }}{{ .Name.Old }} &#8594; {{ .Name.New }}{{ else }}{{ $path }}{{ end }}
61
                    </a>
62
                  </td>
63
                </tr>
64
                {{ end }}
65
              </tbody>
66
            </table>
67
          </div>
68
        </div>
69
      </section>
70
      <section>
71
        {{ $repo := .name }}
72
        {{ $this := .commit.This }}
73
        {{ $parent := .commit.Parent }}
74
        {{ range .diff }}
75
          {{ $path := .Name.New }}
76
          {{ if not $path }}{{ $path = .Name.Old }}{{ end }}
77
          <div id="{{ $path }}">
78
            <div class="diff">
79
            {{ if .IsNew }}
80
            <span class="diff-type diff-add">A</span>
81
            {{ end }}
82
            {{ if .IsDelete }}
83
            <span class="diff-type diff-del">D</span>
84
            {{ end }}
85
            {{ if not (or .IsNew .IsDelete) }}
86
            <span class="diff-type diff-mod">M</span>
87
            {{ end }}
88
          {{ if .Name.Old }}
89
          <a href="/{{ $repo }}/blob/{{ $parent }}/{{ .Name.Old }}">{{ .Name.Old }}</a>
90
          {{ if .Name.New }}
91
            &#8594; 
92
            <a href="/{{ $repo }}/blob/{{ $this }}/{{ .Name.New }}">{{ .Name.New }}</a>
93
          {{ end }}
94
          {{ else }}
95
          <a href="/{{ $repo }}/blob/{{ $this }}/{{ .Name.New }}">{{ .Name.New }}</a>
96
          {{- end -}}
97
          {{ if .IsBinary }}
98
          <p>Not showing binary file.</p>
99
          {{ else }}
100
            <pre>
101
            {{- range .TextFragments -}}
102
            <p>{{- .Header -}}</p>
103
            {{- range .Lines -}}
104
              {{- if eq .Op.String "+" -}}
105
              <span class="diff-add">{{ .String }}</span>
106
              {{- end -}}
107
              {{- if eq .Op.String "-" -}}
108
              <span class="diff-del">{{ .String }}</span>
109
              {{- end -}}
110
              {{- if eq .Op.String " " -}}
111
              <span class="diff-noop">{{ .String }}</span>
112
              {{- end -}}
113
            {{- end -}}
114
            {{- end -}}
115
          {{- end -}}
116
            </pre>
117
          </div>
118
          </div>
119
        {{ end }}
120
      </section>
121
    </main>
122
  </body>
123
</html>
124
{{ end }}