all repos

mugit @ fb69639f0c8274f4b9ad5904100efd6fb15a1be0

🐮 git server that your cow will love

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

Oleksandr Smirnov Oleksandr Smirnov
olexsmir@gmail.com
ui: dont display "jump to" table if there's only one file changed, 3 months ago
1
{{ define "repo_commit" }}
2
<html>
3
  <head>
4
    {{ template "head" . }}
5
    <title>{{ .name }}: {{ .commit.HashShort }}</title>
6
  </head>
7
  <body>
8
    {{ template "repo_header" . }}
9
    <main>
10
      <section class="commit">
11
        <div class="box">
12
          <div class="commit-info">
13
            <span class="commit-date">{{ .commit.Committed }}</span>
14
            {{ .commit.AuthorName }} <a href="mailto:{{ .commit.AuthorEmail }}" class="commit-email">{{ .commit.AuthorEmail }}</a>
15
          </div>
16
          <pre class="commit-message">{{- .commit.Message -}}</pre>
17
        </div>
18
19
        <table class="table commit-refs">
20
          <tbody>
21
            <tr>
22
              <td class="label nowrap"><strong>commit</strong></td>
23
              <td>
24
                <span class="commit-hash">{{ .commit.HashShort }}</span>
25
              </td>
26
            </tr>
27
            {{ if .parent }}
28
            <tr>
29
              <td class="label nowrap"><strong>parent</strong></td>
30
              <td>
31
                <span class="commit-hash">{{ .parent.HashShort }}</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
          {{ if gt (len .diff) 1}}
46
          <div class="jump">
47
            <strong>jump to</strong>
48
            <table class="table jump-table">
49
              <tbody>
50
                {{ range .diff }}
51
                {{ $path := .Name.New }}
52
                {{ if not $path }}{{ $path = .Name.Old }}{{ end }}
53
                <tr>
54
                  <td class="diff-type">
55
                    {{ if .IsNew }}<span class="diff-type diff-add">A</span>{{ end }}
56
                    {{ if .IsDelete }}<span class="diff-type diff-del">D</span>{{ end }}
57
                    {{ if not (or .IsNew .IsDelete) }}<span class="diff-type diff-mod">M</span>{{ end }}
58
                  </td>
59
                  <td class="fill">
60
                    <a href="#{{ $path }}">
61
                      {{ if and .Name.Old .Name.New }}{{ .Name.Old }} &#8594; {{ .Name.New }}{{ else }}{{ $path }}{{ end }}
62
                    </a>
63
                  </td>
64
                </tr>
65
                {{ end }}
66
              </tbody>
67
            </table>
68
          </div>
69
          {{ end }}
70
        </div>
71
      </section>
72
      <section>
73
        {{ $repo := .name }}
74
        {{ $this := .commit }}
75
        {{ $parent := .parent }}
76
        {{ range .diff }}
77
          {{ $path := .Name.New }}
78
          {{ if not $path }}{{ $path = .Name.Old }}{{ end }}
79
          <div id="{{ $path }}">
80
            <div class="diff">
81
            {{ if .IsNew }}
82
            <span class="diff-type diff-add">A</span>
83
            {{ end }}
84
            {{ if .IsDelete }}
85
            <span class="diff-type diff-del">D</span>
86
            {{ end }}
87
            {{ if not (or .IsNew .IsDelete) }}
88
            <span class="diff-type diff-mod">M</span>
89
            {{ end }}
90
          {{ if .Name.Old }}
91
          <a href="/{{ $repo }}/blob/{{ $parent }}/{{ .Name.Old }}">{{ .Name.Old }}</a>
92
          {{ if .Name.New }}
93
            &#8594; 
94
            <a href="/{{ $repo }}/blob/{{ $this }}/{{ .Name.New }}">{{ .Name.New }}</a>
95
          {{ end }}
96
          {{ else }}
97
          <a href="/{{ $repo }}/blob/{{ $this }}/{{ .Name.New }}">{{ .Name.New }}</a>
98
          {{- end -}}
99
          {{ if .IsBinary }}
100
          <p>Not showing binary file.</p>
101
          {{ else }}
102
            <pre>
103
            {{- range .TextFragments -}}
104
            <p>{{- .Header -}}</p>
105
            {{- range .Lines -}}
106
              {{- if eq .Op.String "+" -}}
107
              <span class="diff-add">{{ .String }}</span>
108
              {{- end -}}
109
              {{- if eq .Op.String "-" -}}
110
              <span class="diff-del">{{ .String }}</span>
111
              {{- end -}}
112
              {{- if eq .Op.String " " -}}
113
              <span class="diff-noop">{{ .String }}</span>
114
              {{- end -}}
115
            {{- end -}}
116
            {{- end -}}
117
          {{- end -}}
118
            </pre>
119
          </div>
120
          </div>
121
        {{ end }}
122
      </section>
123
    </main>
124
  </body>
125
</html>
126
{{ end }}