all repos

mugit @ 7218955

๐Ÿฎ 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 authored and commited times if needed, 1 month 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 ne $commit.Authored $commit.Committed }}
49
          <div>
50
            <strong>Authored at:</strong>
51
            {{ humanizeTime $commit.Authored }}
52
          </div>
53
          {{ end }}
54
          {{ if $commit.ChangeID -}}
55
          <div>
56
            <strong>Change ID:</strong>
57
            {{ $commit.ChangeID }}
58
          </div>
59
          {{- end }}
60
          {{ if $parents }}
61
          <div>
62
            <strong>Parent:</strong>
63
            {{ range $i, $p := $parents -}}
64
            {{ if $i }}, {{ end -}}
65
            <a class="link" href="/{{ $.RepoName }}/commit/{{ $p }}">{{ $p }}</a>
66
            {{- end }}
67
          </div>
68
          {{ end }}
69
        </div>
70
71
        {{ if gt (len $diff) 1 -}}
72
        <div class="jump">
73
          <strong>jump to</strong>
74
          <table class="table jump-table">
75
            <tbody>
76
              {{ range $diff }}
77
              {{ $path := .Name.New }}
78
              {{ if not $path }}{{ $path = .Name.Old }}{{ end }}
79
              <tr>
80
                <td class="mono">{{ template "_diff_type" . }}</td>
81
                <td class="fill">
82
                  <a href="#{{ $path }}">
83
                    {{ if .IsRename }}{{ .Name.Old }} &#8594; {{ .Name.New }}
84
                    {{ else }}{{ $path }}{{ end }}
85
                  </a>
86
                </td>
87
              </tr>
88
              {{ end }}
89
            </tbody>
90
          </table>
91
        </div>
92
        {{ end }}
93
      </section>
94
95
      <section>
96
        {{ $this := $commit.Hash }}
97
        {{ $parent := "" }}
98
        {{ if $parents }}{{ $parent = index $parents 0 }}{{ end }}
99
        {{ range $diff }}
100
        {{ $path := .Name.New }}
101
        {{ if not $path }}{{ $path = .Name.Old }}{{ end }}
102
        <div id="{{ $path }}">
103
          <div class="diff">
104
            {{ template "_diff_type" . }}
105
106
            {{ $name := .Name.New }}{{ $hash := $this }}
107
            {{ if or .IsDelete .IsRename }}{{ $name = .Name.Old }}{{ $hash = $parent }}{{ end }}
108
            {{ if $hash }}<a href="/{{ $.RepoName }}/blob/{{ $hash }}/{{ $name }}">{{ $name }}</a>{{ else }}{{ $name }}{{ end }}
109
            {{ if .IsRename }} &#8594; <a href="/{{ $.RepoName }}/blob/{{ $this }}/{{ .Name.New }}">{{ .Name.New }}</a>{{ end }}
110
111
            {{ if .IsBinary }}<p>Not showing binary file.</p>
112
            {{ else }}
113
            <pre>
114
              {{- range .TextFragments -}}
115
              <span class="diff-line diff-noop diff-separator">ยทยทยท</span>
116
              {{- $o := .OldPosition -}}
117
              {{- $n := .NewPosition -}}
118
              {{- range .Lines -}}
119
              {{- $op := .Op.String -}}
120
121
              {{- if eq $op "+" -}}
122
              <span class="diff-line diff-add" id="{{ $path }}-N{{ $n }}">
123
                <span class="line-number"></span>
124
                <a class="line-number" href="#{{ $path }}-N{{ $n }}">{{ $n }}</a>
125
                <span><span class="diff-op">{{ $op }}</span>{{ .Line }}</span>
126
              </span>
127
              {{- $n = inc64 $n -}}
128
129
              {{- else if eq $op "-" -}}
130
              <span class="diff-line diff-del" id="{{ $path }}-O{{ $o }}">
131
                <a class="line-number" href="#{{ $path }}-O{{ $o }}">{{ $o }}</a>
132
                <span class="line-number"></span>
133
                <span><span class="diff-op">{{ $op }}</span>{{ .Line }}</span>
134
              </span>
135
              {{- $o = inc64 $o -}}
136
137
              {{- else -}}
138
              <span class="diff-line diff-noop" id="{{ $path }}-L{{ $o }}">
139
                <a class="line-number" href="#{{ $path }}-L{{ $o }}">{{ $o }}</a>
140
                <a class="line-number" href="#{{ $path }}-L{{ $o }}">{{ $n }}</a>
141
                <span><span class="diff-op">{{ $op }}</span>{{ .Line }}</span>
142
              </span>
143
              {{- $o = inc64 $o -}}
144
              {{- $n = inc64 $n -}}
145
              {{- end -}}
146
147
              {{- end -}}
148
              {{- end -}}
149
            </pre>
150
            {{ end }}
151
          </div>
152
        </div>
153
        {{ end }}
154
      </section>
155
    </main>
156
  </body>
157
</html>
158
{{ end }}