Commit 875ef13ad2
Verified · cmc ci/build: success ci/quality: success ci/test: success
Layout: unified · split
Changed files (10)
- e2e/security_test.go +1 −1
- internal/httpd/routes.go +2 −1
- internal/httpd/web.go +26 −1
- internal/httpd/webux_test.go +10 −2
- internal/web/static/app.js added +333
- internal/web/static/style.css +161 −17
- internal/web/templates/issue.html +45 −46
- internal/web/templates/layout.html +8
- internal/web/templates/mr.html +46 −42
- internal/web/web.go +11 −6
e2e/security_test.go +1 −1
| @@ -20,7 +20,7 @@ func TestSecurityHeaders(t *testing.T) { | ||
| 20 | 20 | resp.Body.Close() |
| 21 | 21 | h := resp.Header |
| 22 | 22 | 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'"} { | |
| 24 | 24 | if !strings.Contains(csp, want) { |
| 25 | 25 | t.Errorf("CSP missing %q: %s", want, csp) |
| 26 | 26 | } |
internal/httpd/routes.go +2 −1
| @@ -45,6 +45,7 @@ func (s *Server) Routes() []Route { | ||
| 45 | 45 | Route{Method: "GET", Pattern: "/healthz", Handler: s.healthz}, |
| 46 | 46 | Route{Method: "GET", Pattern: "/privacy", Handler: s.privacy}, |
| 47 | 47 | Route{Method: "GET", Pattern: "/static/style.css", Handler: s.stylesheet}, |
| 48 | Route{Method: "GET", Pattern: "/static/app.js", Handler: s.appScript}, | |
| 48 | 49 | ) |
| 49 | 50 | // One literal route per embedded font file: a {name} wildcard is |
| 50 | 51 | // ambiguous against /{owner}/{repo}/... patterns in ServeMux precedence, |
| @@ -312,7 +313,7 @@ func (s *Server) unmatched(mux *http.ServeMux) http.HandlerFunc { | ||
| 312 | 313 | // still render; they are the one thing a reader-facing forge can't police |
| 313 | 314 | // without a proxy. |
| 314 | 315 | func (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'; " + | |
| 316 | 317 | "img-src * data:; object-src 'none'; base-uri 'none'; form-action 'self'; frame-ancestors 'none'" |
| 317 | 318 | return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 318 | 319 | hd := w.Header() |
internal/httpd/web.go +26 −1
| @@ -79,7 +79,32 @@ var stylesheetHash = func() string { | ||
| 79 | 79 | |
| 80 | 80 | var stylesheetETag = `"` + stylesheetHash + `"` |
| 81 | 81 | |
| 82 | func init() { web.StyleVersion = stylesheetHash } | |
| 82 | var scriptHash = func() string { | |
| 83 | sum := sha256.Sum256(web.AppJS) | |
| 84 | return hex.EncodeToString(sum[:])[:16] | |
| 85 | }() | |
| 86 | ||
| 87 | var scriptETag = `"` + scriptHash + `"` | |
| 88 | ||
| 89 | func init() { | |
| 90 | web.StyleVersion = stylesheetHash | |
| 91 | web.ScriptVersion = scriptHash | |
| 92 | } | |
| 93 | ||
| 94 | func (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 | } | |
| 83 | 108 | |
| 84 | 109 | func (s *Server) stylesheet(w http.ResponseWriter, r *http.Request) { |
| 85 | 110 | w.Header().Set("ETag", stylesheetETag) |
internal/httpd/webux_test.go +10 −2
| @@ -65,7 +65,7 @@ func TestWebUXPickersStatebarAndRailPins(t *testing.T) { | ||
| 65 | 65 | } |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | // Issue detail carries clickable label & assignee pickers and datalists. | |
| 68 | // Issue detail carries popover label & assignee pickers, datalists, and Cmd+K palette. | |
| 69 | 69 | req = httptest.NewRequest("GET", "/alice/app/issues/1", nil) |
| 70 | 70 | req.AddCookie(cookie) |
| 71 | 71 | rec = httptest.NewRecorder() |
| @@ -74,12 +74,20 @@ func TestWebUXPickersStatebarAndRailPins(t *testing.T) { | ||
| 74 | 74 | t.Fatalf("GET /alice/app/issues/1: %d", rec.Code) |
| 75 | 75 | } |
| 76 | 76 | 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`} { | |
| 78 | 78 | if !strings.Contains(body, want) { |
| 79 | 79 | t.Errorf("issue page missing %s", want) |
| 80 | 80 | } |
| 81 | 81 | } |
| 82 | 82 | |
| 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 | ||
| 83 | 91 | // Clicking a picker button applies the label. |
| 84 | 92 | form := url.Values{"add": {"bug"}} |
| 85 | 93 | 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 @@ | ||
| 69 | 69 | --diff-add: #e4f6ea; |
| 70 | 70 | --diff-del: #fdeaea; |
| 71 | 71 | |
| 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; | |
| 74 | 74 | --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; | |
| 78 | 78 | --shell-mark: #ff6b3d; |
| 79 | 79 | |
| 80 | 80 | /* the languages' own colours; the same in both schemes */ |
| @@ -168,11 +168,11 @@ | ||
| 168 | 168 | --diff-add: #0d2a18; |
| 169 | 169 | --diff-del: #2c1113; |
| 170 | 170 | |
| 171 | --shell-bg: #000000; | |
| 171 | --shell-bg: #111318; | |
| 172 | 172 | --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; | |
| 176 | 176 | --shell-mark: #ff6b3d; |
| 177 | 177 | |
| 178 | 178 | /* the languages' own colours; the same in both schemes */ |
| @@ -446,8 +446,9 @@ footer a:hover { color: var(--link); } | ||
| 446 | 446 | |
| 447 | 447 | /* ---- repository header ---- */ |
| 448 | 448 | .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); | |
| 451 | 452 | } |
| 452 | 453 | .repohead .wrap { max-width: calc(var(--container) + 2 * var(--sp-6)); margin: 0 auto; padding: 0 var(--sp-6); } |
| 453 | 454 | .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; } | ||
| 827 | 828 | .notice { border-left-color: var(--ok); background: color-mix(in srgb, var(--ok) 6%, transparent); } |
| 828 | 829 | .empty-note, .none, .empty, li.empty, td.empty { color: var(--muted); } |
| 829 | 830 | |
| 830 | /* ---- containers: one recipe for cards, lists and tables ---- */ | |
| 831 | /* ---- containers: calm hairline borders and clean surfaces ---- */ | |
| 831 | 832 | .card, ul.list, ul.loglist, ul.repolist, ul.issuelist, |
| 832 | 833 | ul.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); | |
| 835 | 836 | border-radius: var(--r-card); |
| 836 | 837 | overflow: hidden; |
| 837 | 838 | } |
| @@ -840,7 +841,8 @@ ul.milestonelist, .readme, .code, article.release, .blame, .teambody { | ||
| 840 | 841 | align-items: center; |
| 841 | 842 | gap: var(--sp-3); |
| 842 | 843 | 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); | |
| 844 | 846 | font-size: var(--fs-1); |
| 845 | 847 | color: var(--muted); |
| 846 | 848 | } |
| @@ -874,8 +876,8 @@ tr.cols th.age, tr.cols th.size { text-align: right; } | ||
| 874 | 876 | .tablewrap { overflow-x: auto; max-width: 100%; } |
| 875 | 877 | |
| 876 | 878 | table.tree, table.refs { |
| 877 | background: var(--surface); | |
| 878 | border: 1px solid var(--line); | |
| 879 | background: var(--canvas); | |
| 880 | border: 1px solid var(--faint); | |
| 879 | 881 | border-radius: var(--r-card); |
| 880 | 882 | /* collapsed borders defeat a radius on the table itself */ |
| 881 | 883 | border-collapse: separate; |
| @@ -2061,3 +2063,145 @@ button.react.mine { border-color: var(--accent); background: var(--surface); col | ||
| 2061 | 2063 | font-weight: 600; |
| 2062 | 2064 | background: var(--surface); |
| 2063 | 2065 | } |
| 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 | } | |
| 2139 | dialog.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 | } | |
| 2149 | dialog.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 @@ | ||
| 43 | 43 | |
| 44 | 44 | {{$base := printf "/%s/%s/issues/%d" .Repo.OwnerName .Repo.Name .Issue.Number}} |
| 45 | 45 | <aside class="aside"> |
| 46 | {{if .CanEdit}} | |
| 47 | 46 | <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> | |
| 57 | 58 | {{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}} | |
| 70 | 60 | </div> |
| 71 | 61 | <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> | |
| 73 | 73 | {{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}} | |
| 86 | 75 | </div> |
| 87 | 76 | <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> | |
| 89 | 90 | {{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}} | |
| 99 | 98 | </form> |
| 100 | {{end}} | |
| 101 | 99 | </div> |
| 100 | {{end}} | |
| 102 | 101 | </aside> |
| 103 | 102 | </div> |
| 104 | 103 | {{end}} |
internal/web/templates/layout.html +8
| @@ -5,6 +5,7 @@ | ||
| 5 | 5 | <meta name="viewport" content="width=device-width, initial-scale=1"> |
| 6 | 6 | <title>{{template "title" .}}</title> |
| 7 | 7 | <link rel="stylesheet" href="/static/style.css?v={{styleVersion}}"> |
| 8 | <script src="/static/app.js?v={{scriptVersion}}" defer></script> | |
| 8 | 9 | <link rel="icon" href="/favicon.svg" type="image/svg+xml"> |
| 9 | 10 | <meta name="theme-color" content="#000000"> |
| 10 | 11 | {{with field . "Feed"}}<link rel="alternate" type="application/atom+xml" href="{{.}}"> |
| @@ -28,6 +29,7 @@ | ||
| 28 | 29 | <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> |
| 29 | 30 | <li class="railopt">{{template "raillink" (index $items 0)}}</li>{{end}} |
| 30 | 31 | </ul> |
| 32 | <button type="button" class="cmdk-trigger" aria-label="Jump to"><span>Jump to…</span><kbd>⌘K</kbd></button> | |
| 31 | 33 | <span class="railgap"></span> |
| 32 | 34 | <ul class="raillist"> |
| 33 | 35 | {{if .Viewer}}<li class="railopt">{{template "raillink" (index $items 1)}}</li> |
| @@ -93,6 +95,12 @@ | ||
| 93 | 95 | </footer> |
| 94 | 96 | </div> |
| 95 | 97 | </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> | |
| 96 | 104 | </body> |
| 97 | 105 | </html>{{end}} |
| 98 | 106 | |
internal/web/templates/mr.html +46 −42
| @@ -123,12 +123,16 @@ | ||
| 123 | 123 | {{end}} |
| 124 | 124 | {{if and .CanEdit (or (eq .MR.State "open") (eq .MR.State "source_gone"))}} |
| 125 | 125 | <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> | |
| 132 | 136 | <form method="post" action="{{$base}}/draft" class="actions"> |
| 133 | 137 | {{if .MR.Draft}}<button type="submit" class="btn">Ready for review</button> |
| 134 | 138 | {{else}}<input type="hidden" name="draft" value="on"><button type="submit" class="btn">Convert to draft</button>{{end}} |
| @@ -161,55 +165,55 @@ | ||
| 161 | 165 | {{end}} |
| 162 | 166 | </div>{{end}} |
| 163 | 167 | <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> | |
| 165 | 179 | {{if .MR.ReviewRequests}}<p class="row">{{range .MR.ReviewRequests}}<a href="/{{.}}">{{.}}</a> {{end}}</p> |
| 166 | 180 | {{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}} | |
| 178 | 181 | </div> |
| 179 | 182 | <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> | |
| 182 | 197 | <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}} | |
| 193 | 198 | </div> |
| 194 | 199 | {{if .MR.Milestone}}<div class="grp"> |
| 195 | 200 | <h2>Milestone</h2> |
| 196 | 201 | <p class="row"><a href="/{{.Repo.OwnerName}}/{{.Repo.Name}}/milestones">{{.MR.Milestone}}</a></p> |
| 197 | 202 | </div>{{end}} |
| 198 | 203 | <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> | |
| 200 | 215 | {{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> |
| 201 | 216 | {{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}} | |
| 213 | 217 | </div> |
| 214 | 218 | </aside> |
| 215 | 219 | </div> |
internal/web/web.go +11 −6
| @@ -22,6 +22,9 @@ var templateFS embed.FS | ||
| 22 | 22 | //go:embed static/style.css |
| 23 | 23 | var StyleCSS []byte |
| 24 | 24 | |
| 25 | //go:embed static/app.js | |
| 26 | var AppJS []byte | |
| 27 | ||
| 25 | 28 | //go:embed static/favicon.svg |
| 26 | 29 | var FaviconSVG []byte |
| 27 | 30 | |
| @@ -31,10 +34,11 @@ var FontFS embed.FS | ||
| 31 | 34 | //go:embed static/img/*.gif static/img/*.webm static/img/*.mp4 |
| 32 | 35 | var ImageFS embed.FS |
| 33 | 36 | |
| 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. | |
| 37 | 40 | var StyleVersion string |
| 41 | var ScriptVersion string | |
| 38 | 42 | |
| 39 | 43 | // railItem is one destination the rail's icon strip and the phone |
| 40 | 44 | // "More" menu both render — from this one list, so a destination added |
| @@ -96,9 +100,10 @@ func railOptItems(v any) []railItem { | ||
| 96 | 100 | } |
| 97 | 101 | |
| 98 | 102 | var 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], | |
| 102 | 107 | // paragraphs splits plain text on blank lines for safe rich display. |
| 103 | 108 | "paragraphs": func(s string) []string { |
| 104 | 109 | var out []string |