all repos

mugit @ 8fee104ec19279689acf5b9b0dd4a47452897ba6

🐮 git server that your cow will love

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

Oleksandr Smirnov Oleksandr Smirnov
olexsmir@gmail.com
ui: improve ux of commits with empty message, 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="commit-refs">
12
          {{ .stat.FilesChanged }} files changed,
13
          {{ .stat.Insertions }} insertions(+),
14
          {{ .stat.Deletions }} deletions(-)
15
        </div>
16
17
        <div class="box">
18
          <pre class="commit-message">
19
            {{- if .commit.Message }}{{- .commit.Message -}}
20
            {{- else -}}<span class="muted">Empty message</span>{{- end -}}
21
          </pre>
22
          <div>
23
            <strong>Author:</strong>
24
            {{ .commit.AuthorName }}
25
            <a href="mailto:{{ .AuthorEmail }}" class="commit-email">{{ .commit.AuthorEmail }}</a>
26
          </div>
27
          <div>
28
            <strong>Committed at:</strong>
29
            {{ .commit.Committed }}
30
          </div>
31
          {{ if .commit.ChangeID -}}
32
          <div>
33
            <strong>Change ID:</strong>
34
            {{ .commit.ChangeID }}
35
          </div>
36
          {{- end }}
37
          <div>
38
            <strong>Parent:</strong>
39
            {{ range $i, $p := .parents -}}
40
            {{ if $i }}, {{ end -}}
41
            <a class="link" href="/{{ $.name }}/commit/{{ $p }}">{{ $p }}</a>
42
            {{- end }}
43
          </div>
44
        </div>
45
46
        {{ if gt (len .diff) 1 -}}
47
        <div class="jump">
48
          <strong>jump to</strong>
49
          <table class="table jump-table">
50
            <tbody>
51
              {{ range .diff }}
52
              {{ $path := .Name.New }}
53
              {{ if not $path }}{{ $path = .Name.Old }}{{ end }}
54
              <tr>
55
                <td class="diff-type">
56
                  {{ if .IsNew }}<span class="diff-type diff-add">A</span>{{ end }}
57
                  {{ if .IsDelete }}<span class="diff-type diff-del">D</span>{{ end }}
58
                  {{ if not (or .IsNew .IsDelete) }}<span class="diff-type diff-mod">M</span>{{ end }}
59
                </td>
60
                <td class="fill">
61
                  <a href="#{{ $path }}">
62
                    {{ if and .Name.Old .Name.New }}{{ .Name.Old }} &#8594; {{ .Name.New }}{{ else }}{{ $path }}{{ end }}
63
                  </a>
64
                </td>
65
              </tr>
66
              {{ end }}
67
            </tbody>
68
          </table>
69
        </div>
70
        {{ end }}
71
      </section>
72
      <section>
73
        {{ $repo := .name }}
74
        {{ $this := .commit.Hash }}
75
        {{ $parent := index .parents 0 }}
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 }}