tenseleyflow/shithub / 3b9caa6

Browse files

S18: commit list / commit view / blame templates + CSS

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
3b9caa65707c2732705ea2d52bbc662e07387474
Parents
ce07386
Tree
437d5f2

4 changed files

StatusFile+-
M internal/web/static/css/shithub.css 96 0
A internal/web/templates/repo/blame.html 48 0
A internal/web/templates/repo/commit.html 78 0
A internal/web/templates/repo/commits.html 54 0
internal/web/static/css/shithub.cssmodified
@@ -991,3 +991,99 @@ code {
991991
 .shithub-finder-form input { font: inherit; padding: 0.4rem 0.6rem; border: 1px solid var(--border-default); border-radius: 6px; flex: 1; }
992992
 .shithub-finder-results { list-style: none; padding: 0; }
993993
 .shithub-finder-results li { padding: 0.3rem 0.5rem; border-bottom: 1px solid var(--border-default); font-family: monospace; font-size: 0.875rem; }
994
+
995
+/* ========== Commits + Commit + Blame (S18) ========== */
996
+.shithub-avatar-sm {
997
+  display: inline-block;
998
+  width: 20px;
999
+  height: 20px;
1000
+  border-radius: 50%;
1001
+  vertical-align: middle;
1002
+  margin-right: 0.4rem;
1003
+}
1004
+.shithub-identicon {
1005
+  background: linear-gradient(135deg, #cce, #ecc);
1006
+}
1007
+.shithub-commits-filter {
1008
+  display: flex;
1009
+  gap: 0.5rem;
1010
+  align-items: end;
1011
+  flex-wrap: wrap;
1012
+  margin: 1rem 0;
1013
+}
1014
+.shithub-commits-filter input {
1015
+  padding: 0.3rem 0.5rem;
1016
+  border: 1px solid var(--border-default);
1017
+  border-radius: 6px;
1018
+  font: inherit;
1019
+}
1020
+.shithub-commits-list { list-style: none; padding: 0; margin: 0; }
1021
+.shithub-commits-row {
1022
+  display: grid;
1023
+  grid-template-columns: 220px 1fr;
1024
+  gap: 0.75rem;
1025
+  padding: 0.6rem 0.5rem;
1026
+  border-bottom: 1px solid var(--border-default);
1027
+  align-items: start;
1028
+}
1029
+.shithub-commits-author { color: var(--fg-muted); font-size: 0.875rem; }
1030
+.shithub-commits-meta { display: flex; flex-direction: column; gap: 0.2rem; }
1031
+.shithub-commits-subject { color: var(--fg-default); font-weight: 500; }
1032
+.shithub-commits-sha { color: var(--fg-muted); font-size: 0.8rem; }
1033
+.shithub-pager { display: flex; gap: 1rem; padding: 1rem 0; }
1034
+
1035
+.shithub-commit-view { max-width: 64rem; margin: 1.5rem auto; padding: 0 1rem; }
1036
+.shithub-commit-meta {
1037
+  margin-top: 1rem;
1038
+  padding: 1rem;
1039
+  border: 1px solid var(--border-default);
1040
+  border-radius: 6px;
1041
+  background: var(--canvas-subtle);
1042
+}
1043
+.shithub-commit-subject { margin: 0 0 0.5rem; font-size: 1.2rem; }
1044
+.shithub-commit-body { margin: 0.75rem 0; font-family: monospace; font-size: 0.9rem; line-height: 1.4; }
1045
+.shithub-commit-people { display: flex; gap: 1.5rem; flex-wrap: wrap; margin: 0.75rem 0; font-size: 0.875rem; }
1046
+.shithub-commit-actor { display: inline-flex; align-items: center; gap: 0.4rem; }
1047
+.shithub-commit-role { color: var(--fg-muted); font-weight: 500; }
1048
+.shithub-commit-refs { display: grid; grid-template-columns: max-content 1fr; gap: 0.5rem 1rem; font-size: 0.875rem; }
1049
+.shithub-commit-refs dt { color: var(--fg-muted); }
1050
+.shithub-commit-refs dd { margin: 0; font-family: monospace; }
1051
+
1052
+.shithub-commit-files { margin-top: 1.5rem; }
1053
+.shithub-commit-files-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
1054
+.shithub-commit-files-table th, .shithub-commit-files-table td {
1055
+  padding: 0.4rem 0.6rem;
1056
+  border-bottom: 1px solid var(--border-default);
1057
+  text-align: left;
1058
+}
1059
+.shithub-num-col { width: 80px; text-align: right; font-variant-numeric: tabular-nums; }
1060
+.shithub-add { color: #22863a; }
1061
+.shithub-del { color: #cb2431; }
1062
+.shithub-status-A { color: #22863a; font-weight: 600; }
1063
+.shithub-status-M { color: #b08800; font-weight: 600; }
1064
+.shithub-status-D { color: #cb2431; font-weight: 600; }
1065
+.shithub-status-R { color: #6f42c1; font-weight: 600; }
1066
+.shithub-status-C { color: #0366d6; font-weight: 600; }
1067
+
1068
+.shithub-blame-table { width: 100%; border-collapse: collapse; font-family: monospace; font-size: 0.85rem; }
1069
+.shithub-blame-chunk-header td {
1070
+  padding: 0.4rem 0.6rem;
1071
+  background: var(--canvas-subtle);
1072
+  border-top: 1px solid var(--border-default);
1073
+  font-family: var(--shithub-font-default, sans-serif);
1074
+  font-size: 0.8rem;
1075
+  color: var(--fg-muted);
1076
+  display: flex;
1077
+  gap: 0.4rem;
1078
+  align-items: center;
1079
+}
1080
+.shithub-blame-lineno { width: 50px; text-align: right; padding-right: 0.5rem; color: var(--fg-muted); }
1081
+.shithub-blame-lineno a { color: inherit; }
1082
+.shithub-blame-content pre { margin: 0; white-space: pre; }
1083
+.shithub-blame-too-large {
1084
+  padding: 1rem;
1085
+  border: 1px dashed var(--border-default);
1086
+  border-radius: 6px;
1087
+  text-align: center;
1088
+  color: var(--fg-muted);
1089
+}
internal/web/templates/repo/blame.htmladded
@@ -0,0 +1,48 @@
1
+{{ define "page" -}}
2
+<section class="shithub-blame">
3
+  <header class="shithub-code-head">
4
+    <nav class="shithub-code-crumbs" aria-label="Breadcrumb">
5
+      {{ range $i, $c := .Crumbs }}
6
+        {{ if $i }}<span class="shithub-code-sep">/</span>{{ end }}
7
+        <a href="{{ $c.URL }}">{{ $c.Name }}</a>
8
+      {{ end }}
9
+    </nav>
10
+    <div class="shithub-code-actions">
11
+      <a href="/{{ .Owner }}/{{ .Repo.Name }}/blob/{{ .Ref }}/{{ .Path }}" class="shithub-button">View source</a>
12
+      <a href="/{{ .Owner }}/{{ .Repo.Name }}/commits/{{ .Ref }}?path={{ .Path }}" class="shithub-button">History</a>
13
+    </div>
14
+  </header>
15
+
16
+  {{ if .TooLarge }}
17
+  <div class="shithub-blame-too-large">
18
+    Blame is too expensive for this file. <a href="/{{ .Owner }}/{{ .Repo.Name }}/blob/{{ .Ref }}/{{ .Path }}">View source</a> instead.
19
+  </div>
20
+  {{ else if .NotBlob }}
21
+  <div class="shithub-blame-too-large">Blame requires a regular file.</div>
22
+  {{ else }}
23
+  <table class="shithub-blame-table">
24
+    <tbody>
25
+      {{ range .Chunks }}
26
+      <tr class="shithub-blame-chunk-header">
27
+        <td colspan="3">
28
+          {{ if .Author.User }}
29
+          <a href="/{{ .Author.Username }}">{{ .Author.DisplayName }}</a>
30
+          {{ else }}
31
+          <span>{{ .Chunk.AuthorName }}</span>
32
+          {{ end }}
33
+          <a href="/{{ $.Owner }}/{{ $.Repo.Name }}/commit/{{ .Chunk.OID }}"><code>{{ .Chunk.ShortOID }}</code></a>
34
+          <time datetime="{{ .Chunk.AuthorWhen.Format "2006-01-02T15:04:05Z" }}">{{ relativeTime .Chunk.AuthorWhen }}</time>
35
+        </td>
36
+      </tr>
37
+      {{ range .Chunk.Lines }}
38
+      <tr id="L{{ .FinalLineNo }}">
39
+        <td class="shithub-blame-lineno"><a href="#L{{ .FinalLineNo }}">{{ .FinalLineNo }}</a></td>
40
+        <td class="shithub-blame-content"><pre>{{ .Content }}</pre></td>
41
+      </tr>
42
+      {{ end }}
43
+      {{ end }}
44
+    </tbody>
45
+  </table>
46
+  {{ end }}
47
+</section>
48
+{{- end }}
internal/web/templates/repo/commit.htmladded
@@ -0,0 +1,78 @@
1
+{{ define "page" -}}
2
+<section class="shithub-commit-view">
3
+  <header class="shithub-code-head">
4
+    <h1>
5
+      <a href="/{{ .Owner }}/{{ .Repo.Name }}/tree/{{ .Detail.OID }}">{{ .Owner }}/{{ .Repo.Name }}</a>
6
+      <span class="shithub-code-sep">/</span>
7
+      <code>{{ .Detail.ShortOID }}</code>
8
+    </h1>
9
+    <a href="/{{ .Owner }}/{{ .Repo.Name }}/tree/{{ .Detail.TreeOID }}" class="shithub-button">Browse files</a>
10
+  </header>
11
+
12
+  <article class="shithub-commit-meta">
13
+    <h2 class="shithub-commit-subject">{{ .Detail.Subject }}</h2>
14
+    {{ if .Detail.Body }}<div class="shithub-commit-body">{{ .BodyHTML }}</div>{{ end }}
15
+
16
+    <div class="shithub-commit-people">
17
+      <div class="shithub-commit-actor">
18
+        <span class="shithub-commit-role">Authored by</span>
19
+        {{ if .Author.User }}
20
+        <a href="/{{ .Author.Username }}"><img src="{{ .Author.AvatarURL }}" alt="" class="shithub-avatar-sm"></a>
21
+        <a href="/{{ .Author.Username }}">{{ .Author.DisplayName }}</a>
22
+        {{ else }}
23
+        <span class="shithub-avatar-sm shithub-identicon" data-seed="{{ .Author.IdenticonSeed }}" aria-hidden="true"></span>
24
+        <span>{{ .Detail.AuthorName }} &lt;{{ .Detail.AuthorEmail }}&gt;</span>
25
+        {{ end }}
26
+        <time datetime="{{ .Detail.AuthorWhen.Format "2006-01-02T15:04:05Z" }}">{{ relativeTime .Detail.AuthorWhen }}</time>
27
+      </div>
28
+      {{ if ne .Detail.CommitterEmail .Detail.AuthorEmail }}
29
+      <div class="shithub-commit-actor">
30
+        <span class="shithub-commit-role">Committed by</span>
31
+        {{ if .Committer.User }}
32
+        <a href="/{{ .Committer.Username }}">{{ .Committer.DisplayName }}</a>
33
+        {{ else }}
34
+        <span>{{ .Detail.CommitterName }}</span>
35
+        {{ end }}
36
+      </div>
37
+      {{ end }}
38
+    </div>
39
+
40
+    <dl class="shithub-commit-refs">
41
+      <dt>SHA</dt><dd><code>{{ .Detail.OID }}</code></dd>
42
+      {{ if .Detail.Parents }}
43
+      <dt>Parents</dt>
44
+      <dd>
45
+        {{ range .Detail.Parents }}
46
+        <a href="/{{ $.Owner }}/{{ $.Repo.Name }}/commit/{{ . }}"><code>{{ slice . 0 7 }}</code></a>
47
+        {{ end }}
48
+      </dd>
49
+      {{ end }}
50
+      <dt>Tree</dt>
51
+      <dd><a href="/{{ .Owner }}/{{ .Repo.Name }}/tree/{{ .Detail.OID }}"><code>{{ slice .Detail.TreeOID 0 7 }}</code></a></dd>
52
+    </dl>
53
+  </article>
54
+
55
+  <section class="shithub-commit-files">
56
+    <h3>{{ len .Detail.Files }} changed file{{ if ne (len .Detail.Files) 1 }}s{{ end }}</h3>
57
+    <table class="shithub-commit-files-table">
58
+      <thead>
59
+        <tr><th>Status</th><th>File</th><th class="shithub-num-col">+</th><th class="shithub-num-col">-</th></tr>
60
+      </thead>
61
+      <tbody>
62
+        {{ range .Detail.Files }}
63
+        <tr>
64
+          <td><span class="shithub-status-{{ .Status }}">{{ .Status }}</span></td>
65
+          <td>
66
+            {{ if eq .Status "R" }}<code>{{ .OldPath }}</code> → {{ end }}
67
+            <a href="/{{ $.Owner }}/{{ $.Repo.Name }}/blob/{{ $.Detail.OID }}/{{ .Path }}"><code>{{ .Path }}</code></a>
68
+          </td>
69
+          <td class="shithub-num-col shithub-add">{{ if .Binary }}bin{{ else }}{{ .Insert }}{{ end }}</td>
70
+          <td class="shithub-num-col shithub-del">{{ if .Binary }}{{ else }}{{ .Delete }}{{ end }}</td>
71
+        </tr>
72
+        {{ end }}
73
+      </tbody>
74
+    </table>
75
+    <p class="shithub-hint">Per-file diff bodies render once S19 ships.</p>
76
+  </section>
77
+</section>
78
+{{- end }}
internal/web/templates/repo/commits.htmladded
@@ -0,0 +1,54 @@
1
+{{ define "page" -}}
2
+<section class="shithub-commits">
3
+  <header class="shithub-code-head">
4
+    <h1>
5
+      <a href="/{{ .Owner }}/{{ .Repo.Name }}/tree/{{ .Ref }}">{{ .Owner }}/{{ .Repo.Name }}</a>
6
+      <span class="shithub-code-sep">/</span>
7
+      Commits on <code>{{ .Ref }}</code>
8
+    </h1>
9
+    <details class="shithub-ref-switcher">
10
+      <summary>{{ .Ref }}</summary>
11
+      <div class="shithub-ref-panel">
12
+        {{ if .Branches }}<strong>Branches</strong>
13
+        {{ range .Branches }}<a href="/{{ $.Owner }}/{{ $.Repo.Name }}/commits/{{ .Name }}">{{ .Name }}</a>{{ end }}{{ end }}
14
+        {{ if .Tags }}<strong>Tags</strong>
15
+        {{ range .Tags }}<a href="/{{ $.Owner }}/{{ $.Repo.Name }}/commits/{{ .Name }}">{{ .Name }}</a>{{ end }}{{ end }}
16
+      </div>
17
+    </details>
18
+  </header>
19
+
20
+  <form class="shithub-commits-filter" method="GET" action="/{{ .Owner }}/{{ .Repo.Name }}/commits/{{ .Ref }}">
21
+    <label>Path <input type="text" name="path" value="{{ .PathFilter }}" placeholder="path/to/file"></label>
22
+    <label>Author <input type="text" name="author" value="{{ .Author }}" placeholder="name or email"></label>
23
+    <label>Since <input type="date" name="since" value="{{ .Since }}"></label>
24
+    <label>Until <input type="date" name="until" value="{{ .Until }}"></label>
25
+    <button type="submit" class="shithub-button">Filter</button>
26
+  </form>
27
+
28
+  <ul class="shithub-commits-list">
29
+    {{ range .Rows }}
30
+    <li class="shithub-commits-row">
31
+      <div class="shithub-commits-author">
32
+        {{ if .Author.User }}
33
+        <a href="/{{ .Author.Username }}"><img src="{{ .Author.AvatarURL }}" alt="" class="shithub-avatar-sm"></a>
34
+        <a href="/{{ .Author.Username }}">{{ .Author.DisplayName }}</a>
35
+        {{ else }}
36
+        <span class="shithub-avatar-sm shithub-identicon" data-seed="{{ .Author.IdenticonSeed }}" aria-hidden="true"></span>
37
+        <span>{{ .Commit.AuthorName }}</span>
38
+        {{ end }}
39
+      </div>
40
+      <div class="shithub-commits-meta">
41
+        <a class="shithub-commits-subject" href="/{{ $.Owner }}/{{ $.Repo.Name }}/commit/{{ .Commit.OID }}">{{ .Commit.Subject }}</a>
42
+        <code class="shithub-commits-sha">{{ .Commit.ShortOID }}</code>
43
+        <time datetime="{{ .Commit.AuthorWhen.Format "2006-01-02T15:04:05Z" }}">{{ relativeTime .Commit.AuthorWhen }}</time>
44
+      </div>
45
+    </li>
46
+    {{ end }}
47
+  </ul>
48
+
49
+  <nav class="shithub-pager" aria-label="Pagination">
50
+    {{ if gt .PrevPage 0 }}<a href="?page={{ .PrevPage }}{{ if .PathFilter }}&path={{ .PathFilter }}{{ end }}{{ if .Author }}&author={{ .Author }}{{ end }}{{ if .Since }}&since={{ .Since }}{{ end }}{{ if .Until }}&until={{ .Until }}{{ end }}">Newer</a>{{ end }}
51
+    {{ if .HasMore }}<a href="?page={{ .NextPage }}{{ if .PathFilter }}&path={{ .PathFilter }}{{ end }}{{ if .Author }}&author={{ .Author }}{{ end }}{{ if .Since }}&since={{ .Since }}{{ end }}{{ if .Until }}&until={{ .Until }}{{ end }}">Older</a>{{ end }}
52
+  </nav>
53
+</section>
54
+{{- end }}