Commit 875ef13ad2

875ef13ad2716b6001290762eef092da1bab439b

parent: d352b61a43

Verified · cmc ci/build: success ci/quality: success ci/test: success

cmc <hello@cleberg.net> · 2026-11-25 04:52 UTC

web: visual redesign and lightweight progressive JS layer

Layout: unified · split

Changed files (10)
e2e/security_test.go +1 −1
@@ -20,7 +20,7 @@ func TestSecurityHeaders(t *testing.T) {
2020 resp.Body.Close()
2121 h := resp.Header
2222 csp := h.Get("Content-Security-Policy")
23 for _, want := range []string{"script-src 'none'", "frame-ancestors 'none'", "object-src 'none'"} {
23 for _, want := range []string{"script-src 'self'", "frame-ancestors 'none'", "object-src 'none'"} {
2424 if !strings.Contains(csp, want) {
2525 t.Errorf("CSP missing %q: %s", want, csp)
2626 }
internal/httpd/routes.go +2 −1
@@ -45,6 +45,7 @@ func (s *Server) Routes() []Route {
4545 Route{Method: "GET", Pattern: "/healthz", Handler: s.healthz},
4646 Route{Method: "GET", Pattern: "/privacy", Handler: s.privacy},
4747 Route{Method: "GET", Pattern: "/static/style.css", Handler: s.stylesheet},
48 Route{Method: "GET", Pattern: "/static/app.js", Handler: s.appScript},
4849 )
4950 // One literal route per embedded font file: a {name} wildcard is
5051 // ambiguous against /{owner}/{repo}/... patterns in ServeMux precedence,
@@ -312,7 +313,7 @@ func (s *Server) unmatched(mux *http.ServeMux) http.HandlerFunc {
312313// still render; they are the one thing a reader-facing forge can't police
313314// without a proxy.
314315func (s *Server) securityHeaders(next http.Handler) http.Handler {
315 const csp = "default-src 'self'; script-src 'none'; style-src 'self' 'unsafe-inline'; " +
316 const csp = "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; " +
316317 "img-src * data:; object-src 'none'; base-uri 'none'; form-action 'self'; frame-ancestors 'none'"
317318 return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
318319 hd := w.Header()
internal/httpd/web.go +26 −1
@@ -79,7 +79,32 @@ var stylesheetHash = func() string {
7979
8080var stylesheetETag = `"` + stylesheetHash + `"`
8181
82func init() { web.StyleVersion = stylesheetHash }
82var scriptHash = func() string {
83 sum := sha256.Sum256(web.AppJS)
84 return hex.EncodeToString(sum[:])[:16]
85}()
86
87var scriptETag = `"` + scriptHash + `"`
88
89func init() {
90 web.StyleVersion = stylesheetHash
91 web.ScriptVersion = scriptHash
92}
93
94func (s *Server) appScript(w http.ResponseWriter, r *http.Request) {
95 w.Header().Set("ETag", scriptETag)
96 if r.URL.Query().Get("v") == scriptHash {
97 w.Header().Set("Cache-Control", "public, max-age=31536000, immutable")
98 } else {
99 w.Header().Set("Cache-Control", "public, max-age=86400, must-revalidate")
100 }
101 if r.Header.Get("If-None-Match") == scriptETag {
102 w.WriteHeader(http.StatusNotModified)
103 return
104 }
105 w.Header().Set("Content-Type", "text/javascript; charset=utf-8")
106 w.Write(web.AppJS)
107}
83108
84109func (s *Server) stylesheet(w http.ResponseWriter, r *http.Request) {
85110 w.Header().Set("ETag", stylesheetETag)
internal/httpd/webux_test.go +10 −2
@@ -65,7 +65,7 @@ func TestWebUXPickersStatebarAndRailPins(t *testing.T) {
6565 }
6666 }
6767
68 // Issue detail carries clickable label & assignee pickers and datalists.
68 // Issue detail carries popover label & assignee pickers, datalists, and Cmd+K palette.
6969 req = httptest.NewRequest("GET", "/alice/app/issues/1", nil)
7070 req.AddCookie(cookie)
7171 rec = httptest.NewRecorder()
@@ -74,12 +74,20 @@ func TestWebUXPickersStatebarAndRailPins(t *testing.T) {
7474 t.Fatalf("GET /alice/app/issues/1: %d", rec.Code)
7575 }
7676 body = rec.Body.String()
77 for _, want := range []string{`id="repo-labels"`, `id="repo-people"`, `Pick labels`, `Pick assignees`, `class="picker-btn"`} {
77 for _, want := range []string{`id="repo-labels"`, `id="repo-people"`, `class="popover"`, `class="picker-btn"`, `id="cmdk"`, `/static/app.js`} {
7878 if !strings.Contains(body, want) {
7979 t.Errorf("issue page missing %s", want)
8080 }
8181 }
8282
83 // /static/app.js is served with JavaScript content-type.
84 req = httptest.NewRequest("GET", "/static/app.js", nil)
85 rec = httptest.NewRecorder()
86 h.ServeHTTP(rec, req)
87 if rec.Code != http.StatusOK || !strings.Contains(rec.Header().Get("Content-Type"), "javascript") {
88 t.Fatalf("GET /static/app.js: %d %q", rec.Code, rec.Header().Get("Content-Type"))
89 }
90
8391 // Clicking a picker button applies the label.
8492 form := url.Values{"add": {"bug"}}
8593 req = httptest.NewRequest("POST", "https://forge.test/alice/app/issues/1/label", strings.NewReader(form.Encode()))
internal/web/static/app.js added +333
@@ -0,0 +1,333 @@
1// gitbay progressive enhancement: popovers, Cmd+K palette, copy buttons,
2// in-place swaps for reactions/toggles/pickers, inline diff comments, and
3// keyboard shortcuts. Every action degrades cleanly without JS.
4(() => {
5 'use strict';
6
7 const isTyping = (el) => {
8 if (!el) return false;
9 const tag = el.tagName;
10 return tag === 'INPUT' || tag === 'TEXTAREA' || tag === 'SELECT' || el.isContentEditable;
11 };
12
13 // ---- 1. Popover hygiene (close others, click outside, Escape) ----
14 const popovers = () => document.querySelectorAll('details.popover, details.railpins, details.refmenu');
15 document.addEventListener('toggle', (e) => {
16 const d = e.target;
17 if (!(d instanceof HTMLDetailsElement) || !d.open) return;
18 if (!d.matches('details.popover, details.railpins, details.refmenu')) return;
19 for (const other of popovers()) {
20 if (other !== d && other.open) other.open = false;
21 }
22 const input = d.querySelector('input[type="text"], input[type="search"]');
23 if (input) setTimeout(() => input.focus(), 0);
24 }, true);
25
26 document.addEventListener('click', (e) => {
27 for (const d of popovers()) {
28 if (d.open && !d.contains(e.target)) d.open = false;
29 }
30 });
31
32 // ---- 2. Copy buttons on clone blocks ----
33 function initCopyButtons(root = document) {
34 for (const pre of root.querySelectorAll('.clone pre')) {
35 if (pre.dataset.copyWired) continue;
36 pre.dataset.copyWired = '1';
37 const code = pre.querySelector('code');
38 if (!code) continue;
39 const wrap = document.createElement('div');
40 wrap.className = 'copywrap';
41 pre.parentNode.insertBefore(wrap, pre);
42 wrap.appendChild(pre);
43 const btn = document.createElement('button');
44 btn.type = 'button';
45 btn.className = 'copybtn';
46 btn.textContent = 'Copy';
47 btn.setAttribute('aria-label', 'Copy command');
48 btn.addEventListener('click', async () => {
49 try {
50 await navigator.clipboard.writeText(code.textContent.trim());
51 btn.textContent = 'Copied';
52 setTimeout(() => { btn.textContent = 'Copy'; }, 1400);
53 } catch {
54 btn.textContent = 'Failed';
55 setTimeout(() => { btn.textContent = 'Copy'; }, 1400);
56 }
57 });
58 wrap.appendChild(btn);
59 }
60 }
61
62 // ---- 3. In-place fragment swaps (reactions, header toggles, sidebar pickers) ----
63 document.addEventListener('submit', async (e) => {
64 const form = e.target;
65 if (!(form instanceof HTMLFormElement) || form.method.toLowerCase() !== 'post') return;
66 let swapSel = null;
67 if (form.classList.contains('reactions')) {
68 swapSel = 'main#content';
69 } else if (form.closest('.identity')) {
70 swapSel = '.identity';
71 } else if (form.closest('.aside .popover')) {
72 swapSel = '.aside';
73 } else {
74 return;
75 }
76 e.preventDefault();
77 const data = new FormData(form);
78 if (e.submitter && e.submitter.name) {
79 data.append(e.submitter.name, e.submitter.value);
80 }
81 const body = new URLSearchParams(data);
82 try {
83 const res = await fetch(form.action, {
84 method: 'POST',
85 body,
86 headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
87 credentials: 'same-origin',
88 });
89 if (!res.ok) { form.submit(); return; }
90 const html = await res.text();
91 const doc = new DOMParser().parseFromString(html, 'text/html');
92 const next = doc.querySelector(swapSel);
93 const cur = document.querySelector(swapSel);
94 if (next && cur) {
95 cur.replaceWith(next);
96 initCopyButtons(next);
97 } else {
98 location.reload();
99 }
100 } catch {
101 form.submit();
102 }
103 });
104
105 // ---- 4. Inline diff-line comment composer without page reload ----
106 document.addEventListener('click', (e) => {
107 const a = e.target.closest('a.cmt');
108 if (!a) return;
109 const url = new URL(a.href, location.origin);
110 const cpath = url.searchParams.get('cpath');
111 const cline = url.searchParams.get('cline');
112 const cside = url.searchParams.get('cside') || 'new';
113 if (!cpath || !cline) return;
114 const row = a.closest('tr');
115 if (!row) return;
116 e.preventDefault();
117
118 const existing = document.getElementById('inline-compose-row');
119 if (existing) existing.remove();
120
121 const base = url.pathname;
122 const cols = row.closest('table')?.classList.contains('split') ? 4 : 3;
123 const tr = document.createElement('tr');
124 tr.id = 'inline-compose-row';
125 tr.className = 'threadrow';
126 const td = document.createElement('td');
127 td.colSpan = cols;
128
129 const form = document.createElement('form');
130 form.method = 'post';
131 form.action = base + '/diff-comment';
132 form.className = 'thread composing';
133
134 const hidden = (name, val) => {
135 const inp = document.createElement('input');
136 inp.type = 'hidden';
137 inp.name = name;
138 inp.value = val;
139 return inp;
140 };
141 form.append(hidden('path', cpath), hidden('line', cline), hidden('side', cside));
142
143 if (cside !== 'old') {
144 const pRange = document.createElement('p');
145 pRange.className = 'hint';
146 pRange.textContent = `Line ${cline} — use \`\`\`suggestion to propose replacement lines`;
147 form.appendChild(pRange);
148 }
149
150 const pArea = document.createElement('p');
151 const ta = document.createElement('textarea');
152 ta.name = 'body';
153 ta.rows = 3;
154 ta.placeholder = `Comment on ${cpath}:${cline}`;
155 ta.required = true;
156 pArea.appendChild(ta);
157
158 const pAct = document.createElement('p');
159 pAct.className = 'btngroup';
160 const bNow = document.createElement('button');
161 bNow.type = 'submit';
162 bNow.textContent = 'Comment';
163 const bPend = document.createElement('button');
164 bPend.type = 'submit';
165 bPend.name = 'pending';
166 bPend.value = 'on';
167 bPend.className = 'btn';
168 bPend.textContent = 'Add to review';
169 const bCancel = document.createElement('button');
170 bCancel.type = 'button';
171 bCancel.className = 'linklike';
172 bCancel.textContent = 'Cancel';
173 bCancel.addEventListener('click', () => tr.remove());
174 pAct.append(bNow, bPend, bCancel);
175
176 form.append(pArea, pAct);
177 td.appendChild(form);
178 tr.appendChild(td);
179 row.insertAdjacentElement('afterend', tr);
180 ta.focus();
181 });
182
183 // ---- 5. Cmd+K Command Palette ----
184 function collectCommands() {
185 const items = [];
186 const seen = new Set();
187 const add = (group, label, href) => {
188 if (!href || seen.has(href)) return;
189 seen.add(href);
190 items.push({ group, label, href });
191 };
192 for (const a of document.querySelectorAll('nav.tabs a')) {
193 add('Repository', a.textContent.trim().replace(/\s+/g, ' '), a.getAttribute('href'));
194 }
195 for (const a of document.querySelectorAll('.railpins .raildrop a')) {
196 add('Pinned', a.textContent.trim(), a.getAttribute('href'));
197 }
198 add('Navigate', 'Dashboard', '/');
199 add('Navigate', 'Explore repositories', '/explore');
200 add('Navigate', 'Global search', '/search');
201 add('Navigate', 'Notifications', '/notifications');
202 add('Navigate', 'New repository', '/new');
203 add('Navigate', 'Account settings', '/settings');
204 return items;
205 }
206
207 function openPalette() {
208 const dlg = document.getElementById('cmdk');
209 if (!(dlg instanceof HTMLDialogElement)) return;
210 const input = dlg.querySelector('input');
211 const list = dlg.querySelector('ul');
212 const all = collectCommands();
213 let active = 0;
214
215 const render = () => {
216 const q = input.value.trim().toLowerCase();
217 const filtered = q ? all.filter((it) => (it.label + ' ' + it.group).toLowerCase().includes(q)) : all;
218 active = Math.min(active, Math.max(0, filtered.length - 1));
219 list.textContent = '';
220 if (filtered.length === 0) {
221 const li = document.createElement('li');
222 li.className = 'cmdk-empty';
223 li.textContent = 'No matching destinations';
224 list.appendChild(li);
225 return;
226 }
227 filtered.forEach((it, idx) => {
228 const li = document.createElement('li');
229 const a = document.createElement('a');
230 a.href = it.href;
231 if (idx === active) a.setAttribute('aria-selected', 'true');
232 const g = document.createElement('span');
233 g.className = 'cmdk-grp';
234 g.textContent = it.group;
235 const t = document.createElement('span');
236 t.textContent = it.label;
237 a.append(g, t);
238 li.appendChild(a);
239 list.appendChild(li);
240 });
241 };
242
243 input.value = '';
244 render();
245 if (!dlg.open) dlg.showModal();
246 input.focus();
247
248 input.oninput = () => { active = 0; render(); };
249 input.onkeydown = (ev) => {
250 const links = list.querySelectorAll('a');
251 if (ev.key === 'ArrowDown') {
252 ev.preventDefault();
253 if (links.length) { active = (active + 1) % links.length; render(); }
254 } else if (ev.key === 'ArrowUp') {
255 ev.preventDefault();
256 if (links.length) { active = (active - 1 + links.length) % links.length; render(); }
257 } else if (ev.key === 'Enter') {
258 const sel = links[active];
259 if (sel) { ev.preventDefault(); location.href = sel.href; }
260 }
261 };
262 }
263
264 document.addEventListener('click', (e) => {
265 if (e.target.closest('.cmdk-trigger')) {
266 e.preventDefault();
267 openPalette();
268 return;
269 }
270 const dlg = document.getElementById('cmdk');
271 if (dlg && e.target === dlg) dlg.close();
272 });
273
274 // ---- 6. Keyboard shortcuts ----
275 let chord = '';
276 let chordTimer = 0;
277 document.addEventListener('keydown', (e) => {
278 if (e.key === 'Escape') {
279 for (const d of popovers()) if (d.open) d.open = false;
280 const inline = document.getElementById('inline-compose-row');
281 if (inline) inline.remove();
282 return;
283 }
284 if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === 'k') {
285 e.preventDefault();
286 openPalette();
287 return;
288 }
289 if (isTyping(e.target) || e.metaKey || e.ctrlKey || e.altKey) return;
290
291 if (e.key === '/') {
292 const search = document.querySelector('main input[type="search"]');
293 if (search) { e.preventDefault(); search.focus(); return; }
294 e.preventDefault();
295 openPalette();
296 return;
297 }
298
299 if (chord === 'g') {
300 clearTimeout(chordTimer);
301 chord = '';
302 const tabLink = (match) => {
303 for (const a of document.querySelectorAll('nav.tabs a')) {
304 if (a.textContent.trim().toLowerCase().startsWith(match)) return a.href;
305 }
306 return null;
307 };
308 const dest = {
309 d: '/',
310 e: '/explore',
311 n: '/notifications',
312 c: tabLink('code'),
313 i: tabLink('issues'),
314 m: tabLink('merge'),
315 b: tabLink('builds'),
316 r: tabLink('releases'),
317 w: tabLink('wiki'),
318 }[e.key.toLowerCase()];
319 if (dest) { e.preventDefault(); location.href = dest; }
320 return;
321 }
322 if (e.key === 'g') {
323 chord = 'g';
324 chordTimer = setTimeout(() => { chord = ''; }, 900);
325 }
326 });
327
328 if (document.readyState === 'loading') {
329 document.addEventListener('DOMContentLoaded', () => initCopyButtons());
330 } else {
331 initCopyButtons();
332 }
333})();
internal/web/static/style.css +161 −17
@@ -69,12 +69,12 @@
6969 --diff-add: #e4f6ea;
7070 --diff-del: #fdeaea;
7171
72 /* the rail is black in both schemes: the one brand constant */
73 --shell-bg: #000000;
72 /* the rail is dark slate in both schemes: the one brand constant */
73 --shell-bg: #111318;
7474 --shell-fg: #f2f2f2;
75 --shell-muted: #8f8f8f;
76 --shell-line: #1c1c1c;
77 --shell-hover: #141414;
75 --shell-muted: #98a0ad;
76 --shell-line: #232730;
77 --shell-hover: #1c2029;
7878 --shell-mark: #ff6b3d;
7979
8080 /* the languages' own colours; the same in both schemes */
@@ -168,11 +168,11 @@
168168 --diff-add: #0d2a18;
169169 --diff-del: #2c1113;
170170
171 --shell-bg: #000000;
171 --shell-bg: #111318;
172172 --shell-fg: #f2f2f2;
173 --shell-muted: #8f8f8f;
174 --shell-line: #1c1c1c;
175 --shell-hover: #141414;
173 --shell-muted: #98a0ad;
174 --shell-line: #232730;
175 --shell-hover: #1c2029;
176176 --shell-mark: #ff6b3d;
177177
178178 /* the languages' own colours; the same in both schemes */
@@ -446,8 +446,9 @@ footer a:hover { color: var(--link); }
446446
447447/* ---- repository header ---- */
448448.repohead {
449 padding: var(--sp-4) 0 0;
450 border-bottom: 1px solid var(--line);
449 padding: var(--sp-5) 0 0;
450 border-bottom: 1px solid var(--faint);
451 background: var(--canvas);
451452}
452453.repohead .wrap { max-width: calc(var(--container) + 2 * var(--sp-6)); margin: 0 auto; padding: 0 var(--sp-6); }
453454.identity { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
@@ -827,11 +828,11 @@ ul.plain li > form:first-of-type { margin-left: auto; }
827828.notice { border-left-color: var(--ok); background: color-mix(in srgb, var(--ok) 6%, transparent); }
828829.empty-note, .none, .empty, li.empty, td.empty { color: var(--muted); }
829830
830/* ---- containers: one recipe for cards, lists and tables ---- */
831/* ---- containers: calm hairline borders and clean surfaces ---- */
831832.card, ul.list, ul.loglist, ul.repolist, ul.issuelist,
832833ul.milestonelist, .readme, .code, article.release, .blame, .teambody {
833 background: var(--surface);
834 border: 1px solid var(--line);
834 background: var(--canvas);
835 border: 1px solid var(--faint);
835836 border-radius: var(--r-card);
836837 overflow: hidden;
837838}
@@ -840,7 +841,8 @@ ul.milestonelist, .readme, .code, article.release, .blame, .teambody {
840841 align-items: center;
841842 gap: var(--sp-3);
842843 padding: var(--sp-2) var(--sp-4);
843 border-bottom: 1px solid var(--line);
844 background: var(--surface);
845 border-bottom: 1px solid var(--faint);
844846 font-size: var(--fs-1);
845847 color: var(--muted);
846848}
@@ -874,8 +876,8 @@ tr.cols th.age, tr.cols th.size { text-align: right; }
874876.tablewrap { overflow-x: auto; max-width: 100%; }
875877
876878table.tree, table.refs {
877 background: var(--surface);
878 border: 1px solid var(--line);
879 background: var(--canvas);
880 border: 1px solid var(--faint);
879881 border-radius: var(--r-card);
880882 /* collapsed borders defeat a radius on the table itself */
881883 border-collapse: separate;
@@ -2061,3 +2063,145 @@ button.react.mine { border-color: var(--accent); background: var(--surface); col
20612063 font-weight: 600;
20622064 background: var(--surface);
20632065}
2066
2067/* ---- sidebar group headers & floating popovers ---- */
2068.grp-head {
2069 display: flex;
2070 align-items: center;
2071 justify-content: space-between;
2072 gap: var(--sp-2);
2073 margin-bottom: var(--sp-2);
2074}
2075.grp-head h2 { margin: 0; }
2076.popover { position: relative; }
2077.popover > summary { list-style: none; }
2078.popover > summary::-webkit-details-marker { display: none; }
2079.popbtn {
2080 display: inline-flex;
2081 align-items: center;
2082 padding: 2px var(--sp-2);
2083 border-radius: var(--r-ctl);
2084 font-size: var(--fs-0);
2085 font-weight: 500;
2086 color: var(--muted);
2087 cursor: pointer;
2088}
2089.popbtn:hover, .popover[open] > .popbtn { background: var(--hover); color: var(--fg); }
2090.popmenu {
2091 position: absolute;
2092 right: 0;
2093 top: calc(100% + var(--sp-1));
2094 z-index: 30;
2095 width: 16rem;
2096 max-width: 85vw;
2097 padding: var(--sp-3);
2098 background: var(--canvas);
2099 border: 1px solid var(--faint);
2100 border-radius: var(--r-card);
2101 box-shadow: var(--shadow);
2102 display: flex;
2103 flex-direction: column;
2104 gap: var(--sp-2);
2105}
2106.popform {
2107 display: flex;
2108 gap: var(--sp-2);
2109 align-items: center;
2110 margin: 0;
2111}
2112.popform input[type="text"], .popform select { flex: 1; min-width: 0; }
2113
2114/* ---- Cmd+K trigger & command palette ---- */
2115.cmdk-trigger {
2116 display: inline-flex;
2117 align-items: center;
2118 gap: var(--sp-3);
2119 height: 30px;
2120 margin-left: var(--sp-2);
2121 padding: 0 var(--sp-3);
2122 border: 1px solid var(--shell-line);
2123 border-radius: var(--r-ctl);
2124 background: var(--shell-hover);
2125 color: var(--shell-muted);
2126 font-size: var(--fs-1);
2127 font-weight: 400;
2128 cursor: pointer;
2129}
2130.cmdk-trigger:hover { color: var(--shell-fg); border-color: var(--shell-muted); filter: none; }
2131.cmdk-trigger kbd {
2132 font-family: var(--mono);
2133 font-size: var(--fs-0);
2134 padding: 1px 5px;
2135 border: 1px solid var(--shell-line);
2136 border-radius: var(--r-ctl);
2137 color: var(--shell-muted);
2138}
2139dialog.cmdk {
2140 padding: 0;
2141 border: 1px solid var(--faint);
2142 border-radius: var(--r-card);
2143 background: var(--canvas);
2144 color: var(--fg);
2145 box-shadow: var(--shadow);
2146 width: min(34rem, 92vw);
2147 margin: 12vh auto auto;
2148}
2149dialog.cmdk::backdrop { background: rgb(0 0 0 / 0.45); }
2150.cmdk-box { display: flex; flex-direction: column; }
2151.cmdk-box input[type="search"] {
2152 width: 100%;
2153 height: 44px;
2154 padding: 0 var(--sp-4);
2155 border: 0;
2156 border-bottom: 1px solid var(--faint);
2157 border-radius: 0;
2158 background: transparent;
2159 font-size: var(--fs-3);
2160}
2161.cmdk-box input[type="search"]:focus { outline: none; }
2162.cmdk-list {
2163 list-style: none;
2164 margin: 0;
2165 padding: var(--sp-2);
2166 max-height: 22rem;
2167 overflow-y: auto;
2168}
2169.cmdk-list a {
2170 display: flex;
2171 align-items: center;
2172 gap: var(--sp-3);
2173 padding: var(--sp-2) var(--sp-3);
2174 border-radius: var(--r-ctl);
2175 color: var(--fg);
2176 text-decoration: none;
2177 font-size: var(--fs-2);
2178}
2179.cmdk-list a:hover, .cmdk-list a[aria-selected="true"] { background: var(--hover); }
2180.cmdk-grp {
2181 font-size: var(--fs-0);
2182 color: var(--muted);
2183 min-width: 5.5rem;
2184}
2185.cmdk-empty { padding: var(--sp-4); color: var(--muted); text-align: center; font-size: var(--fs-2); }
2186
2187/* ---- copy button on clone blocks ---- */
2188.copywrap { position: relative; }
2189.copywrap pre { padding-right: 4.5rem; }
2190.copybtn {
2191 position: absolute;
2192 top: 50%;
2193 right: var(--sp-2);
2194 transform: translateY(-50%);
2195 height: 24px;
2196 padding: 0 var(--sp-2);
2197 font-size: var(--fs-0);
2198 background: var(--surface);
2199 color: var(--fg);
2200 border: 1px solid var(--faint);
2201 border-radius: var(--r-ctl);
2202}
2203.copybtn:hover { background: var(--hover); filter: none; }
2204
2205@media (max-width: 34rem) {
2206 .cmdk-trigger { display: none; }
2207}
internal/web/templates/issue.html +45 −46
@@ -43,62 +43,61 @@
4343
4444{{$base := printf "/%s/%s/issues/%d" .Repo.OwnerName .Repo.Name .Issue.Number}}
4545<aside class="aside">
46 {{if .CanEdit}}
4746 <div class="grp">
48 <h2>State</h2>
49 <form method="post" action="{{$base}}/state" class="actions">
50 {{if eq .Issue.State "open"}}<button type="submit" name="action" value="close">Close issue</button>
51 {{else}}<button type="submit" name="action" value="reopen">Reopen issue</button>{{end}}
52 </form>
53 </div>
54 {{end}}
55 <div class="grp">
56 <h2>Labels</h2>
47 <div class="grp-head">
48 <h2>Labels</h2>
49 {{if .CanWrite}}<details class="popover"><summary class="popbtn">Edit</summary><div class="popmenu">
50 {{with field . "AllLabels"}}<div class="picker-list">{{range .}}<form method="post" action="{{$base}}/label" class="inline">{{if hasStr $.Issue.Labels .Name}}<input type="hidden" name="remove" value="{{.Name}}"><button type="submit" class="picker-btn" aria-pressed="true">{{.Name}} ×</button>{{else}}<input type="hidden" name="add" value="{{.Name}}"><button type="submit" class="picker-btn" aria-pressed="false">{{.Name}}</button>{{end}}</form>{{end}}</div>
51 <datalist id="repo-labels">{{range .}}<option value="{{.Name}}"></option>{{end}}</datalist>{{end}}
52 <form method="post" action="{{$base}}/label" class="popform">
53 <input type="text" name="add" aria-label="Add labels" list="repo-labels" autocomplete="off" spellcheck="false" placeholder="Add label…">
54 <button type="submit" class="btn">Add</button>
55 </form>
56 </div></details>{{end}}
57 </div>
5758 {{if .Issue.Labels}}<p class="row">{{range .Issue.Labels}}<a class="chip label" style="{{index $.LabelColors .}}" href="/{{$.Repo.OwnerName}}/{{$.Repo.Name}}/issues?label={{.}}">{{.}}</a> {{end}}</p>
58 {{else}}<p class="none">none yet</p>{{end}}
59 {{if .CanWrite}}
60 {{with field . "AllLabels"}}<details class="picker"><summary>Pick labels</summary>
61 <div class="picker-list">{{range .}}<form method="post" action="{{$base}}/label" class="inline">{{if hasStr $.Issue.Labels .Name}}<input type="hidden" name="remove" value="{{.Name}}"><button type="submit" class="picker-btn" aria-pressed="true">{{.Name}} ×</button>{{else}}<input type="hidden" name="add" value="{{.Name}}"><button type="submit" class="picker-btn" aria-pressed="false">{{.Name}}</button>{{end}}</form>{{end}}</div>
62 </details>
63 <datalist id="repo-labels">{{range .}}<option value="{{.Name}}"></option>{{end}}</datalist>{{end}}
64 <form method="post" action="{{$base}}/label" class="actions">
65 <input type="text" name="add" aria-label="Add labels" list="repo-labels" autocomplete="off" spellcheck="false" placeholder="add, space-separated">
66 <input type="text" name="remove" aria-label="Remove labels" list="repo-labels" autocomplete="off" spellcheck="false" placeholder="remove">
67 <button type="submit" class="btn">Apply</button>
68 </form>
69 {{end}}
59 {{else}}<p class="none">None</p>{{end}}
7060 </div>
7161 <div class="grp">
72 <h2>Assignees</h2>
62 <div class="grp-head">
63 <h2>Assignees</h2>
64 {{if .CanWrite}}<details class="popover"><summary class="popbtn">Edit</summary><div class="popmenu">
65 {{with field . "People"}}<div class="picker-list">{{range .}}<form method="post" action="{{$base}}/assign" class="inline">{{if hasStr $.Issue.Assignees .}}<input type="hidden" name="remove" value="{{.}}"><button type="submit" class="picker-btn" aria-pressed="true">{{.}} ×</button>{{else}}<input type="hidden" name="add" value="{{.}}"><button type="submit" class="picker-btn" aria-pressed="false">{{.}}</button>{{end}}</form>{{end}}</div>
66 <datalist id="repo-people">{{range .}}<option value="{{.}}"></option>{{end}}</datalist>{{end}}
67 <form method="post" action="{{$base}}/assign" class="popform">
68 <input type="text" name="add" aria-label="Add assignees" list="repo-people" autocomplete="off" spellcheck="false" placeholder="Add username…">
69 <button type="submit" class="btn">Add</button>
70 </form>
71 </div></details>{{end}}
72 </div>
7373 {{if .Issue.Assignees}}<p class="row">{{range .Issue.Assignees}}<a href="/{{.}}">{{.}}</a> {{end}}</p>
74 {{else}}<p class="none">nobody yet</p>{{end}}
75 {{if .CanWrite}}
76 {{with field . "People"}}<details class="picker"><summary>Pick assignees</summary>
77 <div class="picker-list">{{range .}}<form method="post" action="{{$base}}/assign" class="inline">{{if hasStr $.Issue.Assignees .}}<input type="hidden" name="remove" value="{{.}}"><button type="submit" class="picker-btn" aria-pressed="true">{{.}} ×</button>{{else}}<input type="hidden" name="add" value="{{.}}"><button type="submit" class="picker-btn" aria-pressed="false">{{.}}</button>{{end}}</form>{{end}}</div>
78 </details>
79 <datalist id="repo-people">{{range .}}<option value="{{.}}"></option>{{end}}</datalist>{{end}}
80 <form method="post" action="{{$base}}/assign" class="actions">
81 <input type="text" name="add" aria-label="Add assignees" list="repo-people" autocomplete="off" spellcheck="false" placeholder="add, space-separated">
82 <input type="text" name="remove" aria-label="Remove assignees" list="repo-people" autocomplete="off" spellcheck="false" placeholder="remove">
83 <button type="submit" class="btn">Apply</button>
84 </form>
85 {{end}}
74 {{else}}<p class="none">Unassigned</p>{{end}}
8675 </div>
8776 <div class="grp">
88 <h2>Milestone</h2>
77 <div class="grp-head">
78 <h2>Milestone</h2>
79 {{if .CanWrite}}<details class="popover"><summary class="popbtn">Edit</summary><div class="popmenu">
80 <form method="post" action="{{$base}}/milestone" class="popform">
81 <label class="vh" for="milestone">Set milestone</label>
82 <select id="milestone" name="milestone">
83 <option value="none">No milestone</option>
84 {{range .Milestones}}<option value="{{.Title}}"{{if eq .Title $.Issue.Milestone}} selected{{end}}>{{.Title}}</option>{{end}}
85 </select>
86 <button type="submit" class="btn">Save</button>
87 </form>
88 </div></details>{{end}}
89 </div>
8990 {{if .Issue.Milestone}}<p class="row"><a href="/{{.Repo.OwnerName}}/{{.Repo.Name}}/milestones">{{.Issue.Milestone}}</a></p>
90 {{else}}<p class="none">none yet</p>{{end}}
91 {{if .CanWrite}}
92 <form method="post" action="{{$base}}/milestone" class="actions">
93 <label class="none" for="milestone">Set milestone</label>
94 <select id="milestone" name="milestone">
95 <option value="none">No milestone</option>
96 {{range .Milestones}}<option value="{{.Title}}"{{if eq .Title $.Issue.Milestone}} selected{{end}}>{{.Title}}</option>{{end}}
97 </select>
98 <button type="submit" class="btn">Apply</button>
91 {{else}}<p class="none">None</p>{{end}}
92 </div>
93 {{if .CanEdit}}
94 <div class="grp">
95 <form method="post" action="{{$base}}/state" class="actions">
96 {{if eq .Issue.State "open"}}<button type="submit" name="action" value="close" class="btn">Close issue</button>
97 {{else}}<button type="submit" name="action" value="reopen" class="btn">Reopen issue</button>{{end}}
9998 </form>
100 {{end}}
10199 </div>
100 {{end}}
102101</aside>
103102</div>
104103{{end}}
internal/web/templates/layout.html +8
@@ -5,6 +5,7 @@
55<meta name="viewport" content="width=device-width, initial-scale=1">
66<title>{{template "title" .}}</title>
77<link rel="stylesheet" href="/static/style.css?v={{styleVersion}}">
8<script src="/static/app.js?v={{scriptVersion}}" defer></script>
89<link rel="icon" href="/favicon.svg" type="image/svg+xml">
910<meta name="theme-color" content="#000000">
1011{{with field . "Feed"}}<link rel="alternate" type="application/atom+xml" href="{{.}}">
@@ -28,6 +29,7 @@
2829 <li class="railopt"><details class="railpins"><summary class="railicon" aria-label="Pinned repositories" title="Pinned repositories">{{template "icon" "bookmark"}}<span class="vh">Pinned repositories</span></summary><div class="raildrop">{{range .Rail.Pins}}<a href="/{{.Owner}}/{{.Name}}">{{.Owner}}/{{.Name}}</a>{{else}}<span class="none">No pinned repos</span>{{end}}<a href="/{{.Viewer}}/-/repositories">All repositories →</a></div></details></li>
2930 <li class="railopt">{{template "raillink" (index $items 0)}}</li>{{end}}
3031 </ul>
32 <button type="button" class="cmdk-trigger" aria-label="Jump to"><span>Jump to…</span><kbd>⌘K</kbd></button>
3133 <span class="railgap"></span>
3234 <ul class="raillist">
3335 {{if .Viewer}}<li class="railopt">{{template "raillink" (index $items 1)}}</li>
@@ -93,6 +95,12 @@
9395</footer>
9496</div>
9597</div>
98<dialog id="cmdk" class="cmdk" aria-label="Jump to">
99 <div class="cmdk-box">
100 <input type="search" aria-label="Filter destinations" placeholder="Jump to repository, tab, or page…">
101 <ul class="cmdk-list"></ul>
102 </div>
103</dialog>
96104</body>
97105</html>{{end}}
98106
internal/web/templates/mr.html +46 −42
@@ -123,12 +123,16 @@
123123 {{end}}
124124 {{if and .CanEdit (or (eq .MR.State "open") (eq .MR.State "source_gone"))}}
125125 <div class="grp">
126 <h2>State</h2>
127 <form method="post" action="{{$base}}/close" class="actions">
128 <label class="vh" for="by">Closed in favour of</label>
129 <input type="text" id="by" name="by" size="4" autocomplete="off" placeholder="!N">
130 <button type="submit" class="danger">Close without merging</button>
131 </form>
126 <div class="grp-head">
127 <h2>State</h2>
128 <details class="popover"><summary class="popbtn">Close…</summary><div class="popmenu">
129 <form method="post" action="{{$base}}/close" class="popform">
130 <label class="vh" for="by">Closed in favour of</label>
131 <input type="text" id="by" name="by" size="6" autocomplete="off" placeholder="Superseded by !N">
132 <button type="submit" class="danger">Close without merging</button>
133 </form>
134 </div></details>
135 </div>
132136 <form method="post" action="{{$base}}/draft" class="actions">
133137 {{if .MR.Draft}}<button type="submit" class="btn">Ready for review</button>
134138 {{else}}<input type="hidden" name="draft" value="on"><button type="submit" class="btn">Convert to draft</button>{{end}}
@@ -161,55 +165,55 @@
161165 {{end}}
162166 </div>{{end}}
163167 <div class="grp">
164 <h2>Reviewers</h2>
168 <div class="grp-head">
169 <h2>Reviewers</h2>
170 {{if and .CanWrite (or (eq .MR.State "open") (eq .MR.State "source_gone"))}}<details class="popover"><summary class="popbtn">Edit</summary><div class="popmenu">
171 {{with field . "People"}}<div class="picker-list">{{range .}}<form method="post" action="{{$base}}/review-request" class="inline">{{if hasStr $.MR.ReviewRequests .}}<input type="hidden" name="remove" value="{{.}}"><button type="submit" class="picker-btn" aria-pressed="true">{{.}} ×</button>{{else}}<input type="hidden" name="add" value="{{.}}"><button type="submit" class="picker-btn" aria-pressed="false">{{.}}</button>{{end}}</form>{{end}}</div>
172 <datalist id="repo-people">{{range .}}<option value="{{.}}"></option>{{end}}</datalist>{{end}}
173 <form method="post" action="{{$base}}/review-request" class="popform">
174 <input type="text" name="add" aria-label="Add reviewers" list="repo-people" autocomplete="off" spellcheck="false" placeholder="Add username…">
175 <button type="submit" class="btn">Add</button>
176 </form>
177 </div></details>{{end}}
178 </div>
165179 {{if .MR.ReviewRequests}}<p class="row">{{range .MR.ReviewRequests}}<a href="/{{.}}">{{.}}</a> {{end}}</p>
166180 {{else}}<p class="none">no reviewers</p>{{end}}
167 {{if and .CanWrite (or (eq .MR.State "open") (eq .MR.State "source_gone"))}}
168 {{with field . "People"}}<details class="picker"><summary>Pick reviewers</summary>
169 <div class="picker-list">{{range .}}<form method="post" action="{{$base}}/review-request" class="inline">{{if hasStr $.MR.ReviewRequests .}}<input type="hidden" name="remove" value="{{.}}"><button type="submit" class="picker-btn" aria-pressed="true">{{.}} ×</button>{{else}}<input type="hidden" name="add" value="{{.}}"><button type="submit" class="picker-btn" aria-pressed="false">{{.}}</button>{{end}}</form>{{end}}</div>
170 </details>
171 <datalist id="repo-people">{{range .}}<option value="{{.}}"></option>{{end}}</datalist>{{end}}
172 <form method="post" action="{{$base}}/review-request" class="actions">
173 <input type="text" name="add" aria-label="Add reviewers" list="repo-people" autocomplete="off" spellcheck="false" placeholder="add, space-separated">
174 <input type="text" name="remove" aria-label="Remove reviewers" list="repo-people" autocomplete="off" spellcheck="false" placeholder="remove">
175 <button type="submit" class="btn">Apply</button>
176 </form>
177 {{end}}
178181 </div>
179182 <div class="grp">
180 <h2>Source and target</h2>
181 <p class="row"><code>{{if .MR.SourcePath}}{{.MR.SourcePath}}:{{end}}{{.MR.SourceRef}}</code> into <code>{{.MR.TargetRef}}</code></p>
183 <div class="grp-head">
184 <h2>Branches</h2>
185 {{if and .CanEdit (or (eq .MR.State "open") (eq .MR.State "source_gone"))}}<details class="popover"><summary class="popbtn">Retarget</summary><div class="popmenu">
186 <form method="post" action="{{$base}}/retarget" class="popform">
187 <label class="vh" for="target">Branch</label>
188 <select id="target" name="target">
189 {{range .Branches}}<option value="{{.Name}}"{{if eq .Name $.MR.TargetRef}} selected{{end}}>{{.Name}}</option>{{end}}
190 </select>
191 <button type="submit" class="btn">Save</button>
192 </form>
193 <p class="hint">Retargeting stales existing reviews.</p>
194 </div></details>{{end}}
195 </div>
196 <p class="row"><code>{{if .MR.SourcePath}}{{.MR.SourcePath}}:{{end}}{{.MR.SourceRef}}</code> → <code>{{.MR.TargetRef}}</code></p>
182197 <p class="row none">{{if eq .MR.State "merged"}}merged at{{else}}head{{end}} <code>{{short .MR.HeadSHA}}</code>{{if .Base}} · base <code>{{short .Base}}</code>{{end}}{{if .SourceGone}} · <span class="chip chip-neutral">branch deleted</span>{{end}}</p>
183 {{if and .CanEdit (or (eq .MR.State "open") (eq .MR.State "source_gone"))}}
184 <form method="post" action="{{$base}}/retarget" class="actions">
185 <label class="none" for="target">Branch</label>
186 <select id="target" name="target">
187 {{range .Branches}}<option value="{{.Name}}"{{if eq .Name $.MR.TargetRef}} selected{{end}}>{{.Name}}</option>{{end}}
188 </select>
189 <button type="submit" class="btn">Retarget</button>
190 </form>
191 <p class="row none">Retargeting stales existing reviews.</p>
192 {{end}}
193198 </div>
194199 {{if .MR.Milestone}}<div class="grp">
195200 <h2>Milestone</h2>
196201 <p class="row"><a href="/{{.Repo.OwnerName}}/{{.Repo.Name}}/milestones">{{.MR.Milestone}}</a></p>
197202 </div>{{end}}
198203 <div class="grp">
199 <h2>Labels</h2>
204 <div class="grp-head">
205 <h2>Labels</h2>
206 {{if .CanWrite}}<details class="popover"><summary class="popbtn">Edit</summary><div class="popmenu">
207 {{with field . "AllLabels"}}<div class="picker-list">{{range .}}<form method="post" action="{{$base}}/label" class="inline">{{if hasStr $.MR.Labels .Name}}<input type="hidden" name="remove" value="{{.Name}}"><button type="submit" class="picker-btn" aria-pressed="true">{{.Name}} ×</button>{{else}}<input type="hidden" name="add" value="{{.Name}}"><button type="submit" class="picker-btn" aria-pressed="false">{{.Name}}</button>{{end}}</form>{{end}}</div>
208 <datalist id="repo-labels">{{range .}}<option value="{{.Name}}"></option>{{end}}</datalist>{{end}}
209 <form method="post" action="{{$base}}/label" class="popform">
210 <input type="text" name="add" aria-label="Add labels" list="repo-labels" autocomplete="off" spellcheck="false" placeholder="Add label…">
211 <button type="submit" class="btn">Add</button>
212 </form>
213 </div></details>{{end}}
214 </div>
200215 {{if .MR.Labels}}<p class="row">{{range .MR.Labels}}<a class="chip label" style="{{index $.LabelColors .}}" href="/{{$.Repo.OwnerName}}/{{$.Repo.Name}}/mrs?label={{.}}">{{.}}</a> {{end}}</p>
201216 {{else}}<p class="none">{{if or (eq .MR.State "merged") (eq .MR.State "closed")}}no labels{{else}}none yet{{end}}</p>{{end}}
202 {{if .CanWrite}}
203 {{with field . "AllLabels"}}<details class="picker"><summary>Pick labels</summary>
204 <div class="picker-list">{{range .}}<form method="post" action="{{$base}}/label" class="inline">{{if hasStr $.MR.Labels .Name}}<input type="hidden" name="remove" value="{{.Name}}"><button type="submit" class="picker-btn" aria-pressed="true">{{.Name}} ×</button>{{else}}<input type="hidden" name="add" value="{{.Name}}"><button type="submit" class="picker-btn" aria-pressed="false">{{.Name}}</button>{{end}}</form>{{end}}</div>
205 </details>
206 <datalist id="repo-labels">{{range .}}<option value="{{.Name}}"></option>{{end}}</datalist>{{end}}
207 <form method="post" action="{{$base}}/label" class="actions">
208 <input type="text" name="add" aria-label="Add labels" list="repo-labels" autocomplete="off" spellcheck="false" placeholder="add, space-separated">
209 <input type="text" name="remove" aria-label="Remove labels" list="repo-labels" autocomplete="off" spellcheck="false" placeholder="remove">
210 <button type="submit" class="btn">Apply</button>
211 </form>
212 {{end}}
213217 </div>
214218</aside>
215219</div>
internal/web/web.go +11 −6
@@ -22,6 +22,9 @@ var templateFS embed.FS
2222//go:embed static/style.css
2323var StyleCSS []byte
2424
25//go:embed static/app.js
26var AppJS []byte
27
2528//go:embed static/favicon.svg
2629var FaviconSVG []byte
2730
@@ -31,10 +34,11 @@ var FontFS embed.FS
3134//go:embed static/img/*.gif static/img/*.webm static/img/*.mp4
3235var ImageFS embed.FS
3336
34// StyleVersion identifies the bytes /static/style.css serves. The httpd
35// package sets it; the layout stamps it on the stylesheet URL so a deploy
36// changes that URL and a browser holding a cached copy cannot miss it.
37// StyleVersion and ScriptVersion identify the bytes /static/style.css and
38// /static/app.js serve. The httpd package sets them so a deploy busts
39// browser caches automatically.
3740var StyleVersion string
41var ScriptVersion string
3842
3943// railItem is one destination the rail's icon strip and the phone
4044// "More" menu both render — from this one list, so a destination added
@@ -96,9 +100,10 @@ func railOptItems(v any) []railItem {
96100}
97101
98102var funcs = template.FuncMap{
99 "styleVersion": func() string { return StyleVersion },
100 "join": strings.Join,
101 "hasStr": slices.Contains[[]string, string],
103 "styleVersion": func() string { return StyleVersion },
104 "scriptVersion": func() string { return ScriptVersion },
105 "join": strings.Join,
106 "hasStr": slices.Contains[[]string, string],
102107 // paragraphs splits plain text on blank lines for safe rich display.
103108 "paragraphs": func(s string) []string {
104109 var out []string