tenseleyflow/shithub / 0a1bfa2

Browse files

S20: branches/tags/compare/settings templates + CSS

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
0a1bfa24b4e5c05e106250d84c85650e073254e3
Parents
b8b7c3a
Tree
a60d3f7

5 changed files

StatusFile+-
M internal/web/static/css/shithub.css 21 0
A internal/web/templates/repo/branches.html 52 0
A internal/web/templates/repo/compare.html 49 0
A internal/web/templates/repo/settings_branches.html 71 0
A internal/web/templates/repo/tags.html 31 0
internal/web/static/css/shithub.cssmodified
@@ -1154,3 +1154,24 @@ code {
11541154
   width: 50%;
11551155
   border-left: 1px solid var(--border-default);
11561156
 }
1157
+
1158
+/* ========== Branches/Tags/Compare/Settings (S20) ========== */
1159
+.shithub-branches, .shithub-tags, .shithub-compare, .shithub-settings-branches {
1160
+  max-width: 64rem;
1161
+  margin: 1.5rem auto;
1162
+  padding: 0 1rem;
1163
+}
1164
+.shithub-branches-filter { display: flex; gap: 0.4rem; }
1165
+.shithub-branches-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
1166
+.shithub-branches-table th, .shithub-branches-table td {
1167
+  padding: 0.5rem 0.75rem;
1168
+  text-align: left;
1169
+  border-bottom: 1px solid var(--border-default);
1170
+}
1171
+.shithub-branches-subject { color: var(--fg-default); }
1172
+.shithub-compare-summary { padding: 0.75rem 1rem; background: var(--canvas-subtle); border-radius: 6px; display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
1173
+.shithub-compare-empty { padding: 1.5rem; text-align: center; color: var(--fg-muted); border: 1px dashed var(--border-default); border-radius: 6px; }
1174
+.shithub-compare-commits { margin-top: 1.5rem; }
1175
+.shithub-settings-branches form label { display: block; margin: 0.5rem 0; }
1176
+.shithub-settings-branches form input[type=text],
1177
+.shithub-settings-branches form select { font: inherit; padding: 0.4rem 0.6rem; border: 1px solid var(--border-default); border-radius: 6px; min-width: 280px; }
internal/web/templates/repo/branches.htmladded
@@ -0,0 +1,52 @@
1
+{{ define "page" -}}
2
+<section class="shithub-branches">
3
+  <header class="shithub-code-head">
4
+    <h1>
5
+      <a href="/{{ .Owner }}/{{ .Repo.Name }}/tree/{{ .DefaultBranch }}">{{ .Owner }}/{{ .Repo.Name }}</a>
6
+      <span class="shithub-code-sep">/</span>
7
+      Branches
8
+    </h1>
9
+    <nav class="shithub-branches-filter">
10
+      <a href="?filter=" class="shithub-button {{ if eq .Filter "" }}shithub-button-primary{{ end }}">All</a>
11
+      <a href="?filter=active" class="shithub-button {{ if eq .Filter "active" }}shithub-button-primary{{ end }}">Active</a>
12
+      <a href="?filter=stale" class="shithub-button {{ if eq .Filter "stale" }}shithub-button-primary{{ end }}">Stale</a>
13
+    </nav>
14
+  </header>
15
+
16
+  <table class="shithub-branches-table">
17
+    <thead>
18
+      <tr>
19
+        <th>Branch</th>
20
+        <th>Last commit</th>
21
+        <th>vs <code>{{ .DefaultBranch }}</code></th>
22
+        <th></th>
23
+      </tr>
24
+    </thead>
25
+    <tbody>
26
+      {{ range .Rows }}
27
+      <tr>
28
+        <td>
29
+          <a href="/{{ $.Owner }}/{{ $.Repo.Name }}/tree/{{ .Name }}"><code>{{ .Name }}</code></a>
30
+          {{ if .IsDefault }}<span class="shithub-pill">default</span>{{ end }}
31
+          {{ if .Protected }}<span class="shithub-pill shithub-pill-private">protected</span>{{ end }}
32
+        </td>
33
+        <td>
34
+          {{ if .LastSubject }}
35
+          <a href="/{{ $.Owner }}/{{ $.Repo.Name }}/commit/{{ .OID }}" class="shithub-branches-subject">{{ .LastSubject }}</a>
36
+          <small><time datetime="{{ .LastWhen.Format "2006-01-02T15:04:05Z" }}">{{ relativeTime .LastWhen }}</time></small>
37
+          {{ end }}
38
+        </td>
39
+        <td>
40
+          {{ if .IsDefault }}—{{ else }}<span class="shithub-add">+{{ .Ahead }}</span> <span class="shithub-del">−{{ .Behind }}</span>{{ end }}
41
+        </td>
42
+        <td>
43
+          {{ if not .IsDefault }}
44
+          <a href="/{{ $.Owner }}/{{ $.Repo.Name }}/compare/{{ $.DefaultBranch }}...{{ .Name }}" class="shithub-button">Compare</a>
45
+          {{ end }}
46
+        </td>
47
+      </tr>
48
+      {{ end }}
49
+    </tbody>
50
+  </table>
51
+</section>
52
+{{- end }}
internal/web/templates/repo/compare.htmladded
@@ -0,0 +1,49 @@
1
+{{ define "page" -}}
2
+<section class="shithub-compare">
3
+  <header class="shithub-code-head">
4
+    <h1>
5
+      <a href="/{{ .Owner }}/{{ .Repo.Name }}/tree/{{ .Repo.DefaultBranch }}">{{ .Owner }}/{{ .Repo.Name }}</a>
6
+      <span class="shithub-code-sep">/</span>
7
+      Compare <code>{{ .Base }}</code> ... <code>{{ .Head }}</code>
8
+    </h1>
9
+  </header>
10
+
11
+  {{ if .NotFound }}
12
+  <div class="shithub-compare-empty">One or both refs were not found in this repository.</div>
13
+  {{ else }}
14
+  <p class="shithub-compare-summary">
15
+    {{ if eq .Base .Head }}
16
+    Base and head are the same — nothing to compare.
17
+    {{ else if le .Ahead 0 }}
18
+    There isn't anything to compare. <code>{{ .Head }}</code> is up to date with <code>{{ .Base }}</code>.
19
+    {{ else }}
20
+    <strong>{{ .Ahead }}</strong> commit{{ if ne .Ahead 1 }}s{{ end }} ahead, <strong>{{ .Behind }}</strong> behind <code>{{ .Base }}</code>.
21
+    <a href="/{{ .Owner }}/{{ .Repo.Name }}/pulls/new?base={{ .Base }}&amp;head={{ .Head }}" class="shithub-button shithub-button-primary">Create pull request</a>
22
+    {{ end }}
23
+  </p>
24
+
25
+  {{ if .Commits }}
26
+  <section class="shithub-compare-commits">
27
+    <h2>Commits in <code>{{ .Head }}</code></h2>
28
+    <ul class="shithub-commits-list">
29
+      {{ range .Commits }}
30
+      <li class="shithub-commits-row">
31
+        <div class="shithub-commits-meta">
32
+          <a class="shithub-commits-subject" href="/{{ $.Owner }}/{{ $.Repo.Name }}/commit/{{ .OID }}">{{ .Subject }}</a>
33
+          <code class="shithub-commits-sha">{{ .ShortOID }}</code>
34
+          <small>{{ .AuthorName }} · <time datetime="{{ .AuthorWhen.Format "2006-01-02T15:04:05Z" }}">{{ relativeTime .AuthorWhen }}</time></small>
35
+        </div>
36
+      </li>
37
+      {{ end }}
38
+    </ul>
39
+  </section>
40
+  {{ end }}
41
+
42
+  {{ if .DiffHTML }}
43
+  <section class="shithub-diff-body" aria-label="Diff">
44
+    {{ safeHTML .DiffHTML }}
45
+  </section>
46
+  {{ end }}
47
+  {{ end }}
48
+</section>
49
+{{- end }}
internal/web/templates/repo/settings_branches.htmladded
@@ -0,0 +1,71 @@
1
+{{ define "page" -}}
2
+<section class="shithub-settings-branches">
3
+  <header class="shithub-code-head">
4
+    <h1>
5
+      <a href="/{{ .Owner }}/{{ .Repo.Name }}/tree/{{ .Repo.DefaultBranch }}">{{ .Owner }}/{{ .Repo.Name }}</a>
6
+      <span class="shithub-code-sep">/</span>
7
+      Branch protection
8
+    </h1>
9
+  </header>
10
+
11
+  <section class="shithub-danger-zone">
12
+    <h2>Default branch</h2>
13
+    <p>Current: <code>{{ .Repo.DefaultBranch }}</code></p>
14
+    <form method="POST" action="/{{ .Owner }}/{{ .Repo.Name }}/settings/default-branch">
15
+      <input type="hidden" name="csrf_token" value="{{ .CSRFToken }}">
16
+      <label>New default branch
17
+        <select name="default_branch">
18
+          {{ range .Branches }}<option value="{{ .Name }}" {{ if eq .Name $.Repo.DefaultBranch }}selected{{ end }}>{{ .Name }}</option>{{ end }}
19
+        </select>
20
+      </label>
21
+      <button type="submit" class="shithub-button">Update default</button>
22
+    </form>
23
+  </section>
24
+
25
+  <section class="shithub-danger-zone">
26
+    <h2>Protection rules</h2>
27
+    {{ if .Rules }}
28
+    <table class="shithub-branches-table">
29
+      <thead>
30
+        <tr><th>Pattern</th><th>Force-push</th><th>Deletion</th><th>Allowed pushers</th><th></th></tr>
31
+      </thead>
32
+      <tbody>
33
+        {{ range .Rules }}
34
+        <tr>
35
+          <td><code>{{ .Pattern }}</code></td>
36
+          <td>{{ if .PreventForcePush }}🚫{{ else }}allowed{{ end }}</td>
37
+          <td>{{ if .PreventDeletion }}🚫{{ else }}allowed{{ end }}</td>
38
+          <td>{{ len .AllowedPusherUserIds }} {{ if eq (len .AllowedPusherUserIds) 1 }}user{{ else }}users{{ end }}</td>
39
+          <td>
40
+            <form method="POST" action="/{{ $.Owner }}/{{ $.Repo.Name }}/settings/branches/{{ .ID }}/delete" style="display:inline">
41
+              <input type="hidden" name="csrf_token" value="{{ $.CSRFToken }}">
42
+              <button type="submit" class="shithub-button shithub-button-danger">Delete</button>
43
+            </form>
44
+          </td>
45
+        </tr>
46
+        {{ end }}
47
+      </tbody>
48
+    </table>
49
+    {{ else }}
50
+    <p>No rules configured. Add one below to protect a branch pattern.</p>
51
+    {{ end }}
52
+  </section>
53
+
54
+  <section class="shithub-danger-zone">
55
+    <h2>New rule</h2>
56
+    <form method="POST" action="/{{ .Owner }}/{{ .Repo.Name }}/settings/branches">
57
+      <input type="hidden" name="csrf_token" value="{{ .CSRFToken }}">
58
+      <label>Pattern (glob: <code>*</code>, <code>?</code>, <code>[abc]</code>; <code>*</code> doesn't cross <code>/</code>)
59
+        <input type="text" name="pattern" required placeholder="e.g. trunk or release/*">
60
+      </label>
61
+      <label><input type="checkbox" name="prevent_force_push" checked> Prevent force-push</label>
62
+      <label><input type="checkbox" name="prevent_deletion" checked> Prevent deletion</label>
63
+      <label><input type="checkbox" name="require_pr_for_push"> Require PR for push (placeholder; enforced post-MVP)</label>
64
+      <label>Allowed pushers (comma-separated usernames; leave blank for "any collaborator")
65
+        <input type="text" name="allowed_pushers" placeholder="alice, bob">
66
+      </label>
67
+      <button type="submit" class="shithub-button shithub-button-primary">Create rule</button>
68
+    </form>
69
+  </section>
70
+</section>
71
+{{- end }}
internal/web/templates/repo/tags.htmladded
@@ -0,0 +1,31 @@
1
+{{ define "page" -}}
2
+<section class="shithub-tags">
3
+  <header class="shithub-code-head">
4
+    <h1>
5
+      <a href="/{{ .Owner }}/{{ .Repo.Name }}/tree/{{ .Repo.DefaultBranch }}">{{ .Owner }}/{{ .Repo.Name }}</a>
6
+      <span class="shithub-code-sep">/</span>
7
+      Tags
8
+    </h1>
9
+  </header>
10
+  {{ if .Rows }}
11
+  <table class="shithub-branches-table">
12
+    <thead>
13
+      <tr><th>Tag</th><th>Commit</th><th>Subject</th><th>When</th></tr>
14
+    </thead>
15
+    <tbody>
16
+      {{ range .Rows }}
17
+      <tr>
18
+        <td><a href="/{{ $.Owner }}/{{ $.Repo.Name }}/tree/{{ .Name }}"><code>{{ .Name }}</code></a></td>
19
+        <td><a href="/{{ $.Owner }}/{{ $.Repo.Name }}/commit/{{ .OID }}"><code>{{ .ShortOID }}</code></a></td>
20
+        <td>{{ .Subject }}</td>
21
+        <td>{{ if not .AuthorWhen.IsZero }}<time datetime="{{ .AuthorWhen.Format "2006-01-02T15:04:05Z" }}">{{ relativeTime .AuthorWhen }}</time>{{ end }}</td>
22
+      </tr>
23
+      {{ end }}
24
+    </tbody>
25
+  </table>
26
+  {{ else }}
27
+  <p>No tags yet.</p>
28
+  {{ end }}
29
+  <p class="shithub-hint">First-class releases (with notes, assets) ship post-MVP.</p>
30
+</section>
31
+{{- end }}