all repos

mugit @ e61accc205dd74882b1deb4379888cf59226a010

🐮 git server that your cow will love

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

Oleksandr Smirnov Oleksandr Smirnov
olexsmir@gmail.com
ui: refactor how data is passed to pages, 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
          {{ $stat.FilesChanged }} files changed,
17
          {{ $stat.Insertions }} insertions(+),
18
          {{ $stat.Deletions }} deletions(-)
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
          <div>
32
            <strong>Committed at:</strong>
33
            {{ $commit.Committed }}
34
          </div>
35
          {{ if $commit.ChangeID -}}
36
          <div>
37
            <strong>Change ID:</strong>
38
            {{ $commit.ChangeID }}
39
          </div>
40
          {{- end }}
41
          <div>
42
            <strong>Parent:</strong>
43
            {{ range $i, $p := $parents -}}
44
            {{ if $i }}, {{ end -}}
45
            <a class="link" href="/{{$.RepoName}}/commit/{{ $p }}">{{ $p }}</a>
46
            {{- end }}
47
          </div>
48
        </div>
49
50
        {{ if gt (len $diff) 1 -}}
51
        <div class="jump">
52
          <strong>jump to</strong>
53
          <table class="table jump-table">
54
            <tbody>
55
              {{ range $diff }}
56
              {{ $path := .Name.New }}
57
              {{ if not $path }}{{ $path = .Name.Old }}{{ end }}
58
              <tr>
59
                <td class="diff-type">
60
                  {{ if .IsNew }}<span class="diff-type diff-add">A</span>{{ end }}
61
                  {{ if .IsDelete }}<span class="diff-type diff-del">D</span>{{ end }}
62
                  {{ if not (or .IsNew .IsDelete) }}<span class="diff-type diff-mod">M</span>{{ end }}
63
                </td>
64
                <td class="fill">
65
                  <a href="#{{ $path }}">
66
                    {{ if and .Name.Old .Name.New }}{{ .Name.Old }} &#8594; {{ .Name.New }}{{ else }}{{ $path }}{{ end }}
67
                  </a>
68
                </td>
69
              </tr>
70
              {{ end }}
71
            </tbody>
72
          </table>
73
        </div>
74
        {{ end }}
75
      </section>
76
      <section>
77
        {{ $this := $commit.Hash }}
78
        {{ $parent := index $parents 0 }}
79
        {{ range $diff }}
80
        {{ $path := .Name.New }}
81
        {{ if not $path }}{{ $path = .Name.Old }}{{ end }}
82
        <div id="{{ $path }}">
83
          <div class="diff">
84
            {{ if .IsNew }}
85
            <span class="diff-type diff-add">A</span>
86
            {{ end }}
87
            {{ if .IsDelete }}
88
            <span class="diff-type diff-del">D</span>
89
            {{ end }}
90
            {{ if not (or .IsNew .IsDelete) }}
91
            <span class="diff-type diff-mod">M</span>
92
            {{ end }}
93
            {{ if .Name.Old }}
94
            <a href="/{{$.RepoName}}/blob/{{ $parent }}/{{ .Name.Old }}">{{ .Name.Old }}</a>
95
            {{ if .Name.New }}
96
            &#8594;
97
            <a href="/{{$.RepoName}}/blob/{{ $this }}/{{ .Name.New }}">{{ .Name.New }}</a>
98
            {{ end }}
99
            {{ else }}
100
            <a href="/{{$.RepoName}}/blob/{{ $this }}/{{ .Name.New }}">{{ .Name.New }}</a>
101
            {{- end -}}
102
            {{ if .IsBinary }}
103
            <p>Not showing binary file.</p>
104
            {{ else }}
105
            <pre>
106
              {{- range .TextFragments -}}
107
              <p>{{- .Header -}}</p>
108
              {{- range .Lines -}}
109
              {{- if eq .Op.String "+" -}}
110
              <span class="diff-add">{{ .String }}</span>
111
              {{- end -}}
112
              {{- if eq .Op.String "-" -}}
113
              <span class="diff-del">{{ .String }}</span>
114
              {{- end -}}
115
              {{- if eq .Op.String " " -}}
116
              <span class="diff-noop">{{ .String }}</span>
117
              {{- end -}}
118
              {{- end -}}
119
              {{- end -}}
120
              {{- end -}}
121
            </pre>
122
          </div>
123
        </div>
124
        {{ end }}
125
      </section>
126
    </main>
127
  </body>
128
</html>
129
{{ end }}