mugit/web/templates/repo_commit.html (view raw)
Oleksandr Smirnov
Oleksandr Smirnov
olexsmir@gmail.com ui: give some love to templates, 3 months ago
olexsmir@gmail.com ui: give some love to templates, 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 | <div class="jump"> |
| 46 | <strong>jump to</strong> |
| 47 | <table class="table 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="fill"> |
| 59 | <a href="#{{ $path }}"> |
| 60 | {{ if and .Name.Old .Name.New }}{{ .Name.Old }} → {{ .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 }} |
| 73 | {{ $parent := .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 | → |
| 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 }} |