Commit 6521399c1c

6521399c1c78577eb00f1bcf8947c0900b9cb62e

parent: 28e72be7ab

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

cmc <hello@cleberg.net> · 2026-11-25 22:13 UTC

web: overhaul code review, navigation, triage, queries, and parity settings

- Fix P0 UI/UX regressions: check-state badges in tree/log, reaction CSS
  variables, autosave error reversion, scoped reaction DOM swaps, inline
  diff comment multi-line range + suggestion insertion, tab-swap history,
  subpage safeReturnTo redirects, /new validation preservation, and state
  chip consistency, backed by CSS variable and dynamic class tests.
- Refine light/dark surface elevation (--canvas / --card), unify filter
  and state bars, deduplicate desktop state facets, upgrade repo header
  Pin/Watch/Bookmark/Fork controls with split-button watch modes and live
  counts, and surface snippets/queries in rail menus.
- Upgrade MR code review and code browsing: full-width diff view, sticky
  review bar and file headers, sticky file TOC with Viewed checkboxes,
  single-commit diff filtering, intra-line word diff highlighting, inline
  hunk context expansion, web rebase action, comment permalinks and quote
  replies, colorized range-diff, syntax-highlighted blame with prior-commit
  blame links, blob tip bar and Shift+Click line ranges, 1-step branch+MR
  web file editing (repo commit-file --from), and live Cmd+K / t / ? jump.
- Add triage metadata and author/assignee filter popovers, interactive
  ad-hoc and saved queries web UI, Write/Preview composer tabs with
  @/#/! autocomplete and format pickers, ANSI build log colors and job
  re-run, 1-step signup email verification, and repository/account parity
  settings (build secrets, deploy keys, mirrors, custom pages domains,
  SSH key expiry/last-use, and browser sessions).

Layout: unified · split

Changed files (49)
.gitbay/wiki/Parity.org +7 −7 · view
@@ -215,10 +215,10 @@ there shows the app's rendering rather than the one the web page shows.
215215| access grants | yes | yes | yes |
216216| effective access | yes | yes | yes |
217217| webhooks | yes | yes | yes |
218| build secrets | yes | no | yes |
219| deploy keys | yes | no | yes |
220| mirrors | yes | no | yes |
221| custom pages domains | yes | no | yes |
218| build secrets | yes | yes | yes |
219| deploy keys | yes | yes | yes |
220| mirrors | yes | yes | yes |
221| custom pages domains | yes | yes | yes |
222222| runners attach, list, detach | yes | yes | n/a |
223223| runner attached for some jobs | yes | yes | n/a |
224224| import from a remote | yes | yes | yes |
@@ -340,7 +340,7 @@ now render the way the reference does. go-org is not yet on the corpus.
340340|----------------------------------+-----+-----+-----|
341341| search repositories | yes | yes | yes |
342342| search issues and merge requests | yes | yes | yes |
343| saved query save, remove, pin | yes | no | yes |
343| saved query save, remove, pin | yes | yes | yes |
344344| saved query list and results | yes | yes | yes |
345345| pinned queries on the dashboard | yes | yes | yes |
346346| browse all public repositories | yes | yes | yes |
@@ -414,7 +414,7 @@ client has no use for one (krz/gitbay#57).
414414|-----------------------------+-----+-----+-----|
415415| SSH keys: list, add, remove | yes | yes | yes |
416416| SSH key label | yes | yes | yes |
417| SSH key expiry and last use | yes | no | yes |
417| SSH key expiry and last use | yes | yes | yes |
418418| PGP keys: list, add, remove | yes | yes | yes |
419419| email add and verify | yes | yes | yes |
420420| email list, remove, primary | yes | yes | yes |
@@ -432,7 +432,7 @@ client has no use for one (krz/gitbay#57).
432432| API token mint | yes | yes | yes |
433433| API token list, revoke | yes | yes | yes |
434434| API token revoke with what it created | yes | no | yes |
435| browser sessions: list, end | yes | no | yes |
435| browser sessions: list, end | yes | yes | yes |
436436| account export bundle | yes | yes | n/a |
437437| delete your own account | yes | yes | yes |
438438| profile set | yes | yes | yes |
internal/control/commitfile.go +9 −5 · view
@@ -16,9 +16,10 @@ func init() {
1616 Path: []string{"repo", "commit-file"},
1717 Summary: "write a file and commit it",
1818 Usage: "repo commit-file <owner/name> <path> " +
19 "--ref <branch> [--message <m>] [--file -]",
19 "--ref <branch> [--from <base>] [--message <m>] [--file -]",
2020 Flags: []Flag{
2121 {"--ref", "<branch>", "branch to commit to", ""},
22 {"--from", "<base>", "base branch when creating a new branch", ""},
2223 {"--message", "<m>", "the commit message", ""},
2324 {"--file", "-", "read the new content from stdin", ""},
2425 },
@@ -43,15 +44,18 @@ const maxCommitFileBytes = 1 << 20
4344// A repository that requires verified signatures therefore refuses the
4445// command rather than writing a commit its own policy would reject.
4546func runCommitFile(c *Ctx, args []string) int {
46 f, err := c.parseArgs(args, flagSpec{Values: []string{"--ref", "--message", "--file"}, MaxPos: -1, Usage: c.Cmd.Usage})
47 f, err := c.parseArgs(args, flagSpec{Values: []string{"--ref", "--from", "--message", "--file"}, MaxPos: -1, Usage: c.Cmd.Usage})
4748 if err != nil {
4849 return c.fail(protocol.ExitUsage, "%v", err)
4950 }
5051 rest := f.Pos
51 ref, message, file := f.Value("--ref"), f.Value("--message"), f.Value("--file")
52 ref, fromRef, message, file := f.Value("--ref"), f.Value("--from"), f.Value("--message"), f.Value("--file")
5253 if len(rest) != 2 || ref == "" {
5354 return c.usage()
5455 }
56 if strings.HasPrefix(ref, "-") || strings.HasPrefix(ref, "/") || strings.HasSuffix(ref, "/") || strings.HasSuffix(ref, ".lock") || strings.Contains(ref, "..") || strings.Contains(ref, "//") || strings.ContainsAny(ref, " \t\r\n~^:?*[\\@{") {
57 return c.fail(protocol.ExitUsage, "invalid branch name %q", ref)
58 }
5559 repo, code := resolveRepo(c, rest[0], policy.CanWrite)
5660 if code >= 0 {
5761 return code
@@ -101,9 +105,9 @@ func runCommitFile(c *Ctx, args []string) int {
101105
102106 dir := RepoDir(c.Cfg.Server.Root, repo.OwnerName, repo.Name)
103107 // The head before the commit bounds what landed; a branch that does
104 // not exist fails in CommitFileChange with its own message.
108 // not exist fails in CommitFileFrom unless --from names its base.
105109 parent, _ := gitutil.ResolveRef(dir, "refs/heads/"+ref)
106 sha, err := gitutil.CommitFileChange(dir, ref, filePath, content,
110 sha, err := gitutil.CommitFileFrom(dir, ref, fromRef, filePath, content,
107111 c.User.Username, email, message)
108112 if err != nil {
109113 return c.fail(protocol.ExitFailure, "%v", err)
internal/control/query.go +37 · view
@@ -158,6 +158,43 @@ func PinnedQueries(st *store.Store, user store.User) ([]DashboardQuery, error) {
158158 return out, nil
159159}
160160
161// RunAdHocQuery evaluates an unsaved cross-repository query for the web
162// queries page using the same parser, visibility filter, and cursor as query run.
163func RunAdHocQuery(st *store.Store, user store.User, rawQuery, cursor string, limit int) ([]QueryItem, int, string, error) {
164 q, err := ParseItemQuery(rawQuery)
165 if err != nil {
166 return nil, 0, "", err
167 }
168 var after *store.ItemCursor
169 if cursor != "" {
170 key, err := decodeCursor("query", cursor)
171 if err != nil {
172 return nil, 0, "", errors.New("bad cursor")
173 }
174 if after, err = decodeItemCursor(key); err != nil {
175 return nil, 0, "", err
176 }
177 }
178 if limit <= 0 {
179 limit = queryDefaultLimit
180 }
181 f := q.Filter(user.Username, true, true)
182 total, err := st.CountItems(user.ID, f)
183 if err != nil {
184 return nil, 0, "", err
185 }
186 items, err := st.QueryItems(user.ID, f, after, limit+1)
187 if err != nil {
188 return nil, 0, "", err
189 }
190 next := ""
191 if len(items) > limit {
192 items = items[:limit]
193 next = encodeItemCursor(items[len(items)-1].Cursor())
194 }
195 return queryItems(items), total, next, nil
196}
197
161198func encodeItemCursor(k store.ItemCursor) string {
162199 return encodeCursor("query", fmt.Sprintf("%s|%d|%d", k.CreatedAt, k.Kind, k.ID))
163200}
internal/control/register.go +29 · view
@@ -333,3 +333,32 @@ func RegisterAccount(cfg config.Config, st *store.Store, pub ssh.PublicKey, user
333333 return "", "registration is closed on this instance", protocol.ExitDenied
334334 }
335335}
336
337// VerifyPendingSignup redeems an emailed verification code right on the web
338// post-registration screen, activating the account in one step.
339func VerifyPendingSignup(cfg config.Config, st *store.Store, username, code string) (store.User, string) {
340 if username == "" || code == "" {
341 return store.User{}, "enter the verification code from your email"
342 }
343 u, err := st.UserByUsername(username)
344 if err != nil || u.Disabled {
345 return store.User{}, "that code is invalid, expired, or already used"
346 }
347 address, err := st.ConsumeEmailToken(u.ID, store.HashToken(code))
348 if err != nil {
349 return store.User{}, "that code is invalid, expired, or already used"
350 }
351 if err := st.VerifyEmail(u.ID, address, "smtp"); err != nil {
352 return store.User{}, err.Error()
353 }
354 wasPending := u.Pending
355 if err := st.ClearPending(u.ID); err != nil {
356 return store.User{}, err.Error()
357 }
358 u.Pending = false
359 st.Audit(u.ID, "email.signup_verified", map[string]any{"address": address})
360 if wasPending {
361 notifyAdminsOfSignup(cfg, st, u.Username, "open")
362 }
363 return u, ""
364}
internal/gitutil/merge.go +25 −7 · view
@@ -199,23 +199,41 @@ func MergeBase(dir, a, b string) (string, error) {
199199// advances the branch with compare-and-swap. Used by web edits; hooks do not
200200// run, so callers enforce policy themselves.
201201func CommitFileChange(dir, branch, path string, content []byte, name, email, message string) (string, error) {
202 return CommitFileFrom(dir, branch, "", path, content, name, email, message)
203}
204
205// CommitFileFrom writes content to path on branch. When branch does not exist
206// yet and fromBranch is named, the new branch starts from fromBranch's tip.
207func CommitFileFrom(dir, branch, fromBranch, path string, content []byte, name, email, message string) (string, error) {
202208 branchRef := "refs/heads/" + branch
209 oldRef := ""
203210 parent, err := ResolveRef(dir, branchRef)
204211 if err != nil {
205 // An unborn branch is a root commit only in a repository with no
206 // refs at all. Anywhere else an unresolvable branch is a typo, and
207 // starting an orphan branch for it would be worse than refusing.
208 if !isEmptyRepo(dir) {
209 return "", fmt.Errorf("branch %s: %w", branch, err)
212 if fromBranch != "" {
213 baseSHA, berr := ResolveRef(dir, "refs/heads/"+fromBranch)
214 if berr != nil {
215 return "", fmt.Errorf("base branch %s: %w", fromBranch, berr)
216 }
217 parent = baseSHA
218 oldRef = ""
219 } else {
220 // An unborn branch is a root commit only in a repository with no
221 // refs at all. Anywhere else an unresolvable branch is a typo, and
222 // starting an orphan branch for it would be worse than refusing.
223 if !isEmptyRepo(dir) {
224 return "", fmt.Errorf("branch %s: %w", branch, err)
225 }
226 parent = ""
210227 }
211 parent = ""
228 } else {
229 oldRef = parent
212230 }
213231
214232 sha, err := CommitWithFile(dir, parent, path, "100644", content, name, email, message)
215233 if err != nil {
216234 return "", err
217235 }
218 if err := UpdateRefCAS(dir, branchRef, sha, parent); err != nil {
236 if err := UpdateRefCAS(dir, branchRef, sha, oldRef); err != nil {
219237 return "", fmt.Errorf("branch moved during edit; reload and retry: %w", err)
220238 }
221239 return sha, nil
internal/httpd/account.go +66 −24 · view
@@ -21,6 +21,8 @@ type accountKey struct {
2121 Algo string
2222 Scope string
2323 Label string
24 LastUsed string
25 Expires string
2426 Confirm string // the 8 characters after SHA256: — a label can be empty
2527}
2628
@@ -73,7 +75,14 @@ func (s *Server) renderAccount(w http.ResponseWriter, r *http.Request, u store.U
7375 if list, err := s.st.ListSSHKeys(u.ID); err == nil {
7476 for _, k := range list {
7577 confirm := prefix8(strings.TrimPrefix(k.Fingerprint, "SHA256:"))
76 keys = append(keys, accountKey{Fingerprint: k.Fingerprint, Algo: k.Algo, Scope: k.Scope, Label: k.Label, Confirm: confirm})
78 expires := "never"
79 if k.ExpiresAt != nil {
80 expires = k.ExpiresAt.UTC().Format("2006-01-02 15:04 UTC")
81 }
82 keys = append(keys, accountKey{
83 Fingerprint: k.Fingerprint, Algo: k.Algo, Scope: k.Scope, Label: k.Label,
84 LastUsed: k.LastUsedAt, Expires: expires, Confirm: confirm,
85 })
7786 }
7887 }
7988 var pgp []accountPGP
@@ -122,6 +131,15 @@ func (s *Server) renderAccount(w http.ResponseWriter, r *http.Request, u store.U
122131 }
123132 }
124133
134 var sessions []store.WebSession
135 s.runControlInto(u, []string{"web", "sessions", "list"}, &sessions)
136 currentSession := ""
137 if ck, err := r.Cookie(sessionCookie); err == nil {
138 if h := store.HashToken(ck.Value); len(h) >= 12 {
139 currentSession = h[:12]
140 }
141 }
142
125143 // The about text is a file. The page points at it rather than editing
126144 // it: the repository's own editor already does that job.
127145 aboutRepo := u.Username + "/" + control.ProfileRepoName
@@ -135,33 +153,35 @@ func (s *Server) renderAccount(w http.ResponseWriter, r *http.Request, u store.U
135153
136154 s.render(w, "account.html", struct {
137155 basePage
138 Tab string // marks the rail's Settings row as current
139 Keys []accountKey
140 PGP []accountPGP
141 Emails []store.Email
142 Profile control.ProfileOut
143 LinksText string
144 AboutRepo string // <user>/.gitbay, which holds the about text
145 AboutEdit string // the file editor's URL, empty when there is no file yet
146 Host string
147 Notice string
148 Message string
149 MailOn bool
150 WatchOn bool
151 PushOn bool
152 ReplyOn bool
153 ReplyOffered bool // the instance reads replies to its mail
154 Devices []accountDevice
155 ThemeSetting string // system, light or dark: the form's selected option
156 DiffSetting string // unified or split: the form's selected option
157 Tokens []accountToken
158 TokenShown string // a token minted by this request, shown once
159 Reauth bool // Notice is the stale-session refusal: link to sign in
156 Tab string // marks the rail's Settings row as current
157 Keys []accountKey
158 PGP []accountPGP
159 Emails []store.Email
160 Profile control.ProfileOut
161 LinksText string
162 AboutRepo string // <user>/.gitbay, which holds the about text
163 AboutEdit string // the file editor's URL, empty when there is no file yet
164 Host string
165 Notice string
166 Message string
167 MailOn bool
168 WatchOn bool
169 PushOn bool
170 ReplyOn bool
171 ReplyOffered bool // the instance reads replies to its mail
172 Devices []accountDevice
173 ThemeSetting string // system, light or dark: the form's selected option
174 DiffSetting string // unified or split: the form's selected option
175 Tokens []accountToken
176 TokenShown string // a token minted by this request, shown once
177 Sessions []store.WebSession
178 CurrentSession string
179 Reauth bool // Notice is the stale-session refusal: link to sign in
160180 }{s.baseFor(u), "account", keys, pgp, emails, profile, profileLinksText(profile.Links),
161181 aboutRepo, aboutEdit, s.cfg.SiteHost(),
162182 notice, r.URL.Query().Get("m"), mailOn, watchOn, pushOn,
163183 replyOn, s.cfg.Mail.Inbound.Enabled, devices, theme, diffPref,
164 tokens, tokenShown, reauth})
184 tokens, tokenShown, sessions, currentSession, reauth})
165185}
166186
167187// accountExport hands the browser the same bundle `account export`
@@ -238,11 +258,33 @@ func (s *Server) accountSubmit(w http.ResponseWriter, r *http.Request, u store.U
238258 if label := strings.TrimSpace(r.FormValue("label")); label != "" {
239259 argv = append(argv, "--label", label)
240260 }
261 if ttl := strings.TrimSpace(r.FormValue("ttl")); ttl != "" {
262 argv = append(argv, "--ttl", ttl)
263 }
241264 if msg, ok := s.runControlStdin(u, argv, body+"\n"); !ok {
242265 back(msg, "")
243266 return
244267 }
245268 back("", "key registered")
269 case "session-revoke":
270 id := strings.TrimSpace(r.FormValue("id"))
271 if _, msg, ok := s.runControl(u, []string{"web", "sessions", "revoke", id}); !ok {
272 back(msg, "")
273 return
274 }
275 if ck, err := r.Cookie(sessionCookie); err == nil && strings.HasPrefix(store.HashToken(ck.Value), id) {
276 http.SetCookie(w, s.clearCookie(sessionCookie, sessionSameSite))
277 http.Redirect(w, r, "/", http.StatusSeeOther)
278 return
279 }
280 back("", "browser session ended")
281 case "session-revoke-all":
282 if _, msg, ok := s.runControl(u, []string{"web", "sessions", "revoke", "--all"}); !ok {
283 back(msg, "")
284 return
285 }
286 http.SetCookie(w, s.clearCookie(sessionCookie, sessionSameSite))
287 http.Redirect(w, r, "/", http.StatusSeeOther)
246288 case "account-delete":
247289 if ok, msg := confirmed(r, u.Username); !ok {
248290 back(msg, "")
internal/httpd/accounts.go +130 −21 · view
@@ -212,9 +212,17 @@ func (s *Server) adminOrgs(u store.User) []string {
212212
213213func (s *Server) renderNewRepo(w http.ResponseWriter, u store.User, errMsg string, submitted url.Values) {
214214 // A refused import keeps what was typed, except the token.
215 panel := "create"
216 switch submitted.Get("field") {
217 case "import":
218 panel = "import"
219 case "org-create":
220 panel = "org"
221 }
215222 subm := map[string]string{
216223 "owner": submitted.Get("owner"), "name": submitted.Get("name"),
217224 "from": submitted.Get("from"), "visibility": submitted.Get("visibility"),
225 "panel": panel,
218226 }
219227 s.render(w, "new.html", struct {
220228 basePage
@@ -232,10 +240,11 @@ func (s *Server) newRepoForm(w http.ResponseWriter, r *http.Request, u store.Use
232240// forms, told apart by the org form's field. An organization's page is
233241// the redirect, the same as org-create from anywhere else.
234242func (s *Server) newSubmit(w http.ResponseWriter, r *http.Request, u store.User) {
243 r.ParseForm()
235244 if r.FormValue("field") == "org-create" {
236245 name := strings.TrimSpace(r.FormValue("name"))
237246 if _, msg, ok := s.runControl(u, []string{"org", "create", name}); !ok {
238 s.renderNewRepo(w, u, msg, nil)
247 s.renderNewRepo(w, u, msg, r.Form)
239248 return
240249 }
241250 http.Redirect(w, r, "/"+name, http.StatusSeeOther)
@@ -269,12 +278,37 @@ func (s *Server) newSubmit(w http.ResponseWriter, r *http.Request, u store.User)
269278 argv = append(argv, "--private")
270279 }
271280 if _, msg, ok := s.runControl(u, argv); !ok {
272 s.renderNewRepo(w, u, msg, nil)
281 s.renderNewRepo(w, u, msg, r.Form)
273282 return
274283 }
275284 http.Redirect(w, r, "/"+owner+"/"+name, http.StatusSeeOther)
276285}
277286
287// safeReturnTo returns a same-origin path from Referer when it lives under
288// prefix, falling back to prefix itself so toggling a repo-header button on
289// a subpage (/issues/42, /mrs/10) stays on that subpage.
290func safeReturnTo(r *http.Request, fallback string) string {
291 ref := r.Header.Get("Referer")
292 if ref == "" {
293 return fallback
294 }
295 u, err := url.Parse(ref)
296 if err != nil {
297 return fallback
298 }
299 if u.Host != "" && u.Host != r.Host {
300 return fallback
301 }
302 dest := u.RequestURI()
303 if !localPath(dest) || len(dest) > 300 {
304 return fallback
305 }
306 if dest == fallback || strings.HasPrefix(dest, fallback+"/") || strings.HasPrefix(dest, fallback+"?") {
307 return dest
308 }
309 return fallback
310}
311
278312// pinToggle pins or unpins the repo for the logged-in viewer, through
279313// repo pin/repo unpin — the same commands the CLI runs — rather than
280314// writing the store directly (#261).
@@ -290,7 +324,7 @@ func (s *Server) pinToggle(w http.ResponseWriter, r *http.Request, u store.User)
290324 if _, msg, ok := s.runControl(u, []string{"repo", verb, repo.Path()}); !ok {
291325 s.setFlash(w, msg)
292326 }
293 http.Redirect(w, r, "/"+repo.Path(), http.StatusSeeOther)
327 http.Redirect(w, r, safeReturnTo(r, "/"+repo.Path()), http.StatusSeeOther)
294328}
295329
296330// bookmarkToggle saves or unsaves a repository for the viewer. Read
@@ -308,7 +342,7 @@ func (s *Server) bookmarkToggle(w http.ResponseWriter, r *http.Request, u store.
308342 if _, msg, ok := s.runControl(u, []string{"repo", verb, repo.Path()}); !ok {
309343 s.setFlash(w, msg)
310344 }
311 http.Redirect(w, r, "/"+repo.Path(), http.StatusSeeOther)
345 http.Redirect(w, r, safeReturnTo(r, "/"+repo.Path()), http.StatusSeeOther)
312346}
313347
314348// bookmarksPage lists what the viewer has saved.
@@ -427,7 +461,42 @@ func (s *Server) signupSubmit(w http.ResponseWriter, r *http.Request) {
427461 Username string
428462 Message string
429463 Host string
430 }{s.anonBase(), username, msg, s.cfg.SiteHost()})
464 Mode string
465 Error string
466 }{s.anonBase(), username, msg, s.cfg.SiteHost(), s.cfg.Registration.Mode, ""})
467}
468
469func (s *Server) signupVerifySubmit(w http.ResponseWriter, r *http.Request) {
470 if allowed, wait := s.apiLimit.allow("regverify"+s.clientIP(r), true); !allowed {
471 w.Header().Set("Retry-After", strconv.Itoa(int(wait.Seconds())+1))
472 http.Error(w, "too many verification attempts; wait a moment", http.StatusTooManyRequests)
473 return
474 }
475 username := strings.TrimSpace(r.FormValue("username"))
476 code := strings.TrimSpace(r.FormValue("code"))
477 u, errMsg := control.VerifyPendingSignup(s.cfg, s.st, username, code)
478 if errMsg != "" {
479 s.render(w, "registered.html", struct {
480 basePage
481 Username string
482 Message string
483 Host string
484 Mode string
485 Error string
486 }{s.anonBase(), username, "Check your inbox for the verification code.", s.cfg.SiteHost(), s.cfg.Registration.Mode, errMsg})
487 return
488 }
489 sessTok, sessHash, err := store.NewToken()
490 if err != nil {
491 http.Error(w, "internal error", http.StatusInternalServerError)
492 return
493 }
494 if err := s.st.CreateWebSession(sessHash, u.ID, 7*24*time.Hour); err != nil {
495 http.Error(w, "internal error", http.StatusInternalServerError)
496 return
497 }
498 http.SetCookie(w, s.sessionCookieFor(sessTok))
499 http.Redirect(w, r, "/", http.StatusSeeOther)
431500}
432501
433502// issueNewPage is what the new-issue form renders with, whether that is a
@@ -615,7 +684,7 @@ func (s *Server) mrCommentSubmit(w http.ResponseWriter, r *http.Request, u store
615684func (s *Server) commentSubmit(w http.ResponseWriter, r *http.Request, u store.User, noun, segment string) {
616685 repoPath := r.PathValue("owner") + "/" + r.PathValue("repo")
617686 n := r.PathValue("n")
618 code, msg := s.dispatchJSON(u, []string{noun, "comment", repoPath, n, "--file", "-"}, strings.TrimSpace(r.FormValue("body")))
687 code, msg := s.dispatchJSON(u, []string{noun, "comment", repoPath, n, "--format", bodyFormat(r), "--file", "-"}, strings.TrimSpace(r.FormValue("body")))
619688 if code != protocol.ExitOK {
620689 http.Error(w, msg, statusForExit(code))
621690 return
@@ -631,6 +700,11 @@ type editPage struct {
631700 Content string
632701 Error string
633702 Blocked string
703 // ProposeBranch is suggested when direct commits to Ref are blocked by
704 // require_mr (and signed commits are not required), enabling a 1-step
705 // branch-and-MR edit flow.
706 ProposeBranch string
707 RequireMR bool
634708 // Creating marks a path the branch does not have yet.
635709 Creating bool
636710 // Markup is set for a path the forge renders, which is where a
@@ -640,6 +714,17 @@ type editPage struct {
640714 Nav fileNav
641715}
642716
717func nextPatchBranch(dir, username string) string {
718 base := username + "-patch-"
719 for i := 1; i <= 50; i++ {
720 cand := base + strconv.Itoa(i)
721 if _, err := gitutil.ResolveRef(dir, "refs/heads/"+cand); err != nil {
722 return cand
723 }
724 }
725 return base + "edit"
726}
727
643728func (s *Server) editForm(w http.ResponseWriter, r *http.Request, u store.User) {
644729 repo, ok := s.repoForUser(w, r, u, policy.CanWrite)
645730 if !ok {
@@ -648,14 +733,6 @@ func (s *Server) editForm(w http.ResponseWriter, r *http.Request, u store.User)
648733 ref := r.PathValue("ref")
649734 filePath := strings.Trim(r.PathValue("path"), "/")
650735
651 blocked := ""
652 switch {
653 case repo.Settings.RequireSignedCommits:
654 blocked = repo.Path() + " requires signed commits and the web editor cannot sign; edit locally and push a signed commit."
655 case repo.Settings.RequireMR && slices.Contains(repo.Settings.ProtectedBranches, ref):
656 blocked = "branch " + ref + " accepts changes through merge requests only; edit on another branch and open one."
657 }
658
659736 dir := control.RepoDir(s.cfg.Server.Root, repo.OwnerName, repo.Name)
660737 // A branch that does not exist has nothing to edit. A path that does
661738 // not exist on a real branch is a new file: commit-file creates it.
@@ -663,6 +740,18 @@ func (s *Server) editForm(w http.ResponseWriter, r *http.Request, u store.User)
663740 s.notFound(w, r)
664741 return
665742 }
743
744 blocked := ""
745 requireMR := false
746 propose := ""
747 switch {
748 case repo.Settings.RequireSignedCommits:
749 blocked = repo.Path() + " requires signed commits and the web editor cannot sign; edit locally and push a signed commit."
750 case repo.Settings.RequireMR && slices.Contains(repo.Settings.ProtectedBranches, ref):
751 requireMR = true
752 propose = nextPatchBranch(dir, u.Username)
753 }
754
666755 content, err := gitutil.ReadBlob(dir, "refs/heads/"+ref, filePath, maxRenderBytes)
667756 creating := err != nil
668757 if creating {
@@ -676,7 +765,8 @@ func (s *Server) editForm(w http.ResponseWriter, r *http.Request, u store.User)
676765 nav := fileNavFor(repo.Path(), ref, filePath, navEntries)
677766 s.render(w, "edit.html", editPage{
678767 basePage: s.baseFor(u), Repo: repo,
679 Ref: ref, Path: filePath, Content: string(content), Blocked: blocked, Creating: creating,
768 Ref: ref, Path: filePath, Content: string(content), Blocked: blocked,
769 ProposeBranch: propose, RequireMR: requireMR, Creating: creating,
680770 Markup: markupFile(filePath),
681771 Nav: nav,
682772 })
@@ -689,6 +779,8 @@ func (s *Server) editSubmit(w http.ResponseWriter, r *http.Request, u store.User
689779 }
690780 ref := r.PathValue("ref")
691781 filePath := strings.Trim(r.PathValue("path"), "/")
782 targetBranch := strings.TrimSpace(r.FormValue("target_branch"))
783 requireMR := repo.Settings.RequireMR && slices.Contains(repo.Settings.ProtectedBranches, ref)
692784
693785 // Preview: the file as the blob page will render it, above the
694786 // editor, with nothing committed. Only for paths the forge renders.
@@ -699,25 +791,42 @@ func (s *Server) editSubmit(w http.ResponseWriter, r *http.Request, u store.User
699791 })
700792 s.render(w, "edit.html", editPage{
701793 basePage: s.baseFor(u), Repo: repo,
702 Ref: ref, Path: filePath, Content: content, Markup: true, Draft: d,
794 Ref: ref, Path: filePath, Content: content,
795 ProposeBranch: targetBranch, RequireMR: requireMR,
796 Markup: true, Draft: d,
703797 })
704798 return
705799 }
706800
707 // Editing is a control command; the web supplies the form and lets
708 // the registry enforce the rules — signed-commit policy, verified
709 // identity, archived repositories — so every surface agrees on them.
710 argv := []string{"repo", "commit-file", repo.Path(), filePath, "--ref", ref, "--file", "-"}
711 if message := strings.TrimSpace(r.FormValue("message")); message != "" {
801 commitRef := ref
802 var argv []string
803 if targetBranch != "" && targetBranch != ref {
804 commitRef = targetBranch
805 argv = []string{"repo", "commit-file", repo.Path(), filePath, "--ref", commitRef, "--from", ref, "--file", "-"}
806 } else {
807 argv = []string{"repo", "commit-file", repo.Path(), filePath, "--ref", ref, "--file", "-"}
808 }
809 message := strings.TrimSpace(r.FormValue("message"))
810 if message != "" {
712811 argv = append(argv, "--message", message)
713812 }
714813 if msg, ok := s.runControlStdin(u, argv, r.FormValue("content")); !ok {
715814 s.render(w, "edit.html", editPage{
716815 basePage: s.baseFor(u), Repo: repo,
717816 Ref: ref, Path: filePath, Content: r.FormValue("content"), Error: msg,
817 ProposeBranch: targetBranch, RequireMR: requireMR,
718818 Markup: markupFile(filePath),
719819 })
720820 return
721821 }
822 if commitRef != ref {
823 title := message
824 if title == "" {
825 title = "Update " + filePath
826 }
827 q := url.Values{"source": {commitRef}, "target": {ref}, "title": {title}}
828 http.Redirect(w, r, fmt.Sprintf("/%s/mrs/new?%s", repo.Path(), q.Encode()), http.StatusSeeOther)
829 return
830 }
722831 http.Redirect(w, r, fmt.Sprintf("/%s/blob/%s/%s", repo.Path(), ref, filePath), http.StatusSeeOther)
723832}
internal/httpd/builds.go +113 −5 · view
@@ -283,6 +283,7 @@ func (s *Server) build(w http.ResponseWriter, r *http.Request) {
283283 return
284284 }
285285 v.Log, _, _ = s.runControl(viewer, []string{"build", "log", p.Repo.Path(), n})
286 v.LogHTML = ansiHTML(v.Log)
286287 v.Steps, v.Failed = logSteps(v.Log, b)
287288 if b.DurationS > 0 {
288289 v.Duration = (time.Duration(b.DurationS) * time.Second).String()
@@ -292,8 +293,9 @@ func (s *Server) build(w http.ResponseWriter, r *http.Request) {
292293
293294type buildView struct {
294295 repoPage
295 Build control.BuildOut
296 Log string
296 Build control.BuildOut
297 Log string
298 LogHTML template.HTML
297299 // Steps is the finished log cut at its steps, nil when there is no
298300 // step to cut at; Failed says whether one of them is marked failed.
299301 Steps []logStep
@@ -308,8 +310,9 @@ type logStep struct {
308310 control.LogSection
309311 // Head is the step's first line, which its fold's summary shows, as
310312 // build show does; the full step is in the log below it.
311 Head string
312 Failed bool
313 Head string
314 TextHTML template.HTML
315 Failed bool
313316}
314317
315318// logSteps cuts a finished build's log at its steps and marks the one it
@@ -330,11 +333,116 @@ func logSteps(log string, b control.BuildOut) ([]logStep, bool) {
330333 out := make([]logStep, len(sections))
331334 for i, s := range sections {
332335 head, _, _ := strings.Cut(s.Step, "\n")
333 out[i] = logStep{LogSection: s, Head: head, Failed: i == failed}
336 out[i] = logStep{LogSection: s, Head: head, TextHTML: ansiHTML(s.Text), Failed: i == failed}
334337 }
335338 return out, failed >= 0
336339}
337340
341// ansiHTML escapes build log text and converts standard SGR ANSI sequences
342// (\x1b[...m) into semantic <span class="ansi-*"> elements.
343func ansiHTML(raw string) template.HTML {
344 if !strings.ContainsRune(raw, '\x1b') {
345 return template.HTML(template.HTMLEscapeString(raw))
346 }
347 var b strings.Builder
348 b.Grow(len(raw) + 64)
349 var bold, dim bool
350 var fg string
351 open := false
352 closeSpan := func() {
353 if open {
354 b.WriteString("</span>")
355 open = false
356 }
357 }
358 openSpan := func() {
359 var cls []string
360 if bold {
361 cls = append(cls, "ansi-bold")
362 }
363 if dim {
364 cls = append(cls, "ansi-dim")
365 }
366 if fg != "" {
367 cls = append(cls, fg)
368 }
369 if len(cls) > 0 {
370 b.WriteString(`<span class="`)
371 b.WriteString(strings.Join(cls, " "))
372 b.WriteString(`">`)
373 open = true
374 }
375 }
376 for i := 0; i < len(raw); {
377 esc := strings.IndexByte(raw[i:], '\x1b')
378 if esc < 0 {
379 b.WriteString(template.HTMLEscapeString(raw[i:]))
380 break
381 }
382 if esc > 0 {
383 b.WriteString(template.HTMLEscapeString(raw[i : i+esc]))
384 i += esc
385 }
386 if i+1 >= len(raw) || raw[i+1] != '[' {
387 i++
388 continue
389 }
390 j := i + 2
391 for j < len(raw) && ((raw[j] >= '0' && raw[j] <= '9') || raw[j] == ';') {
392 j++
393 }
394 if j >= len(raw) {
395 break
396 }
397 cmd := raw[j]
398 params := raw[i+2 : j]
399 i = j + 1
400 if cmd != 'm' {
401 continue
402 }
403 closeSpan()
404 if params == "" || params == "0" {
405 bold, dim, fg = false, false, ""
406 continue
407 }
408 for _, part := range strings.Split(params, ";") {
409 code, err := strconv.Atoi(part)
410 if err != nil {
411 continue
412 }
413 switch code {
414 case 0:
415 bold, dim, fg = false, false, ""
416 case 1:
417 bold = true
418 case 2:
419 dim = true
420 case 22:
421 bold, dim = false, false
422 case 39:
423 fg = ""
424 case 31, 91:
425 fg = "ansi-red"
426 case 32, 92:
427 fg = "ansi-green"
428 case 33, 93:
429 fg = "ansi-yellow"
430 case 34, 94:
431 fg = "ansi-blue"
432 case 35, 95:
433 fg = "ansi-magenta"
434 case 36, 96:
435 fg = "ansi-cyan"
436 case 30, 37, 90, 97:
437 fg = "ansi-muted"
438 }
439 }
440 openSpan()
441 }
442 closeSpan()
443 return template.HTML(b.String())
444}
445
338446// liveLogMarker stands in for the log when build.html is rendered for a
339447// live build; streamBuild splits the page there and streams the log into
340448// the gap. Git refs, paths and job names cannot hold the control byte.
internal/httpd/diff.go +141 · view
@@ -190,10 +190,151 @@ func highlightFile(f *diffFile) {
190190 hunk := f.Lines[start:end]
191191 assign(hunk, "del", highlightLines(lexer, sideText(hunk, "del")))
192192 assign(hunk, "add", highlightLines(lexer, sideText(hunk, "add")))
193 highlightIntraLine(hunk)
193194 start = end
194195 }
195196}
196197
198// highlightIntraLine marks the changed interior span on paired -/+ runs so
199// single-token edits pop out without scanning whole lines character by character.
200func highlightIntraLine(hunk []diffLine) {
201 for i := 0; i < len(hunk); {
202 if hunk[i].Class != "del" {
203 i++
204 continue
205 }
206 delStart := i
207 for i < len(hunk) && hunk[i].Class == "del" {
208 i++
209 }
210 delEnd := i
211 addStart := i
212 for i < len(hunk) && hunk[i].Class == "add" {
213 i++
214 }
215 addEnd := i
216 nDel, nAdd := delEnd-delStart, addEnd-addStart
217 if nDel == 0 || nAdd == 0 || nDel > 8 || nAdd > 8 {
218 continue
219 }
220 pairs := min(nDel, nAdd)
221 for k := 0; k < pairs; k++ {
222 dl := &hunk[delStart+k]
223 al := &hunk[addStart+k]
224 if dl.Code == "" || al.Code == "" || dl.Content == al.Content {
225 continue
226 }
227 dr, ar := []rune(dl.Content), []rune(al.Content)
228 pre := 0
229 for pre < len(dr) && pre < len(ar) && dr[pre] == ar[pre] {
230 pre++
231 }
232 suf := 0
233 for suf < len(dr)-pre && suf < len(ar)-pre && dr[len(dr)-1-suf] == ar[len(ar)-1-suf] {
234 suf++
235 }
236 minShared := 1
237 if nDel != nAdd {
238 minShared = 2
239 }
240 if pre < minShared && suf < minShared {
241 continue
242 }
243 dl.Code = template.HTML(markHTMLSpan(string(dl.Code), pre, len(dr)-suf, "idiff-del"))
244 al.Code = template.HTML(markHTMLSpan(string(al.Code), pre, len(ar)-suf, "idiff-add"))
245 }
246 }
247}
248
249// markHTMLSpan wraps visible runes [from, to) of balanced Chroma HTML in
250// <span class="cls">, closing and reopening any active tags at the boundaries.
251func markHTMLSpan(s string, from, to int, cls string) string {
252 if from >= to {
253 return s
254 }
255 var out strings.Builder
256 var open []string
257 pos := 0
258 inMark := false
259 openMark := func() {
260 if !inMark {
261 out.WriteString(`<span class="` + cls + `">`)
262 for _, t := range open {
263 out.WriteString(t)
264 }
265 inMark = true
266 }
267 }
268 closeMark := func() {
269 if inMark {
270 for range open {
271 out.WriteString("</span>")
272 }
273 out.WriteString("</span>")
274 for _, t := range open {
275 out.WriteString(t)
276 }
277 inMark = false
278 }
279 }
280 for i := 0; i < len(s); {
281 if s[i] == '<' {
282 j := strings.IndexByte(s[i:], '>')
283 if j < 0 {
284 out.WriteString(s[i:])
285 break
286 }
287 tag := s[i : i+j+1]
288 if strings.HasPrefix(tag, "</") {
289 if len(open) > 0 {
290 open = open[:len(open)-1]
291 }
292 } else if !strings.HasSuffix(tag, "/>") {
293 open = append(open, tag)
294 }
295 out.WriteString(tag)
296 i += j + 1
297 continue
298 }
299 if pos >= from && pos < to && !inMark {
300 for range open {
301 out.WriteString("</span>")
302 }
303 openMark()
304 } else if pos >= to && inMark {
305 closeMark()
306 }
307 if s[i] == '&' {
308 if semi := strings.IndexByte(s[i:], ';'); semi > 0 && semi <= 10 {
309 out.WriteString(s[i : i+semi+1])
310 i += semi + 1
311 pos++
312 continue
313 }
314 }
315 _, w := utf8DecodeRune(s[i:])
316 out.WriteString(s[i : i+w])
317 i += w
318 pos++
319 }
320 if inMark {
321 for range open {
322 out.WriteString("</span>")
323 }
324 out.WriteString("</span>")
325 }
326 return out.String()
327}
328
329func utf8DecodeRune(s string) (rune, int) {
330 for i, r := range s {
331 if i == 0 {
332 return r, len(string(r))
333 }
334 }
335 return 0, 1
336}
337
197338// sideText joins one side of a hunk: context plus the given change class.
198339// Content, not Text: the marker is already off it. Taking it off Text here
199340// meant stripping "+" and then "-", which ate the dash of an added line that
internal/httpd/diff_test.go +25 · view
@@ -206,3 +206,28 @@ func TestParseDiffKeepsDashAfterMarker(t *testing.T) {
206206 }
207207 }
208208}
209
210func TestParseDiffIntraLineHighlighting(t *testing.T) {
211 files := parseDiff(samplePatch)
212 var delCode, addCode string
213 for _, l := range files[0].Lines {
214 if l.Class == "del" && l.OldLine == 3 {
215 delCode = string(l.Code)
216 }
217 if l.Class == "add" && l.NewLine == 3 {
218 addCode = string(l.Code)
219 }
220 }
221 if !strings.Contains(delCode, `class="idiff-del"`) {
222 t.Errorf("deleted line missing idiff-del span: %s", delCode)
223 }
224 if !strings.Contains(addCode, `class="idiff-add"`) {
225 t.Errorf("added line missing idiff-add span: %s", addCode)
226 }
227 if got := stripTags(delCode); got != "func old() string {" {
228 t.Errorf("deleted line text corrupted: %q", got)
229 }
230 if got := stripTags(addCode); got != "func replaced() string {" {
231 t.Errorf("added line text corrupted: %q", got)
232 }
233}
internal/httpd/mractions.go +6 · view
@@ -179,6 +179,12 @@ func (s *Server) mrRetargetSubmit(w http.ResponseWriter, r *http.Request, u stor
179179 s.done(w, r, code, msg, s.mrRedirect)
180180}
181181
182// mrRebaseSubmit rebases the merge request's source branch onto its target.
183func (s *Server) mrRebaseSubmit(w http.ResponseWriter, r *http.Request, u store.User) {
184 _, msg, code := s.runControlCode(u, mrArgs(r, "rebase"))
185 s.done(w, r, code, msg, s.mrRedirect)
186}
187
182188// mrThreadSubmit resolves or reopens one review thread.
183189func (s *Server) mrThreadSubmit(w http.ResponseWriter, r *http.Request, u store.User) {
184190 verb := "resolve"
internal/httpd/mrrangediff.go +33 −1 · view
@@ -3,11 +3,42 @@ package httpd
33import (
44 "net/http"
55 "strconv"
6 "strings"
67
78 "gitbay.org/gitbay/internal/protocol"
89 "gitbay.org/gitbay/internal/store"
910)
1011
12type rangeDiffLine struct {
13 Class string
14 Text string
15}
16
17func parseRangeDiffLines(raw string) []rangeDiffLine {
18 if raw == "" {
19 return nil
20 }
21 rawLines := strings.Split(strings.TrimRight(raw, "\n"), "\n")
22 out := make([]rangeDiffLine, 0, len(rawLines))
23 for _, l := range rawLines {
24 cls := "rd-ctx"
25 switch {
26 case strings.HasPrefix(l, "++"), strings.HasPrefix(l, "+"):
27 cls = "rd-add"
28 case strings.HasPrefix(l, "--"), strings.HasPrefix(l, "-"):
29 cls = "rd-del"
30 case strings.HasPrefix(l, " +"):
31 cls = "rd-add"
32 case strings.HasPrefix(l, " -"):
33 cls = "rd-del"
34 case strings.Contains(l, ": ") && (strings.Contains(l, " ! ") || strings.Contains(l, " = ") || strings.Contains(l, " < ") || strings.Contains(l, " > ")):
35 cls = "rd-hdr"
36 }
37 out = append(out, rangeDiffLine{Class: cls, Text: l})
38 }
39 return out
40}
41
1142// mrRangeDiff renders what changed between two revisions of a merge
1243// request — the same comparison `mr range-diff` prints on the CLI and
1344// the iOS app already show — so a reviewer whose approval a force-push
@@ -50,6 +81,7 @@ func (s *Server) mrRangeDiff(w http.ResponseWriter, r *http.Request) {
5081 repoPage
5182 MR store.MR
5283 Diff string
84 Lines []rangeDiffLine
5385 Error string
54 }{p, m, out, errMsg})
86 }{p, m, out, parseRangeDiffLines(out), errMsg})
5587}
internal/httpd/notifyweb.go +9 −1 · view
@@ -64,8 +64,16 @@ func (s *Server) watchToggle(w http.ResponseWriter, r *http.Request, u store.Use
6464 }
6565 next := map[string]string{"": "watch", "watching": "mute", "muted": "unwatch"}
6666 verb := next[s.st.RepoWatchState(repo.ID, u.ID)]
67 switch r.FormValue("mode") {
68 case "default":
69 verb = "unwatch"
70 case "watching":
71 verb = "watch"
72 case "muted":
73 verb = "mute"
74 }
6775 if _, msg, ok := s.runControl(u, []string{"repo", verb, repo.Path()}); !ok {
6876 s.setFlash(w, msg)
6977 }
70 http.Redirect(w, r, "/"+repo.Path(), http.StatusSeeOther)
78 http.Redirect(w, r, safeReturnTo(r, "/"+repo.Path()), http.StatusSeeOther)
7179}
internal/httpd/palette_test.go +1 −1 · view
@@ -52,7 +52,7 @@ func TestSyntaxPaletteContrast(t *testing.T) {
5252 exempt map[chroma.TokenType]bool
5353 }{
5454 {lightStyle, map[string]chroma.Colour{
55 "page": chroma.NewColour(0xff, 0xff, 0xff),
55 "page": chroma.NewColour(0xf7, 0xf8, 0xfa),
5656 "code": chroma.NewColour(0xff, 0xff, 0xff),
5757 "add": chroma.NewColour(0xe4, 0xf6, 0xea),
5858 "del": chroma.NewColour(0xfd, 0xea, 0xea),
internal/httpd/queries.go +69 −11 · view
@@ -4,6 +4,7 @@ import (
44 "net/http"
55 "net/url"
66 "strconv"
7 "strings"
78
89 "gitbay.org/gitbay/internal/control"
910 "gitbay.org/gitbay/internal/protocol"
@@ -14,30 +15,44 @@ import (
1415// offering the next, through query run's own cursor.
1516const queryPerPage = 50
1617
17// queriesPage lists the viewer's saved queries (/{owner}/-/queries), or
18// runs one (/{owner}/-/queries/{name}) through query show and query run,
19// the reads the CLI makes. Saved queries are private: under anyone else's
20// name the page is not found.
18// queriesPage lists the viewer's saved queries (/{owner}/-/queries), runs
19// an ad-hoc query (?q=...), or runs a saved one (/{owner}/-/queries/{name}).
20// Saved queries are private: under anyone else's name the page is not found.
2121func (s *Server) queriesPage(w http.ResponseWriter, r *http.Request, viewer store.User) {
2222 if r.PathValue("owner") != viewer.Username {
2323 s.notFound(w, r)
2424 return
2525 }
2626 name := r.PathValue("name")
27 adHoc := strings.TrimSpace(r.URL.Query().Get("q"))
2728 data := struct {
2829 basePage
29 Tab string
30 Saved []control.SavedQueryOut
31 Query control.SavedQueryOut
32 Count int
33 Items []control.QueryItem
34 Next string
35 }{basePage: s.baseFor(viewer), Tab: "dashboard"}
30 Tab string
31 Saved []control.SavedQueryOut
32 Query control.SavedQueryOut
33 AdHoc string
34 Count int
35 Items []control.QueryItem
36 Next string
37 Notice string
38 }{basePage: s.baseFor(viewer), Tab: "dashboard", AdHoc: adHoc, Notice: s.takeFlash(w, r)}
3639 if name == "" {
3740 if msg, ok := s.runControlInto(viewer, []string{"query", "list"}, &data.Saved); !ok {
3841 http.Error(w, msg, http.StatusInternalServerError)
3942 return
4043 }
44 if adHoc != "" {
45 items, count, next, err := control.RunAdHocQuery(s.st, viewer, adHoc, r.URL.Query().Get("cursor"), queryPerPage)
46 if err != nil {
47 data.Notice = err.Error()
48 } else {
49 data.Items = items
50 data.Count = count
51 if next != "" {
52 data.Next = "?" + url.Values{"q": {adHoc}, "cursor": {next}}.Encode()
53 }
54 }
55 }
4156 s.render(w, "queries.html", data)
4257 return
4358 }
@@ -76,3 +91,46 @@ func (s *Server) queriesPage(w http.ResponseWriter, r *http.Request, viewer stor
7691 }
7792 s.render(w, "queries.html", data)
7893}
94
95// queriesSubmit saves, pins, unpins, or removes a saved query through the
96// same query commands the CLI runs.
97func (s *Server) queriesSubmit(w http.ResponseWriter, r *http.Request, viewer store.User) {
98 if r.PathValue("owner") != viewer.Username {
99 s.notFound(w, r)
100 return
101 }
102 base := "/" + viewer.Username + "/-/queries"
103 action := r.FormValue("action")
104 name := strings.TrimSpace(r.FormValue("name"))
105 switch action {
106 case "save":
107 qText := strings.TrimSpace(r.FormValue("query"))
108 argv := []string{"query", "save", name, qText}
109 if r.FormValue("force") == "on" {
110 argv = append(argv, "--force")
111 }
112 if _, msg, ok := s.runControl(viewer, argv); !ok {
113 s.setFlash(w, msg)
114 dest := base
115 if qText != "" {
116 dest += "?" + url.Values{"q": {qText}}.Encode()
117 }
118 http.Redirect(w, r, dest, http.StatusSeeOther)
119 return
120 }
121 http.Redirect(w, r, base+"/"+url.PathEscape(name), http.StatusSeeOther)
122 case "pin", "unpin":
123 if _, msg, ok := s.runControl(viewer, []string{"query", action, name}); !ok {
124 s.setFlash(w, msg)
125 }
126 http.Redirect(w, r, safeReturnTo(r, base), http.StatusSeeOther)
127 case "remove":
128 if _, msg, ok := s.runControl(viewer, []string{"query", "remove", name}); !ok {
129 s.setFlash(w, msg)
130 }
131 http.Redirect(w, r, base, http.StatusSeeOther)
132 default:
133 s.setFlash(w, "unknown query action")
134 http.Redirect(w, r, base, http.StatusSeeOther)
135 }
136}
internal/httpd/releaseactions.go +3 · view
@@ -73,6 +73,9 @@ func (s *Server) releaseSubmit(w http.ResponseWriter, r *http.Request, u store.U
7373 verb = "edit"
7474 }
7575 argv := []string{"release", verb, repo, tag}
76 if verb == "create" {
77 argv = append(argv, "--format", bodyFormat(r))
78 }
7679 if title != "" {
7780 argv = append(argv, "--title", title)
7881 }
internal/httpd/routes.go +6 · view
@@ -151,6 +151,8 @@ func (s *Server) Routes() []Route {
151151 Route{Method: "GET", Pattern: "/register", Handler: s.signupForm},
152152 Route{Method: "POST", Pattern: "/register", Mutating: true,
153153 Handler: s.checkOrigin(s.signupSubmit)},
154 Route{Method: "POST", Pattern: "/register/verify", Mutating: true,
155 Handler: s.checkOrigin(s.signupVerifySubmit)},
154156 )
155157 }
156158 routes = append(routes,
@@ -193,6 +195,8 @@ func (s *Server) Routes() []Route {
193195 Handler: s.checkOrigin(s.requireUser(s.orgMilestoneSubmit))},
194196 Route{Method: "GET", Pattern: "/bookmarks", Handler: s.requireUser(s.bookmarksPage)},
195197 Route{Method: "GET", Pattern: "/{owner}/-/queries", Handler: s.requireUser(s.queriesPage)},
198 Route{Method: "POST", Pattern: "/{owner}/-/queries", Mutating: true,
199 Handler: s.checkOrigin(s.requireUser(s.queriesSubmit))},
196200 Route{Method: "GET", Pattern: "/{owner}/-/queries/{name}", Handler: s.requireUser(s.queriesPage)},
197201 Route{Method: "GET", Pattern: "/{owner}/-/snippets/new", Handler: s.requireUser(s.snippetNewForm)},
198202 Route{Method: "POST", Pattern: "/{owner}/-/snippets/new", Mutating: true,
@@ -243,6 +247,8 @@ func (s *Server) Routes() []Route {
243247 Handler: s.checkOrigin(s.requireUser(s.mrDraftSubmit))},
244248 Route{Method: "POST", Pattern: "/{owner}/{repo}/mrs/{n}/retarget", Mutating: true,
245249 Handler: s.checkOrigin(s.requireUser(s.mrRetargetSubmit))},
250 Route{Method: "POST", Pattern: "/{owner}/{repo}/mrs/{n}/rebase", Mutating: true,
251 Handler: s.checkOrigin(s.requireUser(s.mrRebaseSubmit))},
246252 Route{Method: "POST", Pattern: "/{owner}/{repo}/mrs/{n}/thread", Mutating: true,
247253 Handler: s.checkOrigin(s.requireUser(s.mrThreadSubmit))},
248254 Route{Method: "POST", Pattern: "/{owner}/{repo}/mrs/{n}/diff-comment", Mutating: true,
internal/httpd/searchweb.go +116 · view
@@ -1,11 +1,14 @@
11package httpd
22
33import (
4 "encoding/json"
45 "net/http"
56 "strconv"
67 "strings"
78
89 "gitbay.org/gitbay/internal/control"
10 "gitbay.org/gitbay/internal/gitutil"
11 "gitbay.org/gitbay/internal/policy"
912 "gitbay.org/gitbay/internal/store"
1013)
1114
@@ -17,6 +20,12 @@ type searchResult struct {
1720 Href string
1821}
1922
23type paletteEntry struct {
24 Group string `json:"group"`
25 Label string `json:"label"`
26 Href string `json:"href"`
27}
28
2029// globalSearch is /search: repositories, issues and merge requests across
2130// the instance. It is readable without a session — a visitor sees exactly
2231// the public rows — so it runs control.Search directly rather than
@@ -26,6 +35,10 @@ func (s *Server) globalSearch(w http.ResponseWriter, r *http.Request) {
2635 if s.cfg.Web.Mode == "accounts" {
2736 viewer = s.viewer(r)
2837 }
38 if r.URL.Query().Get("format") == "palette" {
39 s.servePalette(w, r, viewer)
40 return
41 }
2942 q := strings.TrimSpace(r.URL.Query().Get("q"))
3043 kind := r.URL.Query().Get("kind")
3144 if kind != "repo" && kind != "issue" && kind != "mr" {
@@ -71,3 +84,106 @@ func searchHref(h control.SearchResult) string {
7184 return "/" + h.Repo
7285 }
7386}
87
88// servePalette answers Cmd+K / 't' jump queries with files, symbols, issues,
89// merge requests, and repositories the viewer can read.
90func (s *Server) servePalette(w http.ResponseWriter, r *http.Request, viewer store.User) {
91 q := strings.ToLower(strings.TrimSpace(r.URL.Query().Get("q")))
92 repoPath := strings.TrimSpace(r.URL.Query().Get("repo"))
93 var items []paletteEntry
94
95 if repoPath != "" {
96 if repo, err := s.st.RepoByPath(repoPath); err == nil {
97 grant := ""
98 if viewer.ID != 0 {
99 grant, _ = s.st.AccessRole(repo.ID, viewer.ID)
100 }
101 if policy.CanRead(viewer, repo, grant) {
102 dir := control.RepoDir(s.cfg.Server.Root, repo.OwnerName, repo.Name)
103 ref := strings.TrimSpace(r.URL.Query().Get("ref"))
104 if ref == "" {
105 ref = repo.DefaultBranch
106 }
107 if entries, err := gitutil.ListTreeRecursive(dir, ref, ""); err == nil {
108 count := 0
109 for _, e := range entries {
110 if e.Type != "blob" {
111 continue
112 }
113 if q != "" && !strings.Contains(strings.ToLower(e.Name), q) {
114 continue
115 }
116 items = append(items, paletteEntry{
117 Group: "File",
118 Label: e.Name,
119 Href: "/" + repo.Path() + "/blob/" + ref + "/" + e.Name,
120 })
121 count++
122 if count >= 40 {
123 break
124 }
125 }
126 }
127 if mrs, err := s.st.QueryMRs(repo.ID, store.MRFilter{State: "open", Limit: 15}); err == nil {
128 for _, m := range mrs {
129 lbl := "!" + strconv.FormatInt(m.Number, 10) + " " + m.Title
130 if q == "" || strings.Contains(strings.ToLower(lbl), q) {
131 items = append(items, paletteEntry{
132 Group: "MR",
133 Label: lbl,
134 Href: "/" + repo.Path() + "/mrs/" + strconv.FormatInt(m.Number, 10),
135 })
136 }
137 }
138 }
139 if issues, err := s.st.QueryIssues(repo.ID, store.IssueFilter{State: "open", Limit: 15}); err == nil {
140 for _, iss := range issues {
141 lbl := "#" + strconv.FormatInt(iss.Number, 10) + " " + iss.Title
142 if q == "" || strings.Contains(strings.ToLower(lbl), q) {
143 items = append(items, paletteEntry{
144 Group: "Issue",
145 Label: lbl,
146 Href: "/" + repo.Path() + "/issues/" + strconv.FormatInt(iss.Number, 10),
147 })
148 }
149 }
150 }
151 }
152 }
153 }
154
155 if len(q) >= 2 && len(q) <= 100 {
156 if hits, err := control.Search(s.st, s.cfg.Server.Root, viewer.ID, q, nil); err == nil {
157 for i, h := range hits {
158 if i >= 20 {
159 break
160 }
161 lbl := h.Repo
162 grp := "Repo"
163 if h.Number > 0 {
164 lbl = h.Repo + control.SearchMarker(h.Kind) + strconv.FormatInt(h.Number, 10) + " " + h.Title
165 if h.Kind == "mr" {
166 grp = "MR"
167 } else {
168 grp = "Issue"
169 }
170 }
171 items = append(items, paletteEntry{Group: grp, Label: lbl, Href: searchHref(h)})
172 }
173 }
174 } else if repoPath == "" {
175 if repos, err := s.st.ListPublicReposByActivity(); err == nil {
176 for i, rp := range repos {
177 if i >= 15 {
178 break
179 }
180 if q == "" || strings.Contains(strings.ToLower(rp.Path()), q) {
181 items = append(items, paletteEntry{Group: "Repo", Label: rp.Path(), Href: "/" + rp.Path()})
182 }
183 }
184 }
185 }
186
187 w.Header().Set("Content-Type", "application/json; charset=utf-8")
188 json.NewEncoder(w).Encode(map[string]any{"items": items})
189}
internal/httpd/settings.go +133 · view
@@ -32,6 +32,10 @@ type settingsPage struct {
3232 ScanFrequency string
3333 ScanHour int
3434 Runners []store.RepoRunner
35 Secrets []string
36 DeployKeys []deployKeyRow
37 Mirrors []mirrorRow
38 Domains []domainRow
3539 Access []accessRow
3640 Hooks []hookRow
3741 Deliveries []deliveryRow
@@ -41,6 +45,31 @@ type settingsPage struct {
4145 Submitted map[string]string
4246}
4347
48type deployKeyRow struct {
49 Fingerprint string `json:"fingerprint"`
50 Algo string `json:"algo"`
51 Mode string `json:"mode"`
52 Label string `json:"label"`
53 LastUsedAt string `json:"last_used_at"`
54 ExpiresAt string `json:"expires_at"`
55}
56
57type mirrorRow struct {
58 ID int64 `json:"id"`
59 Direction string `json:"direction"`
60 URL string `json:"url"`
61 Username string `json:"username"`
62 Pending bool `json:"pending"`
63 LastSync string `json:"last_sync"`
64 LastError string `json:"last_error"`
65}
66
67type domainRow struct {
68 Domain string `json:"domain"`
69 State string `json:"state"`
70 Verified string `json:"verified_at"`
71}
72
4473type accessRow struct {
4574 User string `json:"user"`
4675 Role string `json:"role"`
@@ -92,6 +121,14 @@ func (s *Server) settingsFormWith(w http.ResponseWriter, r *http.Request, u stor
92121 s.runControlInto(u, []string{"repo", "security", "status", repo.Path()}, &security)
93122 var runners []store.RepoRunner
94123 s.runControlInto(u, []string{"repo", "runner", "list", repo.Path()}, &runners)
124 var secrets []string
125 s.runControlInto(u, []string{"repo", "secret", "list", repo.Path()}, &secrets)
126 var deployKeys []deployKeyRow
127 s.runControlInto(u, []string{"repo", "deploy-key", "list", repo.Path()}, &deployKeys)
128 var mirrors []mirrorRow
129 s.runControlInto(u, []string{"repo", "mirror", "list", repo.Path()}, &mirrors)
130 var domains []domainRow
131 s.runControlInto(u, []string{"repo", "domain", "list", repo.Path()}, &domains)
95132 var access []accessRow
96133 s.runControlInto(u, []string{"repo", "access", "list", repo.Path()}, &access)
97134 var hooks []hookRow
@@ -105,6 +142,7 @@ func (s *Server) settingsFormWith(w http.ResponseWriter, r *http.Request, u stor
105142 "website": submitted.Get("website"),
106143 "topics": submitted.Get("topics"),
107144 "key": submitted.Get("key"),
145 "deploy-key": submitted.Get("deploy-key"),
108146 "user": submitted.Get("user"),
109147 "role": submitted.Get("role"),
110148 "url": submitted.Get("url"),
@@ -112,6 +150,10 @@ func (s *Server) settingsFormWith(w http.ResponseWriter, r *http.Request, u stor
112150 "name": submitted.Get("name"),
113151 "new-owner": submitted.Get("new-owner"),
114152 "jobs": submitted.Get("jobs"),
153 "secret-name": submitted.Get("secret-name"),
154 "mirror-url": submitted.Get("mirror-url"),
155 "mirror-user": submitted.Get("mirror-user"),
156 "domain": submitted.Get("domain"),
115157 }
116158 }
117159 s.render(w, "settings.html", settingsPage{
@@ -122,6 +164,10 @@ func (s *Server) settingsFormWith(w http.ResponseWriter, r *http.Request, u stor
122164 ScanFrequency: s.cfg.Security.Frequency(repo.Settings.SecurityFrequency),
123165 ScanHour: s.cfg.Security.Hour,
124166 Runners: runners,
167 Secrets: secrets,
168 DeployKeys: deployKeys,
169 Mirrors: mirrors,
170 Domains: domains,
125171 Access: access, Hooks: hooks, Deliveries: deliveries,
126172 Notice: notice,
127173 Saved: strings.HasPrefix(notice, "Saved "),
@@ -283,6 +329,85 @@ func (s *Server) settingsSubmit(w http.ResponseWriter, r *http.Request, u store.
283329 return
284330 case "runner-remove":
285331 argv = []string{"repo", "runner", "remove", repo, v("fingerprint")}
332 case "secret-set":
333 // Secret value travels on stdin only, never in argv, flash, or re-rendered HTML.
334 name := v("secret-name")
335 val := strings.TrimRight(r.FormValue("secret-value"), "\r\n")
336 if val == "" {
337 s.settingsFormWith(w, r, u, "enter a value for the build secret", r.Form)
338 return
339 }
340 if msg, ok := s.runControlStdin(u, []string{"repo", "secret", "set", repo, name}, val+"\n"); !ok {
341 s.settingsFormWith(w, r, u, msg, r.Form)
342 return
343 }
344 s.settingsRedirect(w, r, "Saved the build secret.")
345 return
346 case "secret-remove":
347 argv = []string{"repo", "secret", "remove", repo, v("secret-name")}
348 case "deploykey-add":
349 body := v("deploy-key")
350 if body == "" {
351 s.settingsFormWith(w, r, u, "paste a public key in authorized_keys format", r.Form)
352 return
353 }
354 argv := []string{"repo", "deploy-key", "add", repo}
355 if v("rw") == "on" {
356 argv = append(argv, "--rw")
357 }
358 if ttl := v("ttl"); ttl != "" {
359 argv = append(argv, "--ttl", ttl)
360 }
361 if msg, ok := s.runControlStdin(u, argv, body+"\n"); !ok {
362 s.settingsFormWith(w, r, u, msg, r.Form)
363 return
364 }
365 s.settingsRedirect(w, r, "Saved the deploy key.")
366 return
367 case "deploykey-remove":
368 argv = []string{"repo", "deploy-key", "remove", repo, v("fingerprint")}
369 case "mirror-add":
370 // Mirror token travels on stdin only, never in argv, flash, or re-rendered HTML.
371 argv := []string{"repo", "mirror", "add", repo, v("mirror-url"), "--direction", v("direction")}
372 if usr := v("mirror-user"); usr != "" {
373 argv = append(argv, "--username", usr)
374 }
375 var stdin string
376 if tok := strings.TrimSpace(r.FormValue("mirror-token")); tok != "" {
377 argv = append(argv, "--token-stdin")
378 stdin = tok + "\n"
379 }
380 if msg, ok := s.runControlStdin(u, argv, stdin); !ok {
381 s.settingsFormWith(w, r, u, msg, r.Form)
382 return
383 }
384 s.settingsRedirect(w, r, "Saved the mirror.")
385 return
386 case "mirror-remove":
387 argv = []string{"repo", "mirror", "remove", repo, v("id")}
388 case "mirror-sync":
389 if _, msg, ok := s.runControl(u, []string{"repo", "mirror", "sync", repo}); !ok {
390 s.settingsFormWith(w, r, u, msg, r.Form)
391 return
392 }
393 s.settingsRedirect(w, r, "Saved the mirror sync schedule.")
394 return
395 case "domain-add":
396 var claimed struct {
397 Domain string `json:"domain"`
398 ChallengeName string `json:"challenge_name"`
399 ChallengeValue string `json:"challenge_value"`
400 }
401 if msg, ok := s.runControlInto(u, []string{"repo", "domain", "add", repo, v("domain")}, &claimed); !ok {
402 s.settingsFormWith(w, r, u, msg, r.Form)
403 return
404 }
405 s.settingsRedirect(w, r, fmt.Sprintf("Saved the custom domain %s: add TXT %s = %s, then press Verify.", claimed.Domain, claimed.ChallengeName, claimed.ChallengeValue))
406 return
407 case "domain-verify":
408 argv = []string{"repo", "domain", "verify", repo, v("domain")}
409 case "domain-remove":
410 argv = []string{"repo", "domain", "remove", repo, v("domain")}
286411 case "access-grant":
287412 argv = []string{"repo", "access", "grant", repo, v("user"), v("role")}
288413 case "access-revoke":
@@ -401,6 +526,14 @@ func fieldLabel(field string) string {
401526 return "topics"
402527 case "runner-add", "runner-remove":
403528 return "runner"
529 case "secret-remove":
530 return "build secret"
531 case "deploykey-remove":
532 return "deploy key"
533 case "mirror-remove":
534 return "mirror"
535 case "domain-verify", "domain-remove":
536 return "custom domain"
404537 case "access-grant", "access-revoke":
405538 return "access"
406539 case "webhook-remove":
internal/httpd/web.go +168 −31 · view
@@ -4,6 +4,7 @@ import (
44 "bytes"
55 "crypto/sha256"
66 "encoding/hex"
7 "encoding/json"
78 "errors"
89 "fmt"
910 "hash/fnv"
@@ -354,6 +355,8 @@ type repoPage struct {
354355 Topics []string
355356 Pinned bool // by the viewer
356357 Marked bool // bookmarked by the viewer
358 Bookmarks int // public bookmark count
359 Forks int // public fork count
357360 Watch string // the viewer's watch state: watching, muted, or ""
358361 HasWiki bool
359362 Host string
@@ -436,12 +439,16 @@ func (s *Server) repoFor(w http.ResponseWriter, r *http.Request, ref string) (re
436439 }
437440 }
438441 openIssues, openMRs := s.st.OpenCounts(repo.ID)
442 bookmarksCount := s.st.BookmarkCount(repo.ID)
443 forksList, _ := s.st.ListForks(repo.ID)
439444 return repoPage{
440445 basePage: s.baseFor(viewer),
441446 CanAdmin: canAdmin,
442447 Mirrors: mirrors,
443448 Pinned: pinned,
444449 Marked: marked,
450 Bookmarks: bookmarksCount,
451 Forks: len(forksList),
445452 Watch: watch,
446453 HasWiki: s.hasWiki(repo),
447454 Host: s.cfg.SiteHost(),
@@ -777,6 +784,10 @@ func (s *Server) blob(w http.ResponseWriter, r *http.Request) {
777784 return
778785 }
779786 binary := gitutil.IsBinary(data) || len(data) > maxRenderBytes
787 if linesParam := r.URL.Query().Get("lines"); linesParam != "" && !binary {
788 s.serveBlobLines(w, filePath, data, linesParam)
789 return
790 }
780791 _, image := imageTypes[strings.ToLower(path.Ext(filePath))]
781792
782793 var codeHTML template.HTML
@@ -814,6 +825,12 @@ func (s *Server) blob(w http.ResponseWriter, r *http.Request) {
814825 // The file listing leads with the last commit now, so the facts about
815826 // the file itself are reported here instead.
816827 entry, _ := gitutil.StatPath(p.Dir, p.Ref, filePath)
828 var fileTip namedCommit
829 if base != "" {
830 if lc := s.namedCommits(gitutil.LastCommits(p.Dir, p.Ref, navDir(filePath), []string{base})); lc != nil {
831 fileTip = lc[base]
832 }
833 }
817834 s.render(w, "blob.html", struct {
818835 repoPage
819836 Crumbs []crumb
@@ -821,6 +838,8 @@ func (s *Server) blob(w http.ResponseWriter, r *http.Request) {
821838 Path string
822839 DirPath string
823840 RefKind string
841 Commit string
842 Tip namedCommit
824843 Binary bool
825844 Image bool
826845 Size int
@@ -834,10 +853,48 @@ func (s *Server) blob(w http.ResponseWriter, r *http.Request) {
834853 RenderedHTML template.HTML
835854 Nav fileNav
836855 Symbols []store.SymbolRow
837 }{p, cs, base, filePath, filePath, "blob", binary, image, len(data), lines,
856 }{p, cs, base, filePath, filePath, "blob", commit, fileTip, binary, image, len(data), lines,
838857 entry.Mode == "100755", entry.Mode == "120000", branches, codeHTML, renderable, rendered, renderedHTML, nav, fileSymbols})
839858}
840859
860func (s *Server) serveBlobLines(w http.ResponseWriter, filePath string, data []byte, spec string) {
861 aStr, bStr, ok := strings.Cut(spec, ":")
862 from, err1 := strconv.Atoi(aStr)
863 to, err2 := strconv.Atoi(bStr)
864 if !ok || err1 != nil || err2 != nil || from < 1 || to < from || to-from > 100 {
865 http.Error(w, "bad lines range", http.StatusBadRequest)
866 return
867 }
868 rawLines := strings.Split(strings.TrimSuffix(string(data), "\n"), "\n")
869 if from > len(rawLines) {
870 w.Header().Set("Content-Type", "application/json; charset=utf-8")
871 w.Write([]byte(`{"lines":[]}`))
872 return
873 }
874 if to > len(rawLines) {
875 to = len(rawLines)
876 }
877 type lineItem struct {
878 N int `json:"n"`
879 HTML string `json:"html"`
880 }
881 lexer := lexers.Match(filePath)
882 var highlighted []template.HTML
883 if lexer != nil {
884 highlighted = highlightLines(lexer, strings.Join(rawLines[from-1:to], "\n")+"\n")
885 }
886 out := make([]lineItem, 0, to-from+1)
887 for idx := from - 1; idx < to; idx++ {
888 h := template.HTMLEscapeString(rawLines[idx])
889 if k := idx - (from - 1); k < len(highlighted) && highlighted[k] != "" {
890 h = string(highlighted[k])
891 }
892 out = append(out, lineItem{N: idx + 1, HTML: h})
893 }
894 w.Header().Set("Content-Type", "application/json; charset=utf-8")
895 json.NewEncoder(w).Encode(map[string]any{"lines": out})
896}
897
841898// releases lists tag-anchored releases with notes and assets.
842899func (s *Server) releases(w http.ResponseWriter, r *http.Request) {
843900 s.releasesPage(w, r, "")
@@ -881,12 +938,13 @@ func (s *Server) releasesPage(w http.ResponseWriter, r *http.Request, previewFor
881938 }
882939 }
883940 }
884 // An edit keeps the release's stored format; a new release has no
885 // picker and is markdown, as release create stores with no --format.
941 // An edit keeps the release's stored format; a new release reads the
942 // format picker, defaulting to markdown.
886943 var d *draft
887944 if previewForm != "" {
888 format := "md"
945 format := bodyFormat(r)
889946 if tag, ok := strings.CutPrefix(previewForm, "release:"); ok {
947 format = "md"
890948 for _, v := range views {
891949 if v.Tag == tag {
892950 format = v.NotesFormat
@@ -1098,18 +1156,24 @@ func (s *Server) blame(w http.ResponseWriter, r *http.Request) {
10981156
10991157 type hunkView struct {
11001158 gitutil.BlameHunk
1101 ShortSHA string
1102 Date string
1103 Sig sigView
1104 Numbered []numberedLine
1159 ShortSHA string
1160 ParentSHA string
1161 Date string
1162 Sig sigView
1163 Numbered []numberedLine
11051164 }
1165 blameLexer := lexers.Match(filePath)
11061166 var hunks []hunkView
11071167 sigs := map[string]sigView{}
1168 parents := map[string]string{}
11081169 for _, h := range out.Hunks {
11091170 v, seen := sigs[h.SHA]
11101171 if !seen {
11111172 v, _ = s.sigFor(p.Repo, p.Dir, h.SHA)
11121173 sigs[h.SHA] = v
1174 if ps := gitutil.Parents(p.Dir, h.SHA); len(ps) > 0 {
1175 parents[h.SHA] = ps[0]
1176 }
11131177 }
11141178 date := h.Date
11151179 if t, err := time.Parse(time.RFC3339, h.Date); err == nil {
@@ -1119,10 +1183,18 @@ func (s *Server) blame(w http.ResponseWriter, r *http.Request) {
11191183 BlameHunk: gitutil.BlameHunk{SHA: h.SHA, AuthorName: h.AuthorName,
11201184 AuthorEmail: h.AuthorEmail, Summary: h.Summary,
11211185 StartLine: h.StartLine, Lines: h.Lines},
1122 ShortSHA: h.SHA[:min(10, len(h.SHA))], Date: date, Sig: v,
1186 ShortSHA: h.SHA[:min(10, len(h.SHA))], ParentSHA: parents[h.SHA], Date: date, Sig: v,
1187 }
1188 var hl []template.HTML
1189 if blameLexer != nil && len(h.Lines) > 0 {
1190 hl = highlightLines(blameLexer, strings.Join(h.Lines, "\n")+"\n")
11231191 }
11241192 for i, l := range h.Lines {
1125 hv.Numbered = append(hv.Numbered, numberedLine{h.StartLine + i, l})
1193 var code template.HTML
1194 if i < len(hl) {
1195 code = hl[i]
1196 }
1197 hv.Numbered = append(hv.Numbered, numberedLine{h.StartLine + i, l, code})
11261198 }
11271199 hunks = append(hunks, hv)
11281200 }
@@ -1158,6 +1230,7 @@ func (s *Server) blame(w http.ResponseWriter, r *http.Request) {
11581230type numberedLine struct {
11591231 N int
11601232 Text string
1233 Code template.HTML
11611234}
11621235
11631236// chromaFormatter emits class-based markup (no inline colors), so the
@@ -1915,7 +1988,7 @@ var hexColorPat = regexp.MustCompile(`^#[0-9a-fA-F]{6}$`)
19151988// 4.5:1. TestChipCanvasMatchesStylesheet keeps these in step with the
19161989// tokens.
19171990const (
1918 chipCanvasLight = "#ffffff"
1991 chipCanvasLight = "#f7f8fa"
19191992 chipCanvasDark = "#101114"
19201993 chipRatio = 4.5
19211994)
@@ -2091,11 +2164,24 @@ func (s *Server) issues(w http.ResponseWriter, r *http.Request) {
20912164 issues = issues[:listPage]
20922165 older = olderLink(r, issues[len(issues)-1].Number)
20932166 }
2167 ids := make([]int64, len(issues))
2168 for i, iss := range issues {
2169 ids[i] = iss.ID
2170 }
20942171 if labels, err := s.st.ListIssueLabels(p.Repo); err == nil {
20952172 for i := range issues {
20962173 issues[i].Labels = labels[issues[i].ID]
20972174 }
20982175 }
2176 if _, assignees, err := s.st.IssueLabelsFor(ids); err == nil {
2177 for i := range issues {
2178 issues[i].Assignees = assignees[issues[i].ID]
2179 }
2180 }
2181 commentCounts, err := s.st.IssueCommentCounts(ids)
2182 if err != nil {
2183 commentCounts = map[int64]int{}
2184 }
20992185 base := url.Values{"state": {state}, "label": {f.Label}, "assignee": {f.Assignee}, "author": {f.Author}, "milestone": {f.Milestone}, "q": {f.Search}}
21002186 readable, _ := control.ReadableScope(s.st, s.viewer(r), p.Repo)
21012187 allLabels, _ := s.st.ListLabels(p.Repo, readable)
@@ -2103,17 +2189,19 @@ func (s *Server) issues(w http.ResponseWriter, r *http.Request) {
21032189 facets := listFacets(base, []string{"open", "closed", "all"}, state, allLabels, openMS, false)
21042190 s.render(w, "issues.html", struct {
21052191 repoPage
2106 State string
2107 Label string
2108 Query string
2109 Filters []listFilter
2110 Facets []facetGroup
2111 Issues []store.Issue
2112 LabelColors map[string]template.CSS
2113 Older string
2192 State string
2193 Label string
2194 Query string
2195 Filters []listFilter
2196 Facets []facetGroup
2197 Issues []store.Issue
2198 CommentCounts map[int64]int
2199 People []string
2200 LabelColors map[string]template.CSS
2201 Older string
21142202 }{p, state, f.Label, f.Search,
21152203 activeFilters(state, [][2]string{{"label", f.Label}, {"assignee", f.Assignee}, {"author", f.Author}, {"milestone", f.Milestone}}),
2116 facets, issues, s.labelColors(p.Repo), older})
2204 facets, issues, commentCounts, s.repoPeople(p.Repo), s.labelColors(p.Repo), older})
21172205}
21182206
21192207func (s *Server) issue(w http.ResponseWriter, r *http.Request) {
@@ -2146,14 +2234,12 @@ func (s *Server) issuePage(w http.ResponseWriter, r *http.Request, previewForm s
21462234 return
21472235 }
21482236 md := s.ugcFor(r, p.Repo)
2149 // An edit keeps the issue's stored format; a comment has no picker
2150 // and is markdown, which is what issue comment stores with no
2151 // --format.
2237 // An edit keeps the issue's stored format; a comment reads the format picker.
21522238 var d *draft
21532239 if previewForm != "" {
21542240 format := iss.BodyFormat
21552241 if previewForm == "comment" {
2156 format = "md"
2242 format = bodyFormat(r)
21572243 }
21582244 d = s.draftFor(r, p.Repo, previewForm, "body", format)
21592245 }
@@ -2237,9 +2323,41 @@ func (s *Server) canEditItem(r *http.Request, repo store.Repo, author string) bo
22372323type mrRow struct {
22382324 store.MR
22392325 Check string
2326 Review string
22402327 Comments int
22412328}
22422329
2330// summarizeReviews computes the aggregate non-stale review state among
2331// reviewers who count for merge gates: "changes_requested" beats "approved".
2332func summarizeReviews(st *store.Store, repo store.Repo, revs []store.MRReview) string {
2333 if len(revs) == 0 {
2334 return ""
2335 }
2336 counts := control.ReviewersWhoCount(st, repo, revs)
2337 latest := map[string]string{}
2338 for _, rv := range revs {
2339 if rv.Stale || !counts[rv.Reviewer] {
2340 continue
2341 }
2342 if rv.Verdict == "approve" || rv.Verdict == "request_changes" {
2343 latest[rv.Reviewer] = rv.Verdict
2344 }
2345 }
2346 approved := false
2347 for _, v := range latest {
2348 if v == "request_changes" {
2349 return "changes_requested"
2350 }
2351 if v == "approve" {
2352 approved = true
2353 }
2354 }
2355 if approved {
2356 return "approved"
2357 }
2358 return ""
2359}
2360
22432361func (s *Server) mrs(w http.ResponseWriter, r *http.Request) {
22442362 p, ok := s.repoFor(w, r, "")
22452363 if !ok {
@@ -2283,6 +2401,10 @@ func (s *Server) mrs(w http.ResponseWriter, r *http.Request) {
22832401 if err != nil {
22842402 comments = map[int64]int{}
22852403 }
2404 reviewsMap, err := s.st.MRReviewsFor(ids)
2405 if err != nil {
2406 reviewsMap = map[int64][]store.MRReview{}
2407 }
22862408 labels, err := s.st.ListMRLabels(p.Repo)
22872409 if err != nil {
22882410 labels = map[int64][]string{}
@@ -2290,7 +2412,11 @@ func (s *Server) mrs(w http.ResponseWriter, r *http.Request) {
22902412 rows := make([]mrRow, len(mrs))
22912413 for i, m := range mrs {
22922414 m.Labels = labels[m.ID]
2293 rows[i] = mrRow{MR: m, Check: checks[m.HeadSHA], Comments: comments[m.ID]}
2415 rows[i] = mrRow{
2416 MR: m, Check: checks[m.HeadSHA],
2417 Review: summarizeReviews(s.st, p.Repo, reviewsMap[m.ID]),
2418 Comments: comments[m.ID],
2419 }
22942420 }
22952421 base := url.Values{"state": {state}, "label": {mf.Label}, "author": {mf.Author}, "milestone": {mf.Milestone}, "q": {mf.Search}}
22962422 readable, _ := control.ReadableScope(s.st, s.viewer(r), p.Repo)
@@ -2305,12 +2431,13 @@ func (s *Server) mrs(w http.ResponseWriter, r *http.Request) {
23052431 Filters []listFilter
23062432 Facets []facetGroup
23072433 MRs []mrRow
2434 People []string
23082435 LabelColors map[string]template.CSS
23092436 Older string
23102437 CanOpenMR bool
23112438 }{p, state, mf.Search,
23122439 activeFilters(state, [][2]string{{"label", mf.Label}, {"author", mf.Author}, {"milestone", mf.Milestone}}),
2313 facets, rows, s.labelColors(p.Repo), older, canOpenMR})
2440 facets, rows, s.repoPeople(p.Repo), s.labelColors(p.Repo), older, canOpenMR})
23142441}
23152442
23162443func (s *Server) mr(w http.ResponseWriter, r *http.Request) {
@@ -2369,7 +2496,17 @@ func (s *Server) mrPage(w http.ResponseWriter, r *http.Request, previewForm stri
23692496 }
23702497 }
23712498 var diffTruncated bool
2372 if base != "" {
2499 selectedCommit := strings.TrimSpace(r.URL.Query().Get("commit"))
2500 if selectedCommit != "" {
2501 if full, err := gitutil.ResolveRef(p.Dir, selectedCommit); err == nil {
2502 selectedCommit = full
2503 if patch, truncated, err := gitutil.ShowPatch(p.Dir, full, 4<<20); err == nil {
2504 files, diffTruncated = parseDiff(patch), truncated
2505 }
2506 } else {
2507 selectedCommit = ""
2508 }
2509 } else if base != "" {
23732510 if patch, truncated, err := gitutil.Diff(p.Dir, base, headRef, 4<<20); err == nil {
23742511 files, diffTruncated = parseDiff(patch), truncated
23752512 }
@@ -2478,13 +2615,12 @@ func (s *Server) mrPage(w http.ResponseWriter, r *http.Request, previewForm stri
24782615 // The merge requests this one superseded when it was closed, so the
24792616 // page it points to can also say what it supersedes.
24802617 supersedes, _ := s.st.MRsSuperseding(p.Repo.ID, m.Number)
2481 // An edit keeps the merge request's stored format; a comment has no
2482 // picker and is markdown, as mr comment stores with no --format.
2618 // An edit keeps the merge request's stored format; a comment reads the format picker.
24832619 var d *draft
24842620 if previewForm != "" {
24852621 format := m.BodyFormat
24862622 if previewForm == "comment" {
2487 format = "md"
2623 format = bodyFormat(r)
24882624 }
24892625 d = s.draftFor(r, p.Repo, previewForm, "body", format)
24902626 }
@@ -2525,11 +2661,12 @@ func (s *Server) mrPage(w http.ResponseWriter, r *http.Request, previewForm stri
25252661 People []string
25262662 Draft *draft
25272663 Layout diffLayout
2664 SelectedCommit string
25282665 Reactions map[int64]reactionBar
25292666 }{p, m, view, md(m.Body, m.BodyFormat), checks, combined, renderComments(comments, md),
25302667 reviewRows, files, diffTruncated, stat, commits, commitsTotal, branches, s.canEditItem(r, p.Repo, m.Author),
25312668 canWrite, unresolved, pendingComments, revisions, s.takeFlash(w, r), detachedThreads, stackedOn, stacked, supersedes, gates,
2532 sourceGone(p, m), headMerged, headPruned, base, s.labelColors(p.Repo), allLabels, s.repoPeople(p.Repo), d, layout, bars})
2669 sourceGone(p, m), headMerged, headPruned, base, s.labelColors(p.Repo), allLabels, s.repoPeople(p.Repo), d, layout, selectedCommit, bars})
25332670}
25342671
25352672// sourceGone reports whether an MR's source branch no longer exists: the
internal/httpd/webux_test.go +124 · view
@@ -172,3 +172,127 @@ func TestAccountAndAdminUX(t *testing.T) {
172172 }
173173 }
174174}
175
176func TestPaletteJSONAndSafeReturnTo(t *testing.T) {
177 st, err := store.Open(":memory:")
178 if err != nil {
179 t.Fatal(err)
180 }
181 defer st.Close()
182 if err := st.MigrateUp(); err != nil {
183 t.Fatal(err)
184 }
185 uid, _ := st.CreateUser("alice", false)
186 repoID, _ := st.CreateRepo("user", uid, "rocket", "public")
187 st.CreateIssue(repoID, uid, "launch pad calibration", "body", "md")
188
189 var cfg config.Config
190 cfg.Server.Root = t.TempDir()
191 cfg.Server.SiteURL = "https://forge.test"
192 cfg.Web.Mode = "accounts"
193 srv := New(cfg, st, nil)
194 cookie := sessionCookieFor(t, srv, st, uid)
195 h := srv.Handler()
196
197 // Palette JSON endpoint returns matching repos and issues.
198 req := httptest.NewRequest("GET", "/search?format=palette&repo=alice/rocket&q=launch", nil)
199 req.AddCookie(cookie)
200 rec := httptest.NewRecorder()
201 h.ServeHTTP(rec, req)
202 if rec.Code != http.StatusOK || !strings.Contains(rec.Header().Get("Content-Type"), "application/json") {
203 t.Fatalf("palette search: %d %q", rec.Code, rec.Header().Get("Content-Type"))
204 }
205 if !strings.Contains(rec.Body.String(), "launch pad calibration") {
206 t.Errorf("palette response missing issue: %s", rec.Body.String())
207 }
208
209 // safeReturnTo preserves subpage under repo and rejects off-site or unrelated paths.
210 rSub := httptest.NewRequest("POST", "https://forge.test/alice/rocket/pin", nil)
211 rSub.Host = "forge.test"
212 rSub.Header.Set("Referer", "https://forge.test/alice/rocket/issues/1")
213 if got := safeReturnTo(rSub, "/alice/rocket"); got != "/alice/rocket/issues/1" {
214 t.Errorf("safeReturnTo subpage = %q, want /alice/rocket/issues/1", got)
215 }
216 rEvil := httptest.NewRequest("POST", "https://forge.test/alice/rocket/pin", nil)
217 rEvil.Host = "forge.test"
218 rEvil.Header.Set("Referer", "https://evil.example/alice/rocket/issues/1")
219 if got := safeReturnTo(rEvil, "/alice/rocket"); got != "/alice/rocket" {
220 t.Errorf("safeReturnTo cross-origin = %q, want /alice/rocket", got)
221 }
222}
223
224func TestANSIBuildLogAndSavedQueriesWebWrite(t *testing.T) {
225 got := string(ansiHTML("\x1b[1;31mFAIL\x1b[0m <script>alert(1)</script> \x1b[32mPASS\x1b[0m"))
226 for _, want := range []string{`class="ansi-bold ansi-red"`, `FAIL</span>`, `&lt;script&gt;`, `class="ansi-green"`, `PASS</span>`} {
227 if !strings.Contains(got, want) {
228 t.Errorf("ansiHTML missing %q in %s", want, got)
229 }
230 }
231
232 st, err := store.Open(":memory:")
233 if err != nil {
234 t.Fatal(err)
235 }
236 defer st.Close()
237 if err := st.MigrateUp(); err != nil {
238 t.Fatal(err)
239 }
240 uid, _ := st.CreateUser("alice", false)
241 repoID, _ := st.CreateRepo("user", uid, "app", "public")
242 st.CreateIssue(repoID, uid, "triage target", "", "md")
243
244 var cfg config.Config
245 cfg.Server.Root = t.TempDir()
246 cfg.Server.SiteURL = "https://forge.test"
247 cfg.Web.Mode = "accounts"
248 srv := New(cfg, st, nil)
249 cookie := sessionCookieFor(t, srv, st, uid)
250 h := srv.Handler()
251
252 // Save a query over the web, pin it, and run an ad-hoc query.
253 form := url.Values{"action": {"save"}, "name": {"triage"}, "query": {"is:open"}}
254 req := httptest.NewRequest("POST", "https://forge.test/alice/-/queries", strings.NewReader(form.Encode()))
255 req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
256 req.Header.Set("Origin", "https://forge.test")
257 req.AddCookie(cookie)
258 rec := httptest.NewRecorder()
259 h.ServeHTTP(rec, req)
260 if rec.Code != http.StatusSeeOther || rec.Header().Get("Location") != "/alice/-/queries/triage" {
261 t.Fatalf("save query: %d loc=%q", rec.Code, rec.Header().Get("Location"))
262 }
263
264 req = httptest.NewRequest("GET", "/alice/-/queries?q=is%3Aopen", nil)
265 req.AddCookie(cookie)
266 rec = httptest.NewRecorder()
267 h.ServeHTTP(rec, req)
268 if rec.Code != http.StatusOK || !strings.Contains(rec.Body.String(), "triage target") {
269 t.Fatalf("ad-hoc query: %d\n%s", rec.Code, rec.Body.String())
270 }
271}
272
273func TestSettingsParitySectionsAndBrowserSessions(t *testing.T) {
274 e := newSettingsEnv(t)
275 rr := e.post(e.alice, url.Values{"field": {"secret-set"}, "secret-name": {"API_KEY"}, "secret-value": {"super-secret-val"}})
276 if rr.Code != http.StatusSeeOther {
277 t.Fatalf("secret-set: %d %s", rr.Code, rr.Body.String())
278 }
279 body := e.page(e.alice).Body.String()
280 if !strings.Contains(body, "API_KEY") || strings.Contains(body, "super-secret-val") {
281 t.Fatalf("secret visibility wrong on settings page:\n%s", body)
282 }
283 for _, want := range []string{`id="buildsecrets"`, `id="deploykeys"`, `id="mirrors"`, `id="domains"`} {
284 if !strings.Contains(body, want) {
285 t.Errorf("repo settings missing %s", want)
286 }
287 }
288
289 // Account settings lists browser sessions and revokes one.
290 cookie := sessionCookieFor(t, e.s, e.st, e.alice.ID)
291 req := httptest.NewRequest("GET", "/settings", nil)
292 req.AddCookie(cookie)
293 rec := httptest.NewRecorder()
294 e.s.accountPage(rec, req, e.alice)
295 if !strings.Contains(rec.Body.String(), `id="sessions"`) || !strings.Contains(rec.Body.String(), `this browser`) {
296 t.Errorf("account settings missing browser sessions:\n%s", rec.Body.String())
297 }
298}
internal/web/classes_test.go +17 · view
@@ -76,6 +76,19 @@ func TestEveryTemplateClassHasARule(t *testing.T) {
7676 for _, m := range attrRe.FindAllStringSubmatch(clean, -1) {
7777 for _, c := range strings.Fields(m[1]) {
7878 if strings.Contains(c, "\x00") {
79 prefix, _, _ := strings.Cut(c, "\x00")
80 if prefix != "" {
81 hasPrefix := false
82 for s := range styled {
83 if strings.HasPrefix(s, prefix) {
84 hasPrefix = true
85 break
86 }
87 }
88 if !hasPrefix {
89 missing[prefix+"*"] = append(missing[prefix+"*"], e.Name())
90 }
91 }
7992 continue // composed at render time; the concrete values have rules
8093 }
8194 if !styled[c] {
@@ -83,6 +96,10 @@ func TestEveryTemplateClassHasARule(t *testing.T) {
8396 }
8497 }
8598 }
99 // Build/check states use check-*, never badge-* (which is for signatures).
100 if strings.Contains(string(src), `badge-{{.}}`) {
101 t.Errorf("%s uses badge-{{.}} instead of check-{{.}}", e.Name())
102 }
86103 }
87104 var names []string
88105 for c := range missing {
internal/web/static/app.js +690 −41 · view
@@ -53,8 +53,9 @@
5353 if (pre.dataset.copyWired) continue;
5454 pre.dataset.copyWired = '1';
5555 const code = pre.querySelector('code') || pre;
56 const rawText = code.textContent.trim();
5657 const wrap = document.createElement('div');
57 wrap.className = 'copywrap';
58 wrap.className = rawText.includes('\n') ? 'copywrap' : 'copywrap oneline';
5859 pre.parentNode.insertBefore(wrap, pre);
5960 wrap.appendChild(pre);
6061 const btn = document.createElement('button');
@@ -77,6 +78,38 @@
7778 }
7879
7980 document.addEventListener('click', async (e) => {
81 const urlBtn = e.target.closest('button[data-copy-url]');
82 if (urlBtn) {
83 const orig = urlBtn.textContent;
84 try {
85 const res = await fetch(urlBtn.dataset.copyUrl, { credentials: 'same-origin' });
86 if (!res.ok) throw new Error('fetch failed');
87 await navigator.clipboard.writeText(await res.text());
88 urlBtn.textContent = 'copied';
89 showToast('File copied to clipboard');
90 setTimeout(() => { urlBtn.textContent = orig; }, 1400);
91 } catch {
92 showToast('Copy failed', true);
93 }
94 return;
95 }
96 const quoteBtn = e.target.closest('button[data-quote-from]');
97 if (quoteBtn) {
98 const art = document.getElementById(quoteBtn.dataset.quoteFrom);
99 const ta = document.getElementById('main-comment-box') || document.querySelector('form.commentform textarea[name="body"]');
100 if (art && ta) {
101 const rendered = art.querySelector('.rendered');
102 const text = (rendered ? rendered.innerText : '').trim();
103 if (text) {
104 const quoted = text.split('\n').map((l) => '> ' + l).join('\n') + '\n\n';
105 ta.value = (ta.value ? ta.value.replace(/\s*$/, '\n\n') : '') + quoted;
106 ta.focus();
107 ta.setSelectionRange(ta.value.length, ta.value.length);
108 ta.scrollIntoView({ behavior: 'smooth', block: 'center' });
109 }
110 }
111 return;
112 }
80113 const btn = e.target.closest('button[data-copy]');
81114 if (!btn) return;
82115 const orig = btn.textContent;
@@ -124,17 +157,27 @@
124157 }
125158
126159 let swapSel = null;
127 if (form.classList.contains('reactions')) {
128 swapSel = 'main#content';
160 let keepPopoverIdx = -1;
161 let foldId = '';
162 if (form.classList.contains('reactions') && form.dataset.reactSlot !== undefined) {
163 swapSel = `form.reactions[data-react-slot="${CSS.escape(form.dataset.reactSlot)}"]`;
129164 } else if (form.closest('.identity')) {
130165 swapSel = '.identity';
131166 } else if (form.closest('.aside .popover')) {
132167 swapSel = '.aside';
168 const openPop = form.closest('.aside .popover');
169 const allPops = Array.from(document.querySelectorAll('.aside .popover'));
170 keepPopoverIdx = allPops.indexOf(openPop);
133171 } else if (form.dataset.notifForm) {
134172 swapSel = '#notif-root';
135 } else {
136 return;
173 } else if (form.closest('details.difffold') && (form.classList.contains('composing') || form.closest('details.threadreply') || form.classList.contains('threadact'))) {
174 const fold = form.closest('details.difffold');
175 if (fold && fold.id) {
176 foldId = fold.id;
177 swapSel = '#' + CSS.escape(fold.id);
178 }
137179 }
180 if (!swapSel) return;
138181 e.preventDefault();
139182 const data = new FormData(form);
140183 if (e.submitter && e.submitter.name) {
@@ -151,12 +194,29 @@
151194 if (!res.ok) { form.submit(); return; }
152195 const html = await res.text();
153196 const doc = new DOMParser().parseFromString(html, 'text/html');
197 const errBanner = doc.querySelector('main .error');
198 if (errBanner) {
199 showToast(errBanner.textContent.trim(), true);
200 return;
201 }
154202 const next = doc.querySelector(swapSel);
155203 const cur = document.querySelector(swapSel);
156204 if (next && cur) {
205 if (foldId) next.open = true;
157206 cur.replaceWith(next);
158207 initCopyButtons(next);
159 if (swapSel === '#notif-root') {
208 if (swapSel === '.identity') {
209 const nextPins = doc.querySelector('.railpins');
210 const curPins = document.querySelector('.railpins');
211 if (nextPins && curPins) curPins.replaceWith(nextPins);
212 } else if (swapSel === '.aside' && keepPopoverIdx >= 0) {
213 const newPops = next.querySelectorAll('.popover');
214 if (newPops[keepPopoverIdx]) newPops[keepPopoverIdx].open = true;
215 } else if (foldId) {
216 const nextAside = doc.querySelector('.aside');
217 const curAside = document.querySelector('.aside');
218 if (nextAside && curAside) curAside.replaceWith(nextAside);
219 } else if (swapSel === '#notif-root') {
160220 const nextBell = doc.querySelector('.rail a[href="/notifications"]');
161221 const curBell = document.querySelector('.rail a[href="/notifications"]');
162222 if (nextBell && curBell) curBell.replaceWith(nextBell);
@@ -187,7 +247,8 @@
187247 if (existing) existing.remove();
188248
189249 const base = url.pathname;
190 const cols = row.closest('table')?.classList.contains('split') ? 4 : 3;
250 const isSplit = row.closest('table')?.classList.contains('split');
251 const cols = isSplit ? 4 : 3;
191252 const tr = document.createElement('tr');
192253 tr.id = 'inline-compose-row';
193254 tr.className = 'threadrow';
@@ -208,25 +269,52 @@
208269 };
209270 form.append(hidden('path', cpath), hidden('line', cline), hidden('side', cside));
210271
211 if (cside !== 'old') {
212 const pRange = document.createElement('p');
213 pRange.className = 'hint';
214 pRange.textContent = `Line ${cline} — use \`\`\`suggestion to propose replacement lines`;
215 form.appendChild(pRange);
216 }
217
218272 const pArea = document.createElement('p');
219273 const ta = document.createElement('textarea');
220274 ta.name = 'body';
221 ta.rows = 3;
275 ta.rows = 4;
222276 ta.placeholder = `Comment on ${cpath}:${cline}`;
223277 ta.required = true;
224278 pArea.appendChild(ta);
225279
280 let startInp = null;
281 if (cside !== 'old') {
282 const pRange = document.createElement('p');
283 pRange.className = 'hint';
284 const lbl = document.createElement('label');
285 lbl.style.display = 'inline';
286 lbl.textContent = 'From line ';
287 startInp = document.createElement('input');
288 startInp.type = 'number';
289 startInp.name = 'start_line';
290 startInp.min = '1';
291 startInp.max = cline;
292 startInp.placeholder = cline;
293 startInp.style.width = '5rem';
294 startInp.style.height = '26px';
295 lbl.appendChild(startInp);
296 const bSug = document.createElement('button');
297 bSug.type = 'button';
298 bSug.className = 'linklike';
299 bSug.style.marginLeft = '8px';
300 bSug.textContent = 'Insert suggestion';
301 bSug.addEventListener('click', () => {
302 const srcCell = isSplit ? row.querySelectorAll('td.src')[1] : row.querySelector('td.src');
303 const origLine = srcCell ? srcCell.textContent : '';
304 const block = '```suggestion\n' + origLine + '\n```\n';
305 const pos = ta.selectionStart ?? ta.value.length;
306 ta.value = ta.value.slice(0, pos) + block + ta.value.slice(pos);
307 ta.focus();
308 });
309 pRange.append(lbl, document.createTextNode(` to ${cline} · `), bSug);
310 form.appendChild(pRange);
311 }
312
226313 const pAct = document.createElement('p');
227314 pAct.className = 'btngroup';
228315 const bNow = document.createElement('button');
229316 bNow.type = 'submit';
317 bNow.className = 'btn';
230318 bNow.textContent = 'Comment';
231319 const bPend = document.createElement('button');
232320 bPend.type = 'submit';
@@ -248,7 +336,13 @@
248336 ta.focus();
249337 });
250338
251 // ---- 5. Cmd+K Command Palette ----
339 // ---- 5. Cmd+K Command Palette (with live repo/file/issue/MR search) ----
340 function currentRepoContext() {
341 const head = document.querySelector('.repohead [data-repo], .repohead[data-repo]');
342 if (!head) return { repo: '', ref: '' };
343 return { repo: head.dataset.repo || '', ref: head.dataset.ref || '' };
344 }
345
252346 function collectCommands() {
253347 const items = [];
254348 const seen = new Set();
@@ -263,6 +357,12 @@
263357 for (const a of document.querySelectorAll('.railpins .raildrop a')) {
264358 add('Pinned', a.textContent.trim(), a.getAttribute('href'));
265359 }
360 for (const a of document.querySelectorAll('.railusermenu .raildrop a')) {
361 const txt = a.textContent.trim();
362 if (txt.includes('queries') || txt.includes('snippets') || txt.includes('Bookmarks')) {
363 add('Account', txt, a.getAttribute('href'));
364 }
365 }
266366 add('Navigate', 'Dashboard', '/');
267367 add('Navigate', 'Explore repositories', '/explore');
268368 add('Navigate', 'Global search', '/search');
@@ -272,31 +372,44 @@
272372 return items;
273373 }
274374
275 function openPalette() {
375 let paletteFetchTimer = 0;
376 function openPalette(filesOnly = false) {
276377 const dlg = document.getElementById('cmdk');
277378 if (!(dlg instanceof HTMLDialogElement)) return;
278379 const input = dlg.querySelector('input');
279380 const list = dlg.querySelector('ul');
280 const all = collectCommands();
381 const ctx = currentRepoContext();
382 const localItems = filesOnly ? [] : collectCommands();
383 let remoteItems = [];
281384 let active = 0;
282385
283386 const render = () => {
284387 const raw = input.value.trim();
285388 const q = raw.toLowerCase();
286 const filtered = q ? all.filter((it) => (it.label + ' ' + it.group).toLowerCase().includes(q)) : all.slice();
389 const merged = [];
390 const seen = new Set();
391 for (const it of [...remoteItems, ...localItems]) {
392 if (!it.href || seen.has(it.href)) continue;
393 if (q && !(it.label + ' ' + it.group).toLowerCase().includes(q)) continue;
394 seen.add(it.href);
395 merged.push(it);
396 }
287397 if (raw) {
288 filtered.push({ group: 'Search', label: `Search “${raw}”…`, href: '/search?q=' + encodeURIComponent(raw) });
398 if (ctx.repo) {
399 merged.push({ group: 'Code', label: `Search "${raw}" in ${ctx.repo}…`, href: `/${ctx.repo}/search?q=` + encodeURIComponent(raw) });
400 }
401 merged.push({ group: 'Search', label: `Search "${raw}" across site…`, href: '/search?q=' + encodeURIComponent(raw) });
289402 }
290 active = Math.min(active, Math.max(0, filtered.length - 1));
403 active = Math.min(active, Math.max(0, merged.length - 1));
291404 list.textContent = '';
292 if (filtered.length === 0) {
405 if (merged.length === 0) {
293406 const li = document.createElement('li');
294407 li.className = 'cmdk-empty';
295 li.textContent = 'No matching destinations';
408 li.textContent = filesOnly ? 'Type to jump to any file in this repository…' : 'No matching destinations';
296409 list.appendChild(li);
297410 return;
298411 }
299 filtered.forEach((it, idx) => {
412 merged.slice(0, 50).forEach((it, idx) => {
300413 const li = document.createElement('li');
301414 const a = document.createElement('a');
302415 a.href = it.href;
@@ -312,12 +425,34 @@
312425 });
313426 };
314427
428 const loadRemote = (q) => {
429 const params = new URLSearchParams({ format: 'palette', q });
430 if (ctx.repo) params.set('repo', ctx.repo);
431 if (ctx.ref) params.set('ref', ctx.ref);
432 fetch('/search?' + params.toString(), { credentials: 'same-origin' })
433 .then((r) => (r.ok ? r.json() : null))
434 .then((data) => {
435 if (data && Array.isArray(data.items)) {
436 remoteItems = filesOnly ? data.items.filter((x) => x.group === 'File') : data.items;
437 render();
438 }
439 })
440 .catch(() => {});
441 };
442
443 input.placeholder = filesOnly && ctx.repo ? `Find file in ${ctx.repo}…` : 'Jump to repository, file, issue, MR, or page…';
315444 input.value = '';
316445 render();
446 loadRemote('');
317447 if (!dlg.open) dlg.showModal();
318448 input.focus();
319449
320 input.oninput = () => { active = 0; render(); };
450 input.oninput = () => {
451 active = 0;
452 render();
453 clearTimeout(paletteFetchTimer);
454 paletteFetchTimer = setTimeout(() => loadRemote(input.value.trim()), 110);
455 };
321456 input.onkeydown = (ev) => {
322457 const links = list.querySelectorAll('a');
323458 if (ev.key === 'ArrowDown') {
@@ -333,14 +468,30 @@
333468 };
334469 }
335470
471 function openShortcutsHelp() {
472 const dlg = document.getElementById('kbhelp');
473 if (dlg instanceof HTMLDialogElement && !dlg.open) dlg.showModal();
474 }
475
336476 document.addEventListener('click', (e) => {
337477 if (e.target.closest('.cmdk-trigger')) {
338478 e.preventDefault();
339 openPalette();
479 openPalette(false);
340480 return;
341481 }
342 const dlg = document.getElementById('cmdk');
343 if (dlg && e.target === dlg) dlg.close();
482 if (e.target.closest('.kbhelp-trigger')) {
483 e.preventDefault();
484 openShortcutsHelp();
485 return;
486 }
487 if (e.target.closest('.kbhelp-close')) {
488 document.getElementById('kbhelp')?.close();
489 return;
490 }
491 for (const id of ['cmdk', 'kbhelp']) {
492 const dlg = document.getElementById(id);
493 if (dlg && e.target === dlg) dlg.close();
494 }
344495 });
345496
346497 // ---- 6. Keyboard shortcuts ----
@@ -367,6 +518,27 @@
367518 }
368519 if (isTyping(e.target) || e.metaKey || e.ctrlKey || e.altKey) return;
369520
521 if (e.key === '?') {
522 e.preventDefault();
523 openShortcutsHelp();
524 return;
525 }
526 if (e.key === 't' && currentRepoContext().repo) {
527 e.preventDefault();
528 openPalette(true);
529 return;
530 }
531 if (e.key === 'y') {
532 const blobMain = document.querySelector('.blobmain[data-permalink]');
533 if (blobMain && blobMain.dataset.permalink) {
534 e.preventDefault();
535 const nextUrl = blobMain.dataset.permalink + location.search + location.hash;
536 history.replaceState(null, '', nextUrl);
537 navigator.clipboard?.writeText(location.origin + nextUrl).catch(() => {});
538 showToast('Immutable permalink copied');
539 return;
540 }
541 }
370542 if (e.key === '/') {
371543 const search = document.querySelector('main input[type="search"], .railsearch input[type="search"]');
372544 if (search) { e.preventDefault(); search.focus(); return; }
@@ -408,6 +580,7 @@
408580 document.addEventListener('change', async (e) => {
409581 const form = e.target.closest('form[data-autosave]');
410582 if (!(form instanceof HTMLFormElement)) return;
583 const prevTheme = document.documentElement.dataset.theme || 'system';
411584 if (e.target.matches('[data-live-theme]')) {
412585 const val = e.target.value;
413586 if (val === 'system') delete document.documentElement.dataset.theme;
@@ -422,6 +595,24 @@
422595 credentials: 'same-origin',
423596 });
424597 if (!res.ok) { showToast('Save failed', true); return; }
598 const doc = new DOMParser().parseFromString(await res.text(), 'text/html');
599 const errEl = doc.querySelector('main .error');
600 if (errEl) {
601 if (e.target.matches('[data-live-theme]')) {
602 if (prevTheme === 'system') delete document.documentElement.dataset.theme;
603 else document.documentElement.dataset.theme = prevTheme;
604 }
605 if (e.target.id) {
606 const serverCtl = doc.getElementById(e.target.id);
607 if (serverCtl instanceof HTMLInputElement && e.target instanceof HTMLInputElement && serverCtl.type === 'checkbox') {
608 e.target.checked = serverCtl.checked;
609 } else if (serverCtl instanceof HTMLSelectElement && e.target instanceof HTMLSelectElement) {
610 e.target.value = serverCtl.value;
611 }
612 }
613 showToast(errEl.textContent.trim(), true);
614 return;
615 }
425616 showToast('Saved');
426617 } catch {
427618 showToast('Save failed', true);
@@ -436,16 +627,58 @@
436627 if (inp.dataset.filterLinks) {
437628 const box = inp.closest('.' + inp.dataset.filterLinks);
438629 if (!box) return;
630 let shown = 0;
439631 for (const a of box.querySelectorAll('a:not(.allrefs)')) {
440 a.hidden = q !== '' && !a.textContent.toLowerCase().includes(q);
632 const hide = q !== '' && !a.textContent.toLowerCase().includes(q);
633 a.hidden = hide;
634 if (!hide) shown++;
635 }
636 let empty = box.querySelector('.filter-empty');
637 if (q !== '' && shown === 0) {
638 if (!empty) {
639 empty = document.createElement('span');
640 empty.className = 'none filter-empty';
641 empty.style.display = 'block';
642 empty.style.padding = '4px 12px';
643 empty.textContent = 'No matching branches';
644 box.insertBefore(empty, box.querySelector('.allrefs'));
645 }
646 empty.hidden = false;
647 } else if (empty) {
648 empty.hidden = true;
441649 }
442650 return;
443651 }
444652 if (inp.dataset.filterTable) {
445 const table = document.getElementById(inp.dataset.filterTable);
653 const container = document.getElementById(inp.dataset.filterTable);
654 const table = container?.tagName === 'TABLE' ? container : container?.querySelector('table');
446655 if (!table) return;
447 for (const row of table.querySelectorAll('tbody tr')) {
448 row.hidden = q !== '' && !row.textContent.toLowerCase().includes(q);
656 const colSel = inp.dataset.filterCol || '';
657 const tbody = table.querySelector('tbody') || table;
658 let shown = 0;
659 for (const row of tbody.querySelectorAll('tr:not(.filter-empty):not(.cols):not(.tipbar)')) {
660 if (row.querySelector('td.empty')) continue;
661 const cell = colSel ? row.querySelector(colSel) : row;
662 const hay = (cell ? cell.textContent : row.textContent).toLowerCase();
663 const hide = q !== '' && !hay.includes(q);
664 row.hidden = hide;
665 if (!hide) shown++;
666 }
667 let emptyRow = tbody.querySelector('tr.filter-empty');
668 if (q !== '' && shown === 0) {
669 if (!emptyRow) {
670 emptyRow = document.createElement('tr');
671 emptyRow.className = 'filter-empty';
672 const td = document.createElement('td');
673 td.colSpan = 10;
674 td.className = 'empty';
675 td.textContent = 'No matching items';
676 emptyRow.appendChild(td);
677 tbody.appendChild(emptyRow);
678 }
679 emptyRow.hidden = false;
680 } else if (emptyRow) {
681 emptyRow.hidden = true;
449682 }
450683 return;
451684 }
@@ -453,9 +686,24 @@
453686 if (!list) return;
454687 const ul = list.tagName === 'UL' ? list : list.querySelector('ul');
455688 if (!ul) return;
456 for (const item of ul.querySelectorAll(':scope > li')) {
689 let shown = 0;
690 for (const item of ul.querySelectorAll(':scope > li:not(.filter-empty)')) {
457691 if (item.classList.contains('empty')) continue;
458 item.hidden = q !== '' && !item.textContent.toLowerCase().includes(q);
692 const hide = q !== '' && !item.textContent.toLowerCase().includes(q);
693 item.hidden = hide;
694 if (!hide) shown++;
695 }
696 let emptyLi = ul.querySelector(':scope > li.filter-empty');
697 if (q !== '' && shown === 0) {
698 if (!emptyLi) {
699 emptyLi = document.createElement('li');
700 emptyLi.className = 'empty filter-empty';
701 emptyLi.textContent = 'No matching items';
702 ul.appendChild(emptyLi);
703 }
704 emptyLi.hidden = false;
705 } else if (emptyLi) {
706 emptyLi.hidden = true;
459707 }
460708 });
461709
@@ -486,7 +734,8 @@
486734 }
487735 });
488736
489 // ---- 9b. Smooth in-place tab switching (profile tabs) ----
737 // ---- 9b. Smooth in-place tab switching (profile & list tabs) ----
738 let tabSwappedOnPage = false;
490739 document.addEventListener('click', async (e) => {
491740 if (e.metaKey || e.ctrlKey || e.shiftKey || e.altKey || e.button !== 0) return;
492741 const a = e.target.closest('nav[data-tab-swap] a');
@@ -502,15 +751,35 @@
502751 const doc = new DOMParser().parseFromString(html, 'text/html');
503752 const next = doc.getElementById(targetId);
504753 if (!next) { location.href = a.href; return; }
754 if (!tabSwappedOnPage && !(history.state && history.state.tabSwap)) {
755 history.replaceState({ tabSwap: targetId }, '', location.href);
756 }
757 tabSwappedOnPage = true;
505758 cur.replaceWith(next);
759 if (doc.title) document.title = doc.title;
506760 history.pushState({ tabSwap: targetId }, '', a.href);
507761 initCopyButtons(next);
508762 } catch {
509763 location.href = a.href;
510764 }
511765 });
512 window.addEventListener('popstate', (e) => {
513 if (e.state && e.state.tabSwap) location.reload();
766 window.addEventListener('popstate', async (e) => {
767 const targetId = (e.state && e.state.tabSwap) || document.querySelector('nav[data-tab-swap]')?.dataset.tabSwap;
768 if (!targetId) return;
769 const cur = document.getElementById(targetId);
770 if (!cur) { location.reload(); return; }
771 try {
772 const res = await fetch(location.href, { credentials: 'same-origin' });
773 if (!res.ok) { location.reload(); return; }
774 const doc = new DOMParser().parseFromString(await res.text(), 'text/html');
775 const next = doc.getElementById(targetId);
776 if (!next) { location.reload(); return; }
777 cur.replaceWith(next);
778 if (doc.title) document.title = doc.title;
779 initCopyButtons(next);
780 } catch {
781 location.reload();
782 }
514783 });
515784
516785 // ---- 10. Scroll-spy on sticky section navs ----
@@ -554,7 +823,7 @@
554823 else a.removeAttribute('aria-current');
555824 }
556825 };
557 const initial = location.hash.replace(/^#/, '') || (document.querySelector('#import input[name="from"]')?.value ? 'import' : 'create');
826 const initial = location.hash.replace(/^#/, '') || nav.dataset.activePanel || (document.querySelector('#import input[name="from"]')?.value ? 'import' : 'create');
558827 show(initial);
559828 for (const a of links) {
560829 a.addEventListener('click', (e) => {
@@ -579,11 +848,391 @@
579848 if (e.target.id === 'imp-name') e.target.dataset.userEdited = e.target.value ? '1' : '';
580849 });
581850
582 if (document.readyState === 'loading') {
583 document.addEventListener('DOMContentLoaded', () => { initCopyButtons(); initScrollSpy(); initPanelTabs(); });
584 } else {
851 function adaptShortcutLabels() {
852 if (/Mac|iPhone|iPad|iPod/i.test(navigator.platform || navigator.userAgent || '')) return;
853 for (const kbd of document.querySelectorAll('.cmdk-trigger kbd')) {
854 kbd.textContent = kbd.textContent.replace('⌘', 'Ctrl+');
855 }
856 for (const el of document.querySelectorAll('.meta, .crumbs')) {
857 if (el.childNodes.length === 1 && el.textContent.includes('⌘↵')) {
858 el.textContent = el.textContent.replace('⌘↵', 'Ctrl+Enter');
859 }
860 }
861 }
862
863 // ---- 12. Diff "Viewed" checkboxes, inline hunk expansion & blob Shift+Click ranges ----
864 function initDiffEnhancements(root = document) {
865 const wrap = root.querySelector?.('.diffwrap') || document.querySelector('.diffwrap');
866 if (!wrap) return;
867 const repo = wrap.dataset.repo || '';
868 const head = wrap.dataset.head || '';
869
870 // Per-file Viewed checkbox backed by localStorage
871 if (repo && head) {
872 for (const fold of wrap.querySelectorAll('details.difffold[data-file-path]')) {
873 const sum = fold.querySelector(':scope > summary');
874 if (!sum || sum.dataset.viewedWired) continue;
875 sum.dataset.viewedWired = '1';
876 const fpath = fold.dataset.filePath;
877 const key = `gb-viewed:${repo}:${head}:${fpath}`;
878 const lbl = document.createElement('label');
879 lbl.className = 'viewed-toggle';
880 lbl.addEventListener('click', (ev) => ev.stopPropagation());
881 const cb = document.createElement('input');
882 cb.type = 'checkbox';
883 cb.checked = localStorage.getItem(key) === '1';
884 const syncViewed = (checked, collapse) => {
885 const tocItem = wrap.querySelector(`.difftoc-list li[data-toc-path="${CSS.escape(fpath)}"]`);
886 if (tocItem) tocItem.classList.toggle('toc-viewed', checked);
887 if (collapse) fold.open = !checked;
888 };
889 if (cb.checked) syncViewed(true, true);
890 cb.addEventListener('change', () => {
891 try {
892 if (cb.checked) localStorage.setItem(key, '1');
893 else localStorage.removeItem(key);
894 } catch {}
895 syncViewed(cb.checked, true);
896 });
897 lbl.append(cb, document.createTextNode('Viewed'));
898 sum.appendChild(lbl);
899 }
900 }
901
902 // Inline hunk context expansion ("↑ Expand")
903 if (repo && head) {
904 const hunkRe = /^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/;
905 for (const tr of wrap.querySelectorAll('tr.hunk[data-hunk][data-file]')) {
906 if (tr.dataset.expandWired) continue;
907 tr.dataset.expandWired = '1';
908 const m = hunkRe.exec(tr.dataset.hunk || '');
909 if (!m) continue;
910 let curNewStart = parseInt(m[2], 10);
911 let curOldStart = parseInt(m[1], 10);
912 if (curNewStart <= 1) continue;
913 const srcTd = tr.querySelector('td.src');
914 if (!srcTd) continue;
915 const btn = document.createElement('button');
916 btn.type = 'button';
917 btn.className = 'hunk-expand';
918 btn.textContent = '↑ Expand';
919 btn.title = 'Load up to 20 preceding context lines';
920 btn.addEventListener('click', async () => {
921 const to = curNewStart - 1;
922 const from = Math.max(1, to - 19);
923 if (to < 1) { btn.remove(); return; }
924 btn.disabled = true;
925 try {
926 const fpath = tr.dataset.file;
927 const res = await fetch(`/${repo}/blob/${head}/${fpath}?lines=${from}:${to}`, { credentials: 'same-origin' });
928 if (!res.ok) throw new Error('fetch');
929 const data = await res.json();
930 const isSplit = tr.closest('table')?.classList.contains('split');
931 const oldOffset = curOldStart - curNewStart;
932 for (const item of (data.lines || [])) {
933 const ctxTr = document.createElement('tr');
934 if (isSplit) {
935 ctxTr.className = 'pair';
936 const ln1 = document.createElement('td'); ln1.className = 'ln ctx old'; ln1.textContent = String(Math.max(1, item.n + oldOffset));
937 const s1 = document.createElement('td'); s1.className = 'src ctx old chroma'; s1.innerHTML = item.html;
938 const ln2 = document.createElement('td'); ln2.className = 'ln ctx'; ln2.textContent = String(item.n);
939 const s2 = document.createElement('td'); s2.className = 'src ctx chroma'; s2.innerHTML = item.html;
940 ctxTr.append(ln1, s1, ln2, s2);
941 } else {
942 ctxTr.className = 'ctx';
943 const ln1 = document.createElement('td'); ln1.className = 'ln'; ln1.textContent = String(Math.max(1, item.n + oldOffset));
944 const ln2 = document.createElement('td'); ln2.className = 'ln'; ln2.textContent = String(item.n);
945 const s = document.createElement('td'); s.className = 'src chroma'; s.innerHTML = item.html;
946 ctxTr.append(ln1, ln2, s);
947 }
948 tr.parentNode.insertBefore(ctxTr, tr.nextSibling);
949 }
950 // Move expanded rows in ascending order right after tr
951 const inserted = [];
952 let sib = tr.nextSibling;
953 for (let k = 0; k < (data.lines || []).length && sib; k++) {
954 inserted.push(sib);
955 sib = sib.nextSibling;
956 }
957 inserted.reverse().forEach((n) => tr.parentNode.insertBefore(n, sib));
958 curOldStart = Math.max(1, curOldStart - (curNewStart - from));
959 curNewStart = from;
960 if (curNewStart <= 1) btn.remove();
961 } catch {
962 showToast('Could not expand context', true);
963 } finally {
964 btn.disabled = false;
965 }
966 });
967 srcTd.prepend(btn);
968 }
969 }
970 }
971
972 // Blob Shift+Click multi-line range (#L10-L25)
973 function applyLineRangeFromHash() {
974 const m = /^#L(\d+)(?:-L?(\d+))?$/.exec(location.hash);
975 for (const el of document.querySelectorAll('.code .line.range-hl')) el.classList.remove('range-hl');
976 if (!m || !m[2]) return;
977 let a = parseInt(m[1], 10), b = parseInt(m[2], 10);
978 if (a > b) [a, b] = [b, a];
979 for (let i = a; i <= b; i++) {
980 const anchor = document.getElementById('L' + i);
981 const line = anchor?.closest('.line');
982 if (line) line.classList.add('range-hl');
983 }
984 }
985 let lastClickedLine = 0;
986 document.addEventListener('click', (e) => {
987 const lnLink = e.target.closest('.code a.lnlinks[href^="#L"]');
988 if (!lnLink) return;
989 const n = parseInt(lnLink.getAttribute('href').slice(2), 10);
990 if (!n) return;
991 if (e.shiftKey && lastClickedLine > 0 && lastClickedLine !== n) {
992 e.preventDefault();
993 const lo = Math.min(lastClickedLine, n), hi = Math.max(lastClickedLine, n);
994 history.replaceState(null, '', `#L${lo}-L${hi}`);
995 applyLineRangeFromHash();
996 } else {
997 lastClickedLine = n;
998 setTimeout(applyLineRangeFromHash, 0);
999 }
1000 });
1001 window.addEventListener('hashchange', applyLineRangeFromHash);
1002
1003 // ---- 13. Composer Write | Preview tabs & @/# /! autocomplete ----
1004 function initComposers(root = document) {
1005 const forms = root.querySelectorAll ? root.querySelectorAll('form') : [];
1006 for (const form of forms) {
1007 if (form.dataset.composerWired) continue;
1008 const previewBtn = form.querySelector('button[name="preview"]');
1009 const ta = form.querySelector('textarea');
1010 if (!previewBtn || !ta) continue;
1011 form.dataset.composerWired = '1';
1012
1013 const bar = document.createElement('div');
1014 bar.className = 'composer-bar';
1015 const writeTab = document.createElement('button');
1016 writeTab.type = 'button';
1017 writeTab.className = 'composer-tab';
1018 writeTab.setAttribute('aria-selected', 'true');
1019 writeTab.textContent = 'Write';
1020
1021 const prevTab = document.createElement('button');
1022 prevTab.type = 'button';
1023 prevTab.className = 'composer-tab';
1024 prevTab.setAttribute('aria-selected', 'false');
1025 prevTab.textContent = 'Preview';
1026
1027 const hint = document.createElement('span');
1028 hint.className = 'composer-hint';
1029 hint.textContent = '@user · #issue · !MR';
1030 bar.append(writeTab, prevTab, hint);
1031
1032 const pane = document.createElement('div');
1033 pane.className = 'composer-preview rendered';
1034 pane.hidden = true;
1035
1036 const wrapTarget = ta.closest('p') || ta;
1037 wrapTarget.parentNode.insertBefore(bar, wrapTarget);
1038 wrapTarget.parentNode.insertBefore(pane, wrapTarget.nextSibling);
1039 previewBtn.classList.add('js-hidden-preview');
1040
1041 writeTab.addEventListener('click', () => {
1042 writeTab.setAttribute('aria-selected', 'true');
1043 prevTab.setAttribute('aria-selected', 'false');
1044 pane.hidden = true;
1045 wrapTarget.hidden = false;
1046 ta.focus();
1047 });
1048
1049 prevTab.addEventListener('click', async () => {
1050 writeTab.setAttribute('aria-selected', 'false');
1051 prevTab.setAttribute('aria-selected', 'true');
1052 wrapTarget.hidden = true;
1053 pane.hidden = false;
1054 if (!ta.value.trim()) {
1055 pane.innerHTML = '<p class="none">Nothing to preview.</p>';
1056 return;
1057 }
1058 pane.innerHTML = '<p class="none">Rendering preview…</p>';
1059 try {
1060 const fd = new FormData(form);
1061 fd.set('preview', '1');
1062 const res = await fetch(form.action || location.href, {
1063 method: 'POST',
1064 body: new URLSearchParams(fd),
1065 headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
1066 credentials: 'same-origin',
1067 });
1068 if (!res.ok) throw new Error('preview');
1069 const doc = new DOMParser().parseFromString(await res.text(), 'text/html');
1070 const rendered = doc.querySelector('.preview .rendered');
1071 pane.innerHTML = rendered ? rendered.innerHTML : '<p class="none">Nothing to preview.</p>';
1072 initCopyButtons(pane);
1073 } catch {
1074 pane.innerHTML = '<p class="error">Preview failed.</p>';
1075 }
1076 });
1077 }
1078 }
1079
1080 // Lightweight @mention, #issue, and !MR autocomplete on textareas
1081 let acMenu = null;
1082 let acItems = [];
1083 let acIndex = 0;
1084 let acContext = null;
1085 let acTimer = 0;
1086
1087 function closeAutocomplete() {
1088 if (acMenu) acMenu.hidden = true;
1089 acItems = [];
1090 acContext = null;
1091 }
1092
1093 function ensureAutocompleteMenu() {
1094 if (acMenu) return acMenu;
1095 acMenu = document.createElement('ul');
1096 acMenu.className = 'ac-menu';
1097 acMenu.hidden = true;
1098 document.body.appendChild(acMenu);
1099 return acMenu;
1100 }
1101
1102 function applyAutocomplete(choice) {
1103 if (!acContext || !choice) return;
1104 const { ta, start, end } = acContext;
1105 const before = ta.value.slice(0, start);
1106 const after = ta.value.slice(end);
1107 const insert = choice.insert + ' ';
1108 ta.value = before + insert + after;
1109 const pos = before.length + insert.length;
1110 ta.setSelectionRange(pos, pos);
1111 ta.focus();
1112 closeAutocomplete();
1113 }
1114
1115 function renderAutocomplete(ta) {
1116 const menu = ensureAutocompleteMenu();
1117 if (!acItems.length) {
1118 closeAutocomplete();
1119 return;
1120 }
1121 menu.innerHTML = '';
1122 acItems.forEach((it, idx) => {
1123 const li = document.createElement('li');
1124 li.className = idx === acIndex ? 'ac-active' : '';
1125 const b = document.createElement('strong');
1126 b.textContent = it.insert;
1127 const sp = document.createElement('span');
1128 sp.textContent = it.label;
1129 li.append(b, sp);
1130 li.addEventListener('mousedown', (ev) => {
1131 ev.preventDefault();
1132 applyAutocomplete(it);
1133 });
1134 menu.appendChild(li);
1135 });
1136 const rect = ta.getBoundingClientRect();
1137 menu.style.left = `${Math.max(8, rect.left + window.scrollX + 12)}px`;
1138 menu.style.top = `${rect.top + window.scrollY + Math.min(rect.height, 42)}px`;
1139 menu.hidden = false;
1140 }
1141
1142 function collectPagePeople() {
1143 const set = new Set();
1144 for (const opt of document.querySelectorAll('#repo-people option')) {
1145 if (opt.value) set.add(opt.value);
1146 }
1147 for (const a of document.querySelectorAll('.commenthead a[href^="/"], .aside a[href^="/"]')) {
1148 const u = a.getAttribute('href').slice(1);
1149 if (u && !u.includes('/') && !u.includes('?')) set.add(u);
1150 }
1151 return Array.from(set);
1152 }
1153
1154 document.addEventListener('input', (e) => {
1155 if (!(e.target instanceof HTMLTextAreaElement)) return;
1156 const ta = e.target;
1157 const pos = ta.selectionStart;
1158 const upto = ta.value.slice(0, pos);
1159 const m = /(?:^|\s)([@#!])([a-zA-Z0-9._-]{0,24})$/.exec(upto);
1160 if (!m) {
1161 closeAutocomplete();
1162 return;
1163 }
1164 const trig = m[1];
1165 const q = m[2].toLowerCase();
1166 const start = pos - m[2].length - 1;
1167 acContext = { ta, start, end: pos };
1168 acIndex = 0;
1169
1170 if (trig === '@') {
1171 const people = collectPagePeople().filter((u) => u.toLowerCase().startsWith(q)).slice(0, 6);
1172 acItems = people.map((u) => ({ insert: '@' + u, label: u }));
1173 renderAutocomplete(ta);
1174 return;
1175 }
1176 const ctx = currentRepoContext();
1177 if (!ctx.repo) {
1178 closeAutocomplete();
1179 return;
1180 }
1181 clearTimeout(acTimer);
1182 acTimer = setTimeout(async () => {
1183 try {
1184 const params = new URLSearchParams({ format: 'palette', repo: ctx.repo, q });
1185 const res = await fetch('/search?' + params.toString(), { credentials: 'same-origin' });
1186 if (!res.ok) return;
1187 const data = await res.json();
1188 const wantGroup = trig === '#' ? 'Issue' : 'MR';
1189 acItems = (data.items || [])
1190 .filter((it) => it.group === wantGroup)
1191 .slice(0, 6)
1192 .map((it) => {
1193 const num = it.href.split('/').pop();
1194 return { insert: trig + num, label: it.label };
1195 });
1196 renderAutocomplete(ta);
1197 } catch {}
1198 }, 120);
1199 });
1200
1201 document.addEventListener('keydown', (e) => {
1202 if (!acMenu || acMenu.hidden || !acItems.length) return;
1203 if (e.key === 'ArrowDown') {
1204 e.preventDefault();
1205 acIndex = (acIndex + 1) % acItems.length;
1206 if (acContext) renderAutocomplete(acContext.ta);
1207 } else if (e.key === 'ArrowUp') {
1208 e.preventDefault();
1209 acIndex = (acIndex - 1 + acItems.length) % acItems.length;
1210 if (acContext) renderAutocomplete(acContext.ta);
1211 } else if (e.key === 'Enter' || e.key === 'Tab') {
1212 e.preventDefault();
1213 applyAutocomplete(acItems[acIndex]);
1214 } else if (e.key === 'Escape') {
1215 e.preventDefault();
1216 closeAutocomplete();
1217 }
1218 }, true);
1219 document.addEventListener('blur', (e) => {
1220 if (e.target instanceof HTMLTextAreaElement) setTimeout(closeAutocomplete, 150);
1221 }, true);
1222
1223 function bootAll() {
5851224 initCopyButtons();
5861225 initScrollSpy();
5871226 initPanelTabs();
1227 adaptShortcutLabels();
1228 initDiffEnhancements();
1229 applyLineRangeFromHash();
1230 initComposers();
1231 }
1232
1233 if (document.readyState === 'loading') {
1234 document.addEventListener('DOMContentLoaded', bootAll);
1235 } else {
1236 bootAll();
5881237 }
5891238})();
internal/web/static/style.css +332 −69 · view
@@ -34,12 +34,14 @@
3434 scrollbars per scheme, and opt out of browser auto-darkening */
3535 color-scheme: light dark;
3636
37 /* grounds: canvas, surface and inset are three steps, not one */
38 --canvas: #ffffff;
39 --surface: #ebedf1;
37 /* grounds: canvas, card, surface and inset give clear elevation in light and dark */
38 --canvas: #f7f8fa;
39 --card: #ffffff;
40 --card-line: #cfd5df;
41 --surface: #e3e6ed;
4042 --inset: #ffffff;
41 --hover: #e1e4ea;
42 --line: #8d939c; /* 3.09:1 on canvas — a border you can see */
43 --hover: #dce0e8;
44 --line: #878e99; /* >= 3:1 on #f7f8fa canvas */
4345 --faint: #d8dce2;
4446
4547 /* ink */
@@ -57,11 +59,11 @@
5759 /* orange: where you are, what wants you. Two cuts because the floor
5860 differs by size: --mark for bars, --warn at text size. */
5961 --mark: #e4572e;
60 --warn: #b8400f;
62 --warn: #a8380b;
6163
6264 /* state */
6365 --ok: #0a7536;
64 --bad: #c62828;
66 --bad: #b91c1c;
6567 --done: #6b21a8;
6668
6769 /* diff row tints: enough to scan, light enough that the syntax
@@ -143,6 +145,8 @@
143145 color-scheme: dark;
144146
145147 --canvas: #101114;
148 --card: #16181d;
149 --card-line: #2d3139;
146150 --surface: #212429;
147151 --inset: #0b0c0e;
148152 --hover: #2b2f36;
@@ -476,8 +480,8 @@ footer a:hover { color: var(--link); }
476480/* ---- repository header ---- */
477481.repohead {
478482 padding: var(--sp-5) 0 0;
479 border-bottom: 1px solid var(--faint);
480 background: var(--canvas);
483 border-bottom: 1px solid var(--card-line);
484 background: var(--card);
481485}
482486.repohead .wrap { max-width: calc(var(--container) + 2 * var(--sp-6)); margin: 0 auto; padding: 0 var(--sp-6); }
483487.identity { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
@@ -559,21 +563,28 @@ nav.tabs a i { font-style: normal; color: var(--muted); margin-left: 4px; }
559563.commithead p { margin: var(--sp-1) 0; }
560564.commithead h2 { margin-top: 0; margin-bottom: var(--sp-1); }
561565
562nav.filters { display: inline-flex; gap: var(--sp-2); flex-wrap: wrap; }
563nav.filters a {
566nav.filters, nav.statebar { display: inline-flex; gap: var(--sp-2); flex-wrap: wrap; }
567nav.statebar { margin: 0 0 var(--sp-3); }
568nav.filters a, nav.statebar a {
564569 display: inline-flex;
565570 align-items: center;
566571 height: 32px;
567572 padding: 0 var(--sp-3);
568 background: var(--canvas);
569 border: 1px solid var(--line);
573 background: var(--card);
574 border: 1px solid var(--card-line);
570575 border-radius: var(--r-ctl);
571 color: var(--fg);
576 color: var(--muted);
572577 font-size: var(--fs-2);
573578 font-weight: 500;
579 text-decoration: none;
580}
581nav.filters a:hover, nav.statebar a:hover { background: var(--hover); color: var(--fg); text-decoration: none; }
582nav.filters a.active, nav.filters a[aria-current="page"], nav.statebar a[aria-current="page"] {
583 background: var(--surface);
584 border-color: var(--mark);
585 color: var(--fg);
586 font-weight: 600;
574587}
575nav.filters a:hover { background: var(--hover); text-decoration: none; }
576nav.filters a.active { background: var(--surface); border-color: var(--link); color: var(--link); }
577588
578589form.searchform, form.logfilter, form.compareform {
579590 display: flex;
@@ -609,7 +620,7 @@ button, .button {
609620}
610621button:hover, .button.primary:hover { filter: brightness(1.12); text-decoration: none; }
611622button.btn, .button.btn {
612 background: var(--canvas);
623 background: var(--card);
613624 color: var(--fg);
614625 border-color: var(--line);
615626 filter: none;
@@ -857,12 +868,13 @@ ul.plain li > form:first-of-type { margin-left: auto; }
857868.notice { border-left-color: var(--ok); background: color-mix(in srgb, var(--ok) 6%, transparent); }
858869.empty-note, .none, .empty, li.empty, td.empty { color: var(--muted); }
859870
860/* ---- containers: calm hairline borders and clean surfaces ---- */
871/* ---- containers: crisp elevated card surfaces ---- */
861872.card, ul.list, ul.loglist, ul.repolist, ul.issuelist,
862873ul.milestonelist, .readme, .code, article.release, .blame, .teambody {
863 background: var(--canvas);
864 border: 1px solid var(--faint);
874 background: var(--card);
875 border: 1px solid var(--card-line);
865876 border-radius: var(--r-card);
877 box-shadow: 0 1px 2px rgb(0 0 0 / 0.03);
866878 overflow: hidden;
867879}
868880.cardhead {
@@ -897,7 +909,7 @@ tbody tr:hover td { background: var(--hover); }
897909/* every header row a template writes, by the class it or its table
898910 carries: TestHeaderRowsAreLeftAligned reads these selectors */
899911tr.cols th, table.tree th, table.refs th, table.keys th, table.assets th { text-align: left; }
900tr.cols th { background: var(--canvas); }
912tr.cols th { background: var(--card); }
901913/* right-aligned columns keep their header with their values */
902914tr.cols th.age, tr.cols th.size { text-align: right; }
903915/* wide listings scroll inside their own box; the page never does. The
@@ -905,9 +917,10 @@ tr.cols th.age, tr.cols th.size { text-align: right; }
905917.tablewrap { overflow-x: auto; max-width: 100%; }
906918
907919table.tree, table.refs {
908 background: var(--canvas);
909 border: 1px solid var(--faint);
920 background: var(--card);
921 border: 1px solid var(--card-line);
910922 border-radius: var(--r-card);
923 box-shadow: 0 1px 2px rgb(0 0 0 / 0.03);
911924 /* collapsed borders defeat a radius on the table itself */
912925 border-collapse: separate;
913926 border-spacing: 0;
@@ -1203,7 +1216,7 @@ pre.matchline mark { background: color-mix(in srgb, var(--mark) 25%, transparent
12031216p.pager { margin-top: var(--sp-4); }
12041217.snippetfile { margin-bottom: var(--sp-5); }
12051218p.filefacts { color: var(--muted); font-size: var(--fs-1); margin: 0 0 var(--sp-3); }
1206pre.buildlog { max-height: 40rem; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
1219pre.buildlog { overflow-x: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
12071220details.buildstep pre.buildlog { margin: 0; border: 0; border-radius: 0; }
12081221details.buildstep summary code { overflow-wrap: anywhere; }
12091222
@@ -1327,7 +1340,8 @@ form.actions select, form.actions textarea { width: 100%; }
13271340/* ---- comments and threads ---- */
13281341article.comment {
13291342 max-width: 48rem;
1330 border: 1px solid var(--line);
1343 background: var(--card);
1344 border: 1px solid var(--card-line);
13311345 border-radius: var(--r-card);
13321346 margin: var(--sp-4) 0;
13331347 overflow: hidden;
@@ -1699,6 +1713,7 @@ a.memberchip .role { color: var(--muted); }
16991713.sidedrop:not(:has(.grp)) { display: none; }
17001714
17011715@media (min-width: 62.01rem) {
1716 .withcol:has(.statebar) .sidecol .grp-state { display: none; }
17021717 @supports selector(::details-content) {
17031718 .sidedrop > summary { display: none; }
17041719 .sidedrop::details-content { content-visibility: visible; }
@@ -1995,21 +2010,16 @@ svg.icon { vertical-align: -0.125em; }
19952010 ul.loglist .commitside { width: 100%; justify-content: flex-start; }
19962011}
19972012
1998/* Nine 44px squares and the mark are 440px, so below 34rem the rail
1999 keeps six — dashboard, explore, search, notifications, More, your
2000 avatar — and the More menu holds the rest. Seven squares at 44px are
2001 308px, inside a 320px phone. Explore is one of the six because the
2002 More menu only exists for a signed-in viewer: dropping it left a
2003 signed-out phone with no route to the listing at all. Shrinking the
2004 squares instead is what this replaces: 32px was under the target
2005 every phone guideline asks for, and the count only grows. */
2013/* Compact phones expand rail icon sizes slightly while keeping the avatar
2014 and + dropdowns cleanly targetable. */
20062015@media (max-width: 34rem) {
2007 .railopt { display: none; }
2008 .railmore { display: block; }
2009 .railicon svg { width: 20px; height: 20px; }
2010 /* the mark is a link home too, so it is a target like the rest */
2016 .railicon svg { width: 18px; height: 18px; }
20112017 a.brand { width: var(--rail-hit); }
20122018}
2019.railpins-mob { display: none; }
2020@media (max-width: 44rem) {
2021 .railpins-mob { display: block; }
2022}
20132023
20142024/* ---- reactions ---- */
20152025.reactions { display: flex; flex-wrap: wrap; gap: var(--sp-1); margin: 0; padding: var(--sp-2) var(--sp-4); }
@@ -2021,13 +2031,13 @@ button.react, span.react {
20212031 padding: 0 var(--sp-2);
20222032 min-height: 24px;
20232033 border: 1px solid var(--line);
2024 border-radius: var(--r-sm);
2034 border-radius: var(--r-ctl);
20252035 background: transparent;
20262036 color: var(--muted);
20272037}
20282038button.react { cursor: pointer; }
20292039button.react:hover { background: var(--surface); }
2030button.react.mine { border-color: var(--accent); background: var(--surface); color: var(--fg); }
2040button.react.mine { border-color: var(--link); background: var(--surface); color: var(--fg); }
20312041
20322042/* ---- rail pinned switcher ---- */
20332043.railusermenu, .railcreate { position: relative; }
@@ -2139,28 +2149,48 @@ button.react.mine { border-color: var(--accent); background: var(--surface); col
21392149 font-weight: 600;
21402150}
21412151
2142/* ---- list quick state bar ---- */
2143.statebar {
2144 display: flex;
2145 flex-wrap: wrap;
2146 gap: var(--sp-2);
2147 margin: 0 0 var(--sp-3);
2152/* ---- split-button watch & header count badges ---- */
2153.splitbtn { display: inline-flex; align-items: center; }
2154.splitbtn > form > button.btn { border-top-right-radius: 0; border-bottom-right-radius: 0; }
2155.splitbtn > details.watchpop > summary.splitcaret {
2156 border-top-left-radius: 0;
2157 border-bottom-left-radius: 0;
2158 border-left: 0;
2159 padding: 0 7px;
2160 min-width: 24px;
21482161}
2149.statebar a {
2150 font-size: var(--fs-1);
2151 padding: var(--sp-1) var(--sp-3);
2152 border: 1px solid var(--faint);
2162.watchpop .popmenu { width: 18rem; gap: var(--sp-1); padding: var(--sp-2); }
2163.watchopt {
2164 display: flex;
2165 flex-direction: column;
2166 align-items: flex-start;
2167 gap: 2px;
2168 width: 100%;
2169 height: auto;
2170 padding: var(--sp-2) var(--sp-3);
2171 background: transparent;
2172 color: var(--fg);
2173 border: 1px solid transparent;
21532174 border-radius: var(--r-ctl);
2154 color: var(--muted);
2155 text-decoration: none;
2175 text-align: left;
2176 white-space: normal;
2177 filter: none;
21562178}
2157.statebar a:hover { background: var(--hover); color: var(--fg); }
2158.statebar a[aria-current="page"] {
2159 border-color: var(--mark);
2160 color: var(--fg);
2179.watchopt:hover { background: var(--hover); filter: none; }
2180.watchopt[aria-pressed="true"] { background: var(--surface); border-color: var(--mark); }
2181.watchopt b { font-size: var(--fs-2); font-weight: 600; }
2182.watchopt span { font-size: var(--fs-0); color: var(--muted); font-weight: 400; line-height: 1.35; }
2183.btncount {
2184 font-style: normal;
2185 font-size: var(--fs-0);
21612186 font-weight: 600;
2187 padding: 0 6px;
2188 border-radius: var(--r-ctl);
21622189 background: var(--surface);
2190 color: var(--muted);
2191 font-variant-numeric: tabular-nums;
21632192}
2193.filter-empty { color: var(--muted); }
21642194
21652195/* ---- sidebar group headers & floating popovers ---- */
21662196.grp-head {
@@ -2193,8 +2223,8 @@ button.react.mine { border-color: var(--accent); background: var(--surface); col
21932223 width: 16rem;
21942224 max-width: 85vw;
21952225 padding: var(--sp-3);
2196 background: var(--canvas);
2197 border: 1px solid var(--faint);
2226 background: var(--card);
2227 border: 1px solid var(--card-line);
21982228 border-radius: var(--r-card);
21992229 box-shadow: var(--shadow);
22002230 display: flex;
@@ -2299,22 +2329,25 @@ dialog.cmdk::backdrop { background: rgb(0 0 0 / 0.45); }
22992329}
23002330.cmdk-empty { padding: var(--sp-4); color: var(--muted); text-align: center; font-size: var(--fs-2); }
23012331
2302/* ---- copy button on clone blocks ---- */
2332/* ---- copy button on code & clone blocks ---- */
23032333.copywrap { position: relative; }
23042334.copywrap pre { padding-right: 4.5rem; }
23052335.copybtn {
23062336 position: absolute;
2307 top: 50%;
2337 top: 6px;
23082338 right: var(--sp-2);
2309 transform: translateY(-50%);
23102339 height: 24px;
23112340 padding: 0 var(--sp-2);
23122341 font-size: var(--fs-0);
23132342 background: var(--surface);
23142343 color: var(--fg);
2315 border: 1px solid var(--faint);
2344 border: 1px solid var(--card-line);
23162345 border-radius: var(--r-ctl);
23172346}
2347.copywrap.oneline .copybtn {
2348 top: 50%;
2349 transform: translateY(-50%);
2350}
23182351.copybtn:hover { background: var(--hover); filter: none; }
23192352
23202353@media (max-width: 44rem) {
@@ -2324,9 +2357,10 @@ dialog.cmdk::backdrop { background: rgb(0 0 0 / 0.45); }
23242357
23252358/* ---- account & admin redesign ---- */
23262359.setcard, section.activity {
2327 background: var(--canvas);
2328 border: 1px solid var(--faint);
2360 background: var(--card);
2361 border: 1px solid var(--card-line);
23292362 border-radius: var(--r-card);
2363 box-shadow: 0 1px 2px rgb(0 0 0 / 0.03);
23302364 padding: var(--sp-5);
23312365 margin: 0 0 var(--sp-5);
23322366}
@@ -2364,6 +2398,8 @@ nav.admintabs {
23642398.tablefilter { min-width: 14rem; }
23652399pre.copyable { margin: var(--sp-2) 0 0; }
23662400html.js form[data-autosave] button[type="submit"] { display: none; }
2401html.js form.setform[data-autosave] { grid-template-columns: minmax(14rem, 1fr) minmax(0, 28rem); }
2402html.js form.setform[data-autosave] > div:has(> button[type="submit"]) { display: none; }
23672403.toast {
23682404 position: fixed;
23692405 right: var(--sp-5);
@@ -2385,9 +2421,10 @@ html.js form[data-autosave] button[type="submit"] { display: none; }
23852421
23862422/* ---- dashboard & profile polish ---- */
23872423.dashpins, .feedcol {
2388 background: var(--canvas);
2389 border: 1px solid var(--faint);
2424 background: var(--card);
2425 border: 1px solid var(--card-line);
23902426 border-radius: var(--r-card);
2427 box-shadow: 0 1px 2px rgb(0 0 0 / 0.03);
23912428 padding: var(--sp-4);
23922429}
23932430.dashcard-head {
@@ -2410,9 +2447,10 @@ html.js form[data-autosave] button[type="submit"] { display: none; }
24102447 margin: 0 0 var(--sp-2);
24112448}
24122449.profilecard {
2413 background: var(--canvas);
2414 border: 1px solid var(--faint);
2450 background: var(--card);
2451 border: 1px solid var(--card-line);
24152452 border-radius: var(--r-card);
2453 box-shadow: 0 1px 2px rgb(0 0 0 / 0.03);
24162454 padding: var(--sp-5);
24172455 margin-bottom: var(--sp-4);
24182456}
@@ -2478,9 +2516,10 @@ ul.issuelist li.unread {
24782516 font-size: var(--fs-1);
24792517}
24802518.facts .about, .facts .clone {
2481 background: var(--canvas);
2482 border: 1px solid var(--faint);
2519 background: var(--card);
2520 border: 1px solid var(--card-line);
24832521 border-radius: var(--r-card);
2522 box-shadow: 0 1px 2px rgb(0 0 0 / 0.03);
24842523 padding: var(--sp-4);
24852524}
24862525.popform-stack {
@@ -2534,3 +2573,227 @@ article.release.setcard {
25342573 font-weight: 600;
25352574}
25362575.commithead.setcard pre.message { margin: var(--sp-3) 0 0; }
2576
2577/* ---- Phase 3: Full-width MR diff, word-level diffs, hunk expand, blob/blame & shortcuts ---- */
2578.btnicon { display: inline-flex; align-items: center; }
2579.mrbar {
2580 display: flex;
2581 align-items: center;
2582 justify-content: space-between;
2583 gap: var(--sp-3);
2584 border-bottom: 1px solid var(--line);
2585 margin: 0 0 var(--sp-4);
2586 position: sticky;
2587 top: 0;
2588 z-index: 14;
2589 background: var(--canvas);
2590 padding-top: var(--sp-1);
2591}
2592.mrbar nav.subtabs { border-bottom: 0; margin: 0; }
2593.finish-review { margin-bottom: var(--sp-1); }
2594.review-popmenu { width: 22rem; }
2595.commit-picker code { background: none; border: 0; padding: 0; font-size: var(--fs-1); }
2596.diffbar { display: flex; align-items: center; justify-content: space-between; margin: 0 0 var(--sp-3); }
2597.diffbar p.layoutpick { margin: 0; }
2598.diffwrap { display: block; }
2599.difflist { min-width: 0; }
2600@media (min-width: 68.01rem) {
2601 .diffwrap.diffgrid {
2602 display: grid;
2603 grid-template-columns: 16rem minmax(0, 1fr);
2604 gap: var(--sp-5);
2605 align-items: start;
2606 }
2607 .diffwrap.diffgrid > .difftoc {
2608 position: sticky;
2609 top: 3.25rem;
2610 margin: 0;
2611 max-height: calc(100vh - 4.5rem);
2612 overflow-y: auto;
2613 }
2614}
2615details.difffold { overflow: visible; }
2616details.difffold > summary {
2617 position: sticky;
2618 top: 2.75rem;
2619 z-index: 6;
2620 align-items: center;
2621 border-radius: var(--r-card) var(--r-card) 0 0;
2622}
2623details.difffold:not([open]) > summary { border-radius: var(--r-card); }
2624details.difffold .tablewrap { border-radius: 0 0 var(--r-card) var(--r-card); overflow-x: auto; }
2625.diffviewlink { font-family: var(--sans); font-size: var(--fs-1); font-weight: 500; }
2626.viewed-toggle {
2627 display: inline-flex;
2628 align-items: center;
2629 gap: 5px;
2630 font-family: var(--sans);
2631 font-size: var(--fs-1);
2632 color: var(--muted);
2633 font-weight: 400;
2634 margin-left: var(--sp-2);
2635 cursor: pointer;
2636}
2637.difftoc-list li.toc-viewed a { color: var(--muted); text-decoration: line-through; }
2638.idiff-del {
2639 background: color-mix(in srgb, var(--bad) 26%, transparent);
2640 border-radius: 2px;
2641}
2642.idiff-add {
2643 background: color-mix(in srgb, var(--ok) 26%, transparent);
2644 border-radius: 2px;
2645}
2646.hunk-expand {
2647 display: inline-flex;
2648 align-items: center;
2649 margin-right: var(--sp-2);
2650 padding: 0 6px;
2651 height: 20px;
2652 font-family: var(--sans);
2653 font-size: var(--fs-0);
2654 background: var(--card);
2655 color: var(--link);
2656 border: 1px solid var(--card-line);
2657 border-radius: var(--r-ctl);
2658}
2659.hunk-expand:hover { background: var(--hover); filter: none; }
2660.blobtip {
2661 display: flex;
2662 align-items: center;
2663 gap: var(--sp-2);
2664 flex-wrap: wrap;
2665 padding: var(--sp-2) var(--sp-4);
2666 margin: 0 0 var(--sp-3);
2667 background: var(--card);
2668 border: 1px solid var(--card-line);
2669 border-radius: var(--r-card);
2670 font-size: var(--fs-2);
2671}
2672.blobtip .subject { color: var(--fg); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
2673.code .line.range-hl { background: color-mix(in srgb, var(--mark) 18%, transparent); }
2674.code .line.range-hl .ln { border-left: 3px solid var(--mark); }
2675.priorblame { font-weight: 600; padding: 0 3px; border-radius: var(--r-ctl); }
2676.priorblame:hover { background: var(--hover); text-decoration: none; }
2677.branch-target-inp { max-width: 15rem; font-family: var(--mono); font-size: var(--fs-1); }
2678.rangediff .rd-hdr { color: var(--link); font-weight: 600; }
2679.rangediff .rd-add { color: var(--ok); }
2680.rangediff .rd-del { color: var(--bad); }
2681.rangediff .rd-ctx { color: var(--fg); }
2682article.comment:target { outline: 2px solid var(--mark); outline-offset: 2px; }
2683.quote-btn { font-size: var(--fs-1); color: var(--muted); }
2684.quote-btn:hover { color: var(--link); }
2685dialog.kbhelp { width: min(38rem, 92vw); padding: var(--sp-5); }
2686.kbhelp-trigger { cursor: pointer; }
2687.kbhelp-close { flex: none; }
2688.kbhelp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-4); }
2689.kbhelp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-5); }
2690@media (max-width: 40rem) { .kbhelp-grid { grid-template-columns: 1fr; } }
2691dl.kblist { margin: 0; display: flex; flex-direction: column; gap: var(--sp-2); font-size: var(--fs-2); }
2692dl.kblist > div { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
2693dl.kblist dt { font-family: var(--mono); font-size: var(--fs-0); }
2694dl.kblist dd { margin: 0; color: var(--muted); text-align: right; }
2695kbd {
2696 display: inline-block;
2697 padding: 1px 5px;
2698 font-family: var(--mono);
2699 font-size: var(--fs-0);
2700 border: 1px solid var(--card-line);
2701 border-radius: var(--r-ctl);
2702 background: var(--surface);
2703}
2704
2705/* ---- Phase 4: Composer tabs, autocomplete, saved queries & ANSI build logs ---- */
2706.format-inline {
2707 display: inline-flex;
2708 align-items: center;
2709 margin-left: auto;
2710}
2711.format-inline select {
2712 height: 32px;
2713 font-size: var(--fs-1);
2714 color: var(--muted);
2715}
2716.querybar {
2717 display: flex;
2718 gap: var(--sp-2);
2719 width: 100%;
2720 margin-bottom: var(--sp-2);
2721}
2722.querybar input[type="search"] {
2723 flex: 1 1 auto;
2724 min-width: 0;
2725}
2726.composer-bar {
2727 display: flex;
2728 align-items: center;
2729 gap: var(--sp-1);
2730 border-bottom: 1px solid var(--line);
2731 margin: var(--sp-2) 0;
2732}
2733.composer-tab {
2734 height: 30px;
2735 padding: 0 var(--sp-3);
2736 border: 1px solid transparent;
2737 border-bottom: 2px solid transparent;
2738 border-radius: var(--r-ctl) var(--r-ctl) 0 0;
2739 background: transparent;
2740 color: var(--muted);
2741 font-size: var(--fs-1);
2742 font-weight: 500;
2743 margin-bottom: -1px;
2744}
2745.composer-tab:hover { color: var(--fg); background: var(--hover); filter: none; }
2746.composer-tab[aria-selected="true"] {
2747 color: var(--fg);
2748 font-weight: 600;
2749 border-bottom-color: var(--mark);
2750 background: transparent;
2751}
2752.composer-hint {
2753 margin-left: auto;
2754 font-size: var(--fs-0);
2755 color: var(--muted);
2756}
2757@media (max-width: 40rem) { .composer-hint { display: none; } }
2758.composer-preview {
2759 min-height: 6rem;
2760 padding: var(--sp-3) var(--sp-4);
2761 margin-bottom: var(--sp-3);
2762 border: 1px solid var(--line);
2763 border-radius: var(--r-card);
2764 background: var(--inset);
2765}
2766html.js button.js-hidden-preview { display: none; }
2767.ac-menu {
2768 position: absolute;
2769 z-index: 70;
2770 list-style: none;
2771 margin: 0;
2772 padding: var(--sp-1);
2773 min-width: 14rem;
2774 max-width: 24rem;
2775 background: var(--card);
2776 border: 1px solid var(--card-line);
2777 border-radius: var(--r-card);
2778 box-shadow: var(--shadow);
2779 font-size: var(--fs-1);
2780}
2781.ac-menu li {
2782 display: flex;
2783 align-items: baseline;
2784 gap: var(--sp-2);
2785 padding: 5px var(--sp-2);
2786 border-radius: var(--r-ctl);
2787 cursor: pointer;
2788}
2789.ac-menu li:hover, .ac-menu li.ac-active { background: var(--hover); }
2790.ac-menu li strong { font-family: var(--mono); color: var(--link); flex: none; }
2791.ac-menu li span { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
2792.ansi-bold { font-weight: 700; }
2793.ansi-dim { opacity: 0.72; }
2794.ansi-red { color: var(--bad); }
2795.ansi-green { color: var(--ok); }
2796.ansi-yellow { color: var(--warn); }
2797.ansi-blue, .ansi-cyan { color: var(--link); }
2798.ansi-magenta { color: var(--done); }
2799.ansi-muted { color: var(--muted); }
internal/web/templates/account.html +29 −1 · view
@@ -22,6 +22,7 @@
2222 <li><a href="#notifications">Notifications</a></li>
2323 <li><a href="#appearance">Appearance</a></li>
2424 <li><a href="#tokens">API tokens</a></li>
25 <li><a href="#sessions">Browser sessions</a></li>
2526 <li><a href="#export">Export</a></li>
2627 <li><a href="#cli">On the command line</a></li>
2728 <li><a href="#delete">Delete account</a></li>
@@ -56,12 +57,14 @@ Write it with a push, or edit it here.</p>
5657<p class="meta">Your keys are your identity here. A <code>full</code> key can run
5758commands and push; a <code>git</code> key can only move git data (e.g., CI).</p>
5859{{if .Keys}}<div class="tablewrap"><table class="keys nowrap">
59<tr class="cols"><th scope="col">label</th><th scope="col">fingerprint</th><th scope="col">type</th><th scope="col">scope</th><th scope="col"><span class="vh">actions</span></th></tr>
60<tr class="cols"><th scope="col">label</th><th scope="col">fingerprint</th><th scope="col">type</th><th scope="col">scope</th><th scope="col">last used</th><th scope="col">expires</th><th scope="col"><span class="vh">actions</span></th></tr>
6061{{range .Keys}}<tr>
6162 <td>{{.Label}}</td>
6263 <td class="mono">{{.Fingerprint}}</td>
6364 <td>{{.Algo}}</td>
6465 <td><span class="chip">{{.Scope}}</span></td>
66 <td>{{if .LastUsed}}{{when .LastUsed}}{{else}}never{{end}}</td>
67 <td>{{.Expires}}</td>
6568 <td class="act"><details class="popover"><summary class="popbtn popbtn-danger">Remove</summary><div class="popmenu">
6669 <form method="post" action="/settings" class="popform"><input type="hidden" name="field" value="key-remove"><input type="hidden" name="fingerprint" value="{{.Fingerprint}}">{{template "confirmfield" .Confirm}}<button type="submit" class="danger">Remove</button></form>
6770 </div></details></td>
@@ -81,6 +84,8 @@ commands and push; a <code>git</code> key can only move git data (e.g., CI).</p>
8184 <option value="full">full: commands and git</option>
8285 <option value="git">git: git transport only</option>
8386 </select>
87 <label for="key-ttl">Expires after</label>
88 <input id="key-ttl" name="ttl" autocomplete="off" placeholder="e.g. 30d or 720h; empty never expires">
8489 <span class="btngroup"><button type="submit">Add key</button></span>
8590 </form>
8691</details>
@@ -241,6 +246,29 @@ account and where notifications go.</p>
241246</details>
242247</section>
243248
249<section id="sessions" class="setcard"><h2>Browser sessions</h2>
250<p class="meta">Active browser sessions on your account, matching <code>gitbay web sessions list</code>.</p>
251{{if .Sessions}}<div class="tablewrap"><table class="keys nowrap">
252<tr class="cols"><th scope="col">id</th><th scope="col">signed in</th><th scope="col">last used</th><th scope="col">expires</th><th scope="col"><span class="vh">actions</span></th></tr>
253{{range .Sessions}}<tr>
254 <td class="mono">{{.ID}}{{if eq .ID $.CurrentSession}} <span class="chip">this browser</span>{{end}}</td>
255 <td>{{when .CreatedAt}}</td>
256 <td>{{if .LastUsedAt}}{{when .LastUsedAt}}{{else}}never{{end}}</td>
257 <td>{{when .ExpiresAt}}</td>
258 <td class="act"><form method="post" action="/settings" class="inline">
259 <input type="hidden" name="field" value="session-revoke">
260 <input type="hidden" name="id" value="{{.ID}}">
261 <button type="submit" class="danger">End</button>
262 </form></td>
263</tr>
264{{end}}</table></div>
265<form method="post" action="/settings" class="actions">
266 <input type="hidden" name="field" value="session-revoke-all">
267 <button type="submit" class="danger">End all browser sessions</button>
268</form>
269{{else}}<p class="none">No active browser sessions.</p>{{end}}
270</section>
271
244272<section id="export" class="setcard"><h2>Export</h2>
245273<p class="meta">Your profile, repositories, issues and merge requests as one JSON bundle, matching <code>gitbay auth export</code>. Keys are excluded.</p>
246274<p><a class="button btn" href="/settings/export">Download bundle</a></p>
internal/web/templates/blame.html +2 −2 · view
@@ -20,9 +20,9 @@
2020{{range .Hunks}}<div class="blamehunk">
2121 <div class="blameinfo">
2222 <p class="subject"><a href="/{{$.Repo.OwnerName}}/{{$.Repo.Name}}/commit/{{.SHA}}">{{.Summary}}</a></p>
23 <p class="meta"><code><a href="/{{$.Repo.OwnerName}}/{{$.Repo.Name}}/commit/{{.SHA}}">{{.ShortSHA}}</a></code> <span title="{{.AuthorEmail}}">{{.AuthorName}}</span> · {{when .Date}} {{template "sigbadge" .Sig}}</p>
23 <p class="meta"><code><a href="/{{$.Repo.OwnerName}}/{{$.Repo.Name}}/commit/{{.SHA}}">{{.ShortSHA}}</a></code>{{if .ParentSHA}} <a class="priorblame" href="/{{$.Repo.OwnerName}}/{{$.Repo.Name}}/blame/{{.ParentSHA}}/{{$.Path}}" title="Blame prior to this commit">↢</a>{{end}} <span title="{{.AuthorEmail}}">{{.AuthorName}}</span> · {{when .Date}} {{template "sigbadge" .Sig}}</p>
2424 </div>
25 <pre class="blamecode" tabindex="0">{{range .Numbered}}<span class="lineno">{{.N}}</span>{{.Text}}
25 <pre class="blamecode chroma" tabindex="0">{{range .Numbered}}<span class="lineno">{{.N}}</span>{{if .Code}}{{.Code}}{{else}}{{.Text}}{{end}}
2626{{end}}</pre>
2727</div>
2828{{else}}<p class="empty-note">empty file</p>{{end}}
internal/web/templates/blob.html +3 −1 · view
@@ -4,7 +4,7 @@
44<h1 class="vh">{{.Path}}</h1>
55<div class="blobgrid">
66{{template "filenav" .Nav}}
7<div class="blobmain">
7<div class="blobmain" data-commit="{{.Commit}}" data-permalink="/{{.Repo.OwnerName}}/{{.Repo.Name}}/blob/{{.Commit}}/{{.Path}}">
88<div class="pathbar">
99 {{template "refmenu" .}}
1010 <span class="crumbs"><a href="/{{.Repo.OwnerName}}/{{.Repo.Name}}">{{.Repo.Name}}</a>/{{range .Crumbs}}<a href="{{.URL}}">{{.Name}}</a>/{{end}}<strong>{{.Base}}</strong></span>
@@ -13,10 +13,12 @@
1313 {{if .Renderable}}{{if .Rendered}}<a class="button btn" aria-current="page" href="?"><strong>rendered</strong></a><a class="button btn" href="?view=source">source</a>{{else}}<a class="button btn" href="?">rendered</a><a class="button btn" aria-current="page" href="?view=source"><strong>source</strong></a>{{end}}{{end}}
1414 <a class="button btn" href="/{{.Repo.OwnerName}}/{{.Repo.Name}}/log/{{.Ref}}?path={{.Path}}">history</a>
1515 {{if not .Binary}}<a class="button btn" href="/{{.Repo.OwnerName}}/{{.Repo.Name}}/blame/{{.Ref}}/{{.Path}}">blame</a>{{end}}
16 {{if and (not .Binary) (not .Image)}}<button type="button" class="btn" data-copy-url="/{{.Repo.OwnerName}}/{{.Repo.Name}}/raw/{{.Ref}}/{{.Path}}">copy</button>{{end}}
1617 <a class="button btn" href="/{{.Repo.OwnerName}}/{{.Repo.Name}}/raw/{{.Ref}}/{{.Path}}">raw</a>
1718 {{if .Viewer}}<a class="button" href="/{{.Repo.OwnerName}}/{{.Repo.Name}}/edit/{{.Ref}}/{{.Path}}">edit</a>{{end}}
1819 </div>
1920</div>
21{{with .Tip}}{{if .SHA}}<div class="blobtip"><span class="who">{{template "authorname" dict "Name" .Author "User" .User "Email" .Email}}</span> <a class="subject" href="/{{$.Repo.OwnerName}}/{{$.Repo.Name}}/commit/{{.SHA}}">{{.Subject}}</a><span class="spacer"></span><a class="sha" href="/{{$.Repo.OwnerName}}/{{$.Repo.Name}}/commit/{{.SHA}}"><code>{{short .SHA}}</code></a> <span class="age"{{if not .When.IsZero}} title="{{whenT .When}}"{{end}}>{{ago .When}}</span></div>{{end}}{{end}}
2022<p class="filefacts">{{if .Lines}}{{.Lines}} lines · {{end}}{{.Size}} bytes{{if .Exec}} · executable{{end}}{{if .Symlink}} · symlink{{end}}</p>
2123{{if .Symbols}}<details class="symlist"><summary>{{len .Symbols}} symbol{{if ne (len .Symbols) 1}}s{{end}} in this file</summary>
2224<ul>{{range .Symbols}}<li><a href="{{if $.Rendered}}?view=source{{end}}#L{{.Line}}"><code>{{.Name}}</code></a> <span class="meta">{{.Kind}}, line {{.Line}}</span></li>
internal/web/templates/build.html +8 −2 · view
@@ -8,6 +8,12 @@
88<span class="spacer"></span>
99<div class="btngroup">
1010{{if not .Live}}<button type="button" class="btn" data-refresh="self" data-refresh-target="build-root">Refresh</button>{{end}}
11{{if and .CanWrite (not .Live) .Build.Job (ne .Build.Status "pending") (ne .Build.Status "running")}}
12<form method="post" action="/{{.Repo.OwnerName}}/{{.Repo.Name}}/builds" class="inline">
13 <input type="hidden" name="job" value="{{.Build.Job}}">
14 <button type="submit" class="btn">Re-run {{.Build.Job}}</button>
15</form>
16{{end}}
1117{{if and .CanWrite (or (eq .Build.Status "pending") (eq .Build.Status "running"))}}
1218<form method="post" action="/{{.Repo.OwnerName}}/{{.Repo.Name}}/builds/{{.Build.Number}}/cancel" class="inline">
1319 <button type="submit" class="danger">{{if eq .Build.Status "running"}}Cancel (stops at the runner's next check){{else}}Cancel{{end}}</button>
@@ -21,8 +27,8 @@
2127{{else if .Steps}}{{$total := len .Build.Steps}}{{range .Steps}}
2228<details class="difffold buildstep"{{if .Failed}} id="failed" open{{end}}>
2329 <summary>{{if .N}}<span>step {{.N}}/{{$total}}</span> <code>{{.Head}}</code>{{else}}<span>setup</span>{{end}}{{if .Failed}} <span class="chip check-failure">failed</span>{{end}}</summary>
24 <pre class="code buildlog" tabindex="0">{{.Text}}</pre>
30 <pre class="code buildlog" tabindex="0">{{if .TextHTML}}{{.TextHTML}}{{else}}{{.Text}}{{end}}</pre>
2531</details>{{end}}
26{{else if .Log}}<pre class="code buildlog" tabindex="0">{{.Log}}</pre>{{else}}<p class="empty-note">no log yet</p>{{end}}
32{{else if .Log}}<pre class="code buildlog" tabindex="0">{{if .LogHTML}}{{.LogHTML}}{{else}}{{.Log}}{{end}}</pre>{{else}}<p class="empty-note">no log yet</p>{{end}}
2733</div>
2834{{end}}
internal/web/templates/commit.html +1 −1 · view
@@ -15,5 +15,5 @@
1515 <pre class="message" tabindex="0">{{.Message}}</pre>
1616</div>
1717{{if .DiffTruncated}}<p class="error" role="alert">This patch is larger than 4 MiB and is cut off below. Clone the repository to see all of it.</p>{{end}}
18{{template "difffiles" dict "Files" .DiffFiles "Base" "" "Viewer" "" "L" .Layout}}
18{{template "difffiles" dict "Files" .DiffFiles "Base" "" "Viewer" "" "L" .Layout "RepoPath" .Repo.Path "HeadSHA" .SHA}}
1919{{end}}
internal/web/templates/compare.html +1 −1 · view
@@ -18,5 +18,5 @@
1818</ul>{{else}}<p class="empty-note"><code>{{.Head}}</code> has nothing that <code>{{.Base}}</code> does not.</p>{{end}}
1919{{if .DiffFiles}}<p class="diffstat">{{.Stat.Files}} file{{if ne .Stat.Files 1}}s{{end}} changed, <span class="add">+{{.Stat.Adds}}</span> <span class="del">−{{.Stat.Dels}}</span>{{if .DiffTruncated}} · shown up to 4 MiB; the counts and the last file are partial{{end}}</p>
2020{{if .DiffTruncated}}<p class="error" role="alert">This diff is larger than 4 MiB and is cut off below.</p>{{end}}
21{{template "difffiles" dict "Files" .DiffFiles "Base" "" "Viewer" "" "L" .Layout}}{{end}}
21{{template "difffiles" dict "Files" .DiffFiles "Base" "" "Viewer" "" "L" .Layout "RepoPath" .Repo.Path "HeadSHA" .Head}}{{end}}
2222{{end}}
internal/web/templates/dashboard.html +1 · view
@@ -23,6 +23,7 @@
2323<div class="pagehead">
2424 <h1>Dashboard</h1>
2525 <span class="grow"></span>
26 <a class="button btn" href="/{{.Viewer}}/-/queries">Saved queries</a>
2627 <button type="button" class="btn" data-refresh="/" data-refresh-target="dash-root">Refresh</button>
2728 <a class="button" href="/new">New repository</a>
2829</div>
internal/web/templates/edit.html +3 −1 · view
@@ -12,13 +12,15 @@
1212{{if .Error}}<p class="error" role="alert">{{.Error}}</p>{{end}}
1313{{if .Blocked}}<p class="empty-note">{{.Blocked}}</p>{{else}}
1414<section class="setcard">
15{{if .RequireMR}}<p class="notice" role="status">Branch <code>{{.Ref}}</code> accepts changes through merge requests only. Committing below creates a new branch and opens a merge request.</p>{{end}}
1516{{if .Creating}}<p class="meta"><code>{{.Path}}</code> does not exist on {{.Ref}}; committing creates it.</p>{{end}}
1617{{if .Draft.Is "content"}}{{template "previewblock" .Draft.HTML}}{{end}}
1718<form method="post" action="/{{.Repo.OwnerName}}/{{.Repo.Name}}/edit/{{.Ref}}/{{.Path}}" class="editform">
1819 <p><textarea name="content" aria-label="File contents" rows="24" spellcheck="false">{{.Content}}</textarea></p>
1920 <div class="commitbar">
2021 <input name="message" aria-label="Commit message" placeholder="Commit message" value="{{.Draft.Or "content" "message" ""}}">
21 <button type="submit">Commit to {{.Ref}}</button>
22 <input name="target_branch" class="branch-target-inp" aria-label="Target branch" placeholder="Branch (blank commits to {{.Ref}})" value="{{.ProposeBranch}}"{{if .RequireMR}} required{{end}}>
23 <button type="submit">{{if .RequireMR}}Propose merge request{{else}}Commit changes{{end}}</button>
2224 {{if .Markup}}{{template "previewbtn"}}{{end}}
2325 </div>
2426 <p class="crumbs">this commit will be unsigned and authored as {{.Viewer}} · ⌘↵ to commit</p>
internal/web/templates/globalsearch.html +1 −1 · view
@@ -36,7 +36,7 @@
3636 {{/* the kind in the words the CLI prints, so a hit reads the same in
3737 both places; it is why the meta no longer says "repository" */}}
3838 <span class="chip chip-neutral">{{.Kind}}</span>
39 {{if .State}}<span class="chip chip-{{.State}}">{{.State}}</span>{{end}}
39 {{if .State}}<span class="chip {{if eq .State "open"}}chip-open{{else if or (eq .State "merged") (and (eq .Kind "issue") (eq .State "closed"))}}chip-done{{else if eq .State "source_gone"}}chip-source_gone{{else}}chip-closed{{end}}">{{.State}}</span>{{end}}
4040</li>
4141{{end}}
4242</ul>
internal/web/templates/issue.html +9 −9 · view
@@ -5,13 +5,13 @@
55<a href="/{{.Issue.Author}}">{{.Issue.Author}}</a> opened this on {{when .Issue.CreatedAt}}
66{{if .Issue.Labels}} · {{range .Issue.Labels}}<a class="chip label" style="{{index $.LabelColors .}}" href="/{{$.Repo.OwnerName}}/{{$.Repo.Name}}/issues?label={{.}}">{{.}}</a> {{end}}{{end}}
77{{if .Issue.Assignees}} · assigned to {{range .Issue.Assignees}}{{.}} {{end}}{{end}}
8{{if .Issue.Milestone}} · milestone <a href="/{{.Repo.OwnerName}}/{{.Repo.Name}}/milestones">{{.Issue.Milestone}}</a>{{end}}</p>
8{{if .Issue.Milestone}} · milestone <a href="/{{.Repo.OwnerName}}/{{.Repo.Name}}/issues?milestone={{urlquery .Issue.Milestone}}">{{.Issue.Milestone}}</a>{{end}}</p>
99{{if .Notice}}<p class="error" role="alert">{{.Notice}}</p>{{end}}
1010
1111<div class="withaside">
1212<div class="mainside">
1313<h2>Discussion</h2>
14{{if .CanEdit}}<details class="editbox"{{if .Draft.Is "edit"}} open{{end}}><summary>edit</summary>
14{{if .CanEdit}}<details class="editbox"{{if .Draft.Is "edit"}} open{{end}}><summary>Edit</summary>
1515{{if .Draft.Is "edit"}}{{template "previewblock" .Draft.HTML}}{{end}}
1616<form method="post" action="/{{.Repo.OwnerName}}/{{.Repo.Name}}/issues/{{.Issue.Number}}/edit" class="commentform">
1717<p><input type="text" name="title" aria-label="Title" value="{{.Draft.Or "edit" "title" .Issue.Title}}" required></p>
@@ -19,15 +19,15 @@
1919<p><input type="text" name="labels" aria-label="Labels" value="{{$.Draft.Or "edit" "labels" (join .Issue.Labels " ")}}" placeholder="labels, space-separated (write access)"></p>
2020<p><button type="submit" class="btn">Save</button> {{template "previewbtn"}}</p>
2121</form></details>{{end}}
22{{if .BodyHTML}}<article class="comment">
23 <header class="commenthead"><strong><a href="/{{.Issue.Author}}">{{.Issue.Author}}</a></strong> <span class="when">{{when .Issue.CreatedAt}}</span></header>
22{{if .BodyHTML}}<article class="comment" id="issue-body">
23 <header class="commenthead"><strong><a href="/{{.Issue.Author}}">{{.Issue.Author}}</a></strong> <span class="when">{{when .Issue.CreatedAt}}</span>{{if $.Viewer}}<span class="grow"></span><button type="button" class="linklike quote-btn" data-quote-from="issue-body">Quote</button>{{end}}</header>
2424 <div class="rendered">{{.BodyHTML}}</div>
2525 {{template "reactions" index .Reactions 0}}
2626</article>{{else}}{{template "reactions" index .Reactions 0}}{{end}}
2727{{range .Comments}}
2828{{if eq .Kind "system"}}<div class="syscomment">{{.BodyHTML}} <span class="when">{{when .CreatedAt}}</span></div>
29{{else}}<article class="comment">
30 <header class="commenthead"><strong><a href="/{{.Author}}">{{.Author}}</a></strong> <span class="when">{{when .CreatedAt}}</span></header>
29{{else}}<article class="comment" id="comment-{{.ID}}">
30 <header class="commenthead"><strong><a href="/{{.Author}}">{{.Author}}</a></strong> <a class="when" href="#comment-{{.ID}}">{{when .CreatedAt}}</a>{{if $.Viewer}}<span class="grow"></span><button type="button" class="linklike quote-btn" data-quote-from="comment-{{.ID}}">Quote</button>{{end}}</header>
3131 <div class="rendered">{{.BodyHTML}}</div>
3232 {{template "reactions" index $.Reactions .ID}}
3333</article>{{end}}
@@ -35,8 +35,8 @@
3535{{if .Viewer}}
3636{{if .Draft.Is "comment"}}{{template "previewblock" .Draft.HTML}}{{end}}
3737<form method="post" action="/{{.Repo.OwnerName}}/{{.Repo.Name}}/issues/{{.Issue.Number}}/comment" class="commentform">
38<p><textarea name="body" aria-label="Comment" rows="4" placeholder="Comment as {{.Viewer}}">{{.Draft.Or "comment" "body" ""}}</textarea></p>
39<p><button type="submit">Comment</button> {{template "previewbtn"}}</p>
38<p><textarea id="main-comment-box" name="body" aria-label="Comment" rows="4" placeholder="Comment as {{.Viewer}}">{{.Draft.Or "comment" "body" ""}}</textarea></p>
39<p class="btngroup"><button type="submit">Comment</button> {{template "previewbtn"}} <label class="format-inline"><span class="vh">Comment markup</span><select name="format" aria-label="Comment markup">{{$cfmt := .Draft.Or "comment" "format" "md"}}<option value="md"{{if ne $cfmt "org"}} selected{{end}}>Markdown</option><option value="org"{{if eq $cfmt "org"}} selected{{end}}>Org</option></select></label></p>
4040</form>
4141{{end}}
4242</div>
@@ -87,7 +87,7 @@
8787 </form>
8888 </div></details>{{end}}
8989 </div>
90 {{if .Issue.Milestone}}<p class="row"><a href="/{{.Repo.OwnerName}}/{{.Repo.Name}}/milestones">{{.Issue.Milestone}}</a></p>
90 {{if .Issue.Milestone}}<p class="row"><a href="/{{.Repo.OwnerName}}/{{.Repo.Name}}/issues?milestone={{urlquery .Issue.Milestone}}">{{.Issue.Milestone}}</a></p>
9191 {{else}}<p class="none">None</p>{{end}}
9292 </div>
9393 {{if .CanEdit}}
internal/web/templates/issues.html +13 −3 · view
@@ -12,6 +12,14 @@
1212 <input type="hidden" name="state" value="{{.State}}">
1313 </form>
1414 {{range .Filters}}<p class="meta">{{.Key}}: {{if eq .Key "label"}}<span class="chip label" style="{{index $.LabelColors .Value}}">{{.Value}}</span>{{else}}<b>{{.Value}}</b>{{end}} <a href="{{.Clear}}">clear</a></p>{{end}}
15 {{with field . "People"}}{{if .}}
16 <details class="popover"><summary class="popbtn">Author ▾</summary><div class="popmenu">
17 <div class="picker-list">{{range .}}<a class="picker-btn" href="?state={{$.State}}&amp;author={{urlquery .}}">{{.}}</a>{{end}}</div>
18 </div></details>
19 <details class="popover"><summary class="popbtn">Assignee ▾</summary><div class="popmenu">
20 <div class="picker-list">{{range .}}<a class="picker-btn" href="?state={{$.State}}&amp;assignee={{urlquery .}}">{{.}}</a>{{end}}</div>
21 </div></details>
22 {{end}}{{end}}
1523 <span class="spacer"></span>
1624 <div class="btngroup">
1725 <a class="button btn" href="/{{.Repo.OwnerName}}/{{.Repo.Name}}/milestones">Milestones</a>
@@ -21,13 +29,15 @@
2129</div>
2230{{if .Facets}}<nav class="statebar" aria-label="State" data-tab-swap="issues-root">{{range (index .Facets 0).Items}}<a{{if .Active}} aria-current="page"{{end}} href="{{.Href}}">{{.Label}}</a>{{end}}</nav>{{end}}
2331<ul class="issuelist rows">
24{{range .Issues}}<li>
32{{range $iss := .Issues}}<li>
2533 <div class="issuemain">
2634 <p class="title"><a href="/{{$.Repo.OwnerName}}/{{$.Repo.Name}}/issues/{{.Number}}">{{.Title}}</a>
2735 {{range .Labels}}<a class="chip label" style="{{index $.LabelColors .}}" href="?label={{.}}">{{.}}</a> {{end}}</p>
28 <p class="meta">#{{.Number}} opened by <a href="/{{.Author}}">{{.Author}}</a>{{if .Milestone}} · in <a href="/{{$.Repo.OwnerName}}/{{$.Repo.Name}}/milestones">{{.Milestone}}</a>{{end}}</p>
36 <p class="meta">#{{.Number}} opened by <a href="/{{.Author}}">{{.Author}}</a>{{if .Assignees}} · assigned to {{range $i, $a := .Assignees}}{{if $i}}, {{end}}<a href="?state={{$.State}}&amp;assignee={{urlquery $a}}">{{$a}}</a>{{end}}{{end}}{{if .Milestone}} · in <a href="/{{$.Repo.OwnerName}}/{{$.Repo.Name}}/issues?milestone={{urlquery .Milestone}}">{{.Milestone}}</a>{{end}}{{if .UpdatedAt}} · {{when .UpdatedAt}}{{end}}</p>
37 </div>
38 <div class="issueside">
39 {{if eq $.State "all"}}<span class="chip {{if eq .State "open"}}chip-open{{else}}chip-done{{end}}">{{.State}}</span> {{end}}{{with field $ "CommentCounts"}}{{with index . $iss.ID}}<span class="chip chip-neutral" title="{{.}} comment{{if ne . 1}}s{{end}}">{{.}} <span class="vh">comments</span></span>{{end}}{{end}}
2940 </div>
30 {{if eq $.State "all"}}<span class="chip {{if eq .State "open"}}chip-open{{else}}chip-done{{end}}">{{.State}}</span>{{end}}
3141</li>
3242{{else}}{{if .Query}}<li class="empty">no {{if ne .State "all"}}{{.State}} {{end}}issues matching “{{.Query}}”</li>
3343{{else}}<li class="empty">no {{if ne .State "all"}}{{.State}} {{end}}issues{{if .Viewer}} — <a href="/{{.Repo.OwnerName}}/{{.Repo.Name}}/issues/new">open one</a>{{end}}</li>{{end}}{{end}}
internal/web/templates/layout.html +67 −17 · view
@@ -35,6 +35,7 @@
3535 </form>
3636 <span class="railgap"></span>
3737 <div class="railfoot">
38 <button type="button" class="railicon kbhelp-trigger" aria-label="Keyboard shortcuts" title="Keyboard shortcuts (?)">{{template "icon" "kbd"}}<span class="vh">Keyboard shortcuts</span></button>
3839 {{if .Viewer}}
3940 <details class="railcreate">
4041 <summary class="railicon raildrop-trigger" aria-label="Create new" title="Create new">{{template "icon" "plus"}}<span class="railcaret" aria-hidden="true">▾</span><span class="vh">Create new</span></summary>
@@ -42,6 +43,7 @@
4243 <a href="/new#create">{{template "icon" "plus"}} New repository</a>
4344 <a href="/new#import">{{template "icon" "file"}} Import repository</a>
4445 <a href="/new#org">{{template "icon" "person"}} New organization</a>
46 <a href="/{{.Viewer}}/-/snippets/new">{{template "icon" "snippet"}} New snippet</a>
4547 </div>
4648 </details>
4749 {{template "raillink" dict "Href" "/notifications" "Icon" "bell" "Name" "Notifications" "Current" (eq (str . "Tab") "notifications") "Count" .Rail.Unread}}
@@ -50,7 +52,10 @@
5052 <div class="raildrop">
5153 <a class="railuser" href="/{{.Viewer}}">{{template "icon" "person"}} <span><strong>{{.Viewer}}</strong></span></a>
5254 <a href="/{{.Viewer}}/-/repositories">{{template "icon" "folder"}} Your repositories</a>
53 <a href="/{{.Viewer}}/-/bookmarks">{{template "icon" "bookmark"}} Bookmarks</a>
55 <a href="/{{.Viewer}}/-/snippets">{{template "icon" "snippet"}} Your snippets</a>
56 <a href="/{{.Viewer}}/-/queries">{{template "icon" "query"}} Saved queries</a>
57 <a href="/{{.Viewer}}/-/bookmarks">{{template "icon" "star"}} Bookmarks</a>
58 {{if .Rail.Pins}}<div class="railpins-mob"><hr class="railsep">{{range .Rail.Pins}}<a href="/{{.Owner}}/{{.Name}}">{{template "icon" "pin"}} {{.Owner}}/{{.Name}}</a>{{end}}</div>{{end}}
5459 <hr class="railsep">
5560 {{$settings := index $items 1}}<a{{if $settings.Current}} aria-current="page"{{end}} href="{{$settings.Href}}">{{template "icon" $settings.Icon}} {{$settings.Name}}</a>
5661 {{$admin := index $items 2}}{{if $admin.Show}}<a{{if $admin.Current}} aria-current="page"{{end}} href="{{$admin.Href}}">{{template "icon" $admin.Icon}} {{$admin.Name}}</a>{{end}}
@@ -67,7 +72,7 @@
6772<header class="repohead">
6873<div class="wrap">
6974 {{$top := topTab (str $ "Tab")}}
70 <div class="identity">
75 <div class="identity" data-repo="{{.OwnerName}}/{{.Name}}" data-ref="{{or (str $ "Ref") .DefaultBranch}}">
7176 {{if field $ "RepoHome"}}<h1 class="repotitle"><a class="owner" href="/{{.OwnerName}}">{{.OwnerName}}</a><span class="sep">/</span>{{.Name}}</h1>
7277 {{else}}<p class="repotitle"><a class="owner" href="/{{.OwnerName}}">{{.OwnerName}}</a><span class="sep">/</span><a href="/{{.OwnerName}}/{{.Name}}">{{.Name}}</a></p>{{end}}
7378 {{if eq .Visibility "private"}}<span class="chip">Private</span>{{end}}
@@ -76,10 +81,14 @@
7681 with the name so the header is two rows on every page. */}}
7782 {{if eq $top "code"}}{{if or (field $ "Desc") (field $ "Topics") $.Repo.Settings.Website}}<p class="repodesc">{{with field $ "Desc"}}{{.}}{{end}} {{with field $ "Topics"}}{{range .}}<a class="chip topic" href="/explore?q={{.}}">{{.}}</a> {{end}}{{end}}{{with $.Repo.Settings.Website}}<a class="site" href="{{.}}" rel="nofollow">{{.}}</a>{{end}}</p>{{end}}{{end}}
7883 <span class="grow"></span>
79 {{if $.Viewer}}<form method="post" action="/{{.OwnerName}}/{{.Name}}/pin" class="inline"><button type="submit" class="btn" aria-pressed="{{if field $ "Pinned"}}true{{else}}false{{end}}" title="Pinned repositories show on your dashboard"><span aria-hidden="true">{{if field $ "Pinned"}}★{{else}}☆{{end}}</span> {{if field $ "Pinned"}}Pinned{{else}}Pin{{end}}</button></form>
80 <form method="post" action="/{{.OwnerName}}/{{.Name}}/watch" class="inline"><button type="submit" class="btn" aria-pressed="{{if ne (str $ "Watch") ""}}true{{else}}false{{end}}" title="{{if eq (str $ "Watch") "watching"}}Watching: every issue, request and build. Click to mute.{{else if eq (str $ "Watch") "muted"}}Muted: nothing from this repository. Click to stop muting.{{else}}Only what involves you. Click to watch everything.{{end}}">{{if eq (str $ "Watch") "watching"}}Watching{{else if eq (str $ "Watch") "muted"}}Muted{{else}}Watch{{end}}</button></form>
81 <form method="post" action="/{{.OwnerName}}/{{.Name}}/bookmark" class="inline"><button type="submit" class="btn" aria-pressed="{{if field $ "Marked"}}true{{else}}false{{end}}" title="Bookmarked lists it under Bookmarks">{{if field $ "Marked"}}Bookmarked{{else}}Bookmark{{end}}</button></form>
82 <a class="button btn" href="/{{.OwnerName}}/{{.Name}}/fork">Fork</a>{{end}}
84 {{if $.Viewer}}<form method="post" action="/{{.OwnerName}}/{{.Name}}/pin" class="inline"><button type="submit" class="btn" aria-pressed="{{if field $ "Pinned"}}true{{else}}false{{end}}" title="Pinned repositories show on your dashboard"><span aria-hidden="true">{{template "icon" "pin"}}</span> {{if field $ "Pinned"}}Pinned{{else}}Pin{{end}}</button></form>
85 <div class="splitbtn"><form method="post" action="/{{.OwnerName}}/{{.Name}}/watch" class="inline"><button type="submit" class="btn" aria-pressed="{{if ne (str $ "Watch") ""}}true{{else}}false{{end}}" title="{{if eq (str $ "Watch") "watching"}}Watching: every issue, request and build. Click to mute.{{else if eq (str $ "Watch") "muted"}}Muted: nothing from this repository. Click to stop muting.{{else}}Only what involves you. Click to watch everything.{{end}}"><span class="btnicon" aria-hidden="true">{{template "icon" "eye"}}</span>{{if eq (str $ "Watch") "watching"}}Watching{{else if eq (str $ "Watch") "muted"}}Muted{{else}}Watch{{end}}</button></form><details class="popover watchpop"><summary class="button btn splitcaret" aria-label="Choose notification level">▾</summary><div class="popmenu">
86 <form method="post" action="/{{.OwnerName}}/{{.Name}}/watch" class="inline"><input type="hidden" name="mode" value="default"><button type="submit" class="watchopt" aria-pressed="{{if eq (str $ "Watch") ""}}true{{else}}false{{end}}"><b>Participating</b><span>Only threads and mentions that involve you.</span></button></form>
87 <form method="post" action="/{{.OwnerName}}/{{.Name}}/watch" class="inline"><input type="hidden" name="mode" value="watching"><button type="submit" class="watchopt" aria-pressed="{{if eq (str $ "Watch") "watching"}}true{{else}}false{{end}}"><b>Watching</b><span>Every issue, merge request, and build.</span></button></form>
88 <form method="post" action="/{{.OwnerName}}/{{.Name}}/watch" class="inline"><input type="hidden" name="mode" value="muted"><button type="submit" class="watchopt" aria-pressed="{{if eq (str $ "Watch") "muted"}}true{{else}}false{{end}}"><b>Muted</b><span>Silence all alerts from this repository.</span></button></form>
89 </div></details></div>
90 <form method="post" action="/{{.OwnerName}}/{{.Name}}/bookmark" class="inline"><button type="submit" class="btn" aria-pressed="{{if field $ "Marked"}}true{{else}}false{{end}}" title="Bookmarked lists it under Bookmarks">{{template "icon" "star"}} {{if field $ "Marked"}}Bookmarked{{else}}Bookmark{{end}}{{with field $ "Bookmarks"}}{{if .}} <i class="btncount">{{.}}</i>{{end}}{{end}}</button></form>
91 <a class="button btn" href="/{{.OwnerName}}/{{.Name}}/fork">{{template "icon" "fork"}} Fork{{with field $ "Forks"}}{{if .}} <i class="btncount">{{.}}</i>{{end}}{{end}}</a>{{end}}
8392 </div>
8493 {{if eq $top "code"}}{{if field $ "Mirrors"}}<p class="repometa">{{range $i, $m := field $ "Mirrors"}}{{if $i}} · {{end}}{{if eq $m.Direction "push"}}mirrors to{{else}}mirrors from{{end}} <a href="{{$m.URL}}" rel="nofollow">{{$m.Target}}</a>{{if $m.Error}}, <span class="bad">sync error: {{$m.Error}}</span>{{else if $m.Synced}}, synced {{$m.Synced}}{{end}}{{end}}</p>{{end}}{{end}}
8594 {{/* A tab's own count badge is omitted at zero (an empty <i> reads as
@@ -111,10 +120,41 @@
111120</div>
112121<dialog id="cmdk" class="cmdk" aria-label="Jump to">
113122 <div class="cmdk-box">
114 <input type="search" aria-label="Filter destinations" placeholder="Jump to repository, tab, or page…">
123 <input type="search" aria-label="Filter destinations" placeholder="Jump to repository, file, issue, MR, or page…">
115124 <ul class="cmdk-list"></ul>
116125 </div>
117126</dialog>
127<dialog id="kbhelp" class="cmdk kbhelp" aria-label="Keyboard shortcuts">
128 <div class="kbhelp-head">
129 <strong>Keyboard shortcuts</strong>
130 <button type="button" class="linklike kbhelp-close">Close</button>
131 </div>
132 <div class="kbhelp-grid">
133 <div>
134 <h2 class="colhead">Global</h2>
135 <dl class="kblist">
136 <div><dt><kbd>⌘K</kbd></dt><dd>Command palette &amp; jump</dd></div>
137 <div><dt><kbd>/</kbd></dt><dd>Focus search</dd></div>
138 <div><dt><kbd>?</kbd></dt><dd>Show this help</dd></div>
139 <div><dt><kbd>g</kbd> <kbd>d</kbd></dt><dd>Dashboard</dd></div>
140 <div><dt><kbd>g</kbd> <kbd>e</kbd></dt><dd>Explore repositories</dd></div>
141 <div><dt><kbd>g</kbd> <kbd>n</kbd></dt><dd>Notifications</dd></div>
142 </dl>
143 </div>
144 <div>
145 <h2 class="colhead">Repository &amp; editor</h2>
146 <dl class="kblist">
147 <div><dt><kbd>t</kbd></dt><dd>Find file in repository</dd></div>
148 <div><dt><kbd>y</kbd></dt><dd>Copy immutable SHA permalink</dd></div>
149 <div><dt><kbd>g</kbd> <kbd>c</kbd></dt><dd>Code tab</dd></div>
150 <div><dt><kbd>g</kbd> <kbd>i</kbd></dt><dd>Issues tab</dd></div>
151 <div><dt><kbd>g</kbd> <kbd>m</kbd></dt><dd>Merge requests tab</dd></div>
152 <div><dt><kbd>g</kbd> <kbd>b</kbd></dt><dd>Builds tab</dd></div>
153 <div><dt><kbd>⌘↵</kbd></dt><dd>Submit active form</dd></div>
154 </dl>
155 </div>
156 </div>
157</dialog>
118158</body>
119159</html>{{end}}
120160
@@ -137,6 +177,12 @@
137177{{- else if eq . "person"}}<circle cx="8" cy="5.5" r="2.75"/><path d="M2.75 14a5.25 5.25 0 0 1 10.5 0"/>
138178{{- else if eq . "folder"}}<path d="M1.75 3.25h4l1.5 1.75h6.5v7.5a.5.5 0 0 1-.5.5H2.25a.5.5 0 0 1-.5-.5Z"/>
139179{{- else if eq . "file"}}<path d="M3.25 2.75h6L12.75 6v7.25a.5.5 0 0 1-.5.5H3.75a.5.5 0 0 1-.5-.5Z"/><path d="M9 2.75V6h3.75"/>
180{{- else if eq . "pin"}}<path d="m9.5 2.25 4.25 4.25-1.75 1.25-.75 3-4.5-4.5 3-.75Z"/><path d="M6.75 9.25 2.5 13.5"/>
181{{- else if eq . "star"}}<path d="m8 2 1.85 3.75 4.15.6-3 2.92.71 4.13L8 11.45 4.29 13.4 5 9.27 2 6.35l4.15-.6Z"/>
182{{- else if eq . "fork"}}<circle cx="5" cy="3.5" r="1.5"/><circle cx="11" cy="3.5" r="1.5"/><circle cx="8" cy="12.5" r="1.5"/><path d="M5 5v2a3 3 0 0 0 3 3m3-5v2a3 3 0 0 1-3 3m0 0v1"/>
183{{- else if eq . "eye"}}<path d="M1.5 8s2.5-4.5 6.5-4.5S14.5 8 14.5 8s-2.5 4.5-6.5 4.5S1.5 8 1.5 8Z"/><circle cx="8" cy="8" r="2"/>
184{{- else if eq . "query"}}<path d="M2.5 4.25h11M4.5 8h7M6.5 11.75h3"/>
185{{- else if eq . "kbd"}}<rect x="1.75" y="3.75" width="12.5" height="8.5" rx="1.5"/><path d="M4.5 6.75h.01M8 6.75h.01M11.5 6.75h.01M5 9.75h6"/>
140186{{- end}}</svg>{{end}}
141187
142188{{/* raillink draws one square in the rail: the icon, the name for a
@@ -179,7 +225,7 @@
179225{{define "sidecol"}}<nav class="sidecol" aria-label="Filters">
180226<details class="sidedrop">
181227<summary><span class="sideword">Filters</span>{{range .}}{{range .Items}}{{if .Active}} <span class="sideon">{{.Label}}</span>{{end}}{{end}}{{end}}</summary>
182 {{range .}}{{if .Items}}<div class="grp">
228 {{range .}}{{if .Items}}<div class="grp{{if eq .Title "State"}} grp-state{{end}}">
183229 <h2 class="colhead">{{.Title}}</h2>
184230 <ul>{{range .Items}}<li><a{{if .Active}} aria-current="page"{{end}} href="{{.Href}}">{{.Label}}{{if .Count}} <i>{{.Count}}</i>{{end}}</a></li>{{end}}</ul>
185231 </div>{{end}}{{end}}
@@ -208,7 +254,7 @@
208254 hands the page back instead of writing (#235). */}}
209255{{/* reactions is one item's reaction bar (reactionBar in httpd). A
210256 signed-in viewer gets a button per reaction; anyone else the counts. */}}
211{{define "reactions"}}{{if .Items}}{{if .Signed}}<form method="post" action="{{.Action}}" class="reactions">{{if .Comment}}<input type="hidden" name="comment" value="{{.Comment}}">{{end}}
257{{define "reactions"}}{{if .Items}}{{if .Signed}}<form method="post" action="{{.Action}}" class="reactions" data-react-slot="{{.Comment}}">{{if .Comment}}<input type="hidden" name="comment" value="{{.Comment}}">{{end}}
212258{{range .Items}}<button type="submit" name="{{if .Me}}remove{{else}}add{{end}}" value="{{.Name}}" class="react{{if .Me}} mine{{end}}" aria-pressed="{{.Me}}" aria-label="{{.Label}}">{{.Emoji}}{{if .Count}} <span>{{.Count}}</span>{{end}}</button>
213259{{end}}</form>{{else}}<p class="reactions">{{range .Items}}<span class="react" aria-label="{{.Label}}">{{.Emoji}} {{.Count}}</span> {{end}}</p>{{end}}{{end}}{{end}}
214260
@@ -229,21 +275,25 @@
229275 line-number gutters and review threads inline. Base is the MR's
230276 endpoint and Viewer the signed-in account; the commit page passes
231277 neither and gets the same diff without review controls. */}}
232{{define "difffiles"}}{{$base := .Base}}{{$viewer := .Viewer}}{{$L := .L}}{{$split := false}}{{with $L}}{{$split = .Split}}{{end}}
233{{with $L}}{{if .UnifiedURL}}<p class="layoutpick">Layout: {{if .Split}}<a href="{{.UnifiedURL}}">unified</a> · <strong aria-current="true">split</strong>{{else}}<strong aria-current="true">unified</strong> · <a href="{{.SplitURL}}">split</a>{{end}}</p>{{end}}{{end}}
278{{define "difffiles"}}{{$base := .Base}}{{$viewer := .Viewer}}{{$L := .L}}{{$repoPath := or .RepoPath ""}}{{$headSHA := or .HeadSHA ""}}{{$split := false}}{{with $L}}{{$split = .Split}}{{end}}
279{{with $L}}{{if .UnifiedURL}}<div class="diffbar"><p class="layoutpick">Layout: {{if .Split}}<a href="{{.UnifiedURL}}">unified</a> · <strong aria-current="true">split</strong>{{else}}<strong aria-current="true">unified</strong> · <a href="{{.SplitURL}}">split</a>{{end}}</p></div>{{end}}{{end}}
280<div class="diffwrap{{if gt (len .Files) 1}} diffgrid{{end}}"{{if $repoPath}} data-repo="{{$repoPath}}"{{end}}{{if $headSHA}} data-head="{{$headSHA}}"{{end}}>
234281{{if gt (len .Files) 1}}<details class="difftoc" open>
235282 <summary>Changed files ({{len .Files}})</summary>
236 <ul class="difftoc-list">{{range $fi, $f := .Files}}<li><a href="#f{{$fi}}">{{.Path}}</a>{{if ne .Status "modified"}} <span class="chip">{{.Status}}</span>{{end}} <span class="fstat">{{if .Adds}}<span class="add">+{{.Adds}}</span>{{end}}{{if .Dels}} <span class="del">−{{.Dels}}</span>{{end}}</span></li>{{end}}</ul>
283 {{if gt (len .Files) 5}}<input type="search" class="reffilter" placeholder="Filter changed files…" aria-label="Filter changed files" data-filter-links="difftoc">{{end}}
284 <ul class="difftoc-list">{{range $fi, $f := .Files}}<li data-toc-path="{{.Path}}"><a href="#f{{$fi}}">{{.Path}}</a>{{if ne .Status "modified"}} <span class="chip">{{.Status}}</span>{{end}}{{if .Threads}} <span class="chip chip-neutral" title="{{.Threads}} thread{{if ne .Threads 1}}s{{end}}">💬 {{.Threads}}</span>{{end}} <span class="fstat">{{if .Adds}}<span class="add">+{{.Adds}}</span>{{end}}{{if .Dels}} <span class="del">−{{.Dels}}</span>{{end}}</span></li>{{end}}</ul>
237285</details>{{end}}
238{{range $fi, $f := .Files}}<details class="difffold" id="f{{$fi}}"{{if .Open}} open{{end}}>
286<div class="difflist">
287{{range $fi, $f := .Files}}<details class="difffold" id="f{{$fi}}" data-file-path="{{.Path}}"{{if .Open}} open{{end}}>
239288 <summary>
240289 <span class="fpath">{{if eq .Status "renamed"}}<span class="was">{{.OldPath}} →</span> {{end}}{{.Path}}</span>
241290 {{if ne .Status "modified"}}<span class="chip">{{.Status}}</span>{{end}}
242 <span class="fstat">{{if .Adds}}<span class="add">+{{.Adds}}</span>{{end}}{{if .Dels}} <span class="del">−{{.Dels}}</span>{{end}}</span>
291 {{if .Threads}}<span class="chip chip-neutral">{{.Threads}} thread{{if ne .Threads 1}}s{{end}}</span>{{end}}
292 <span class="fstat">{{if .Adds}}<span class="add">+{{.Adds}}</span>{{end}}{{if .Dels}} <span class="del">−{{.Dels}}</span>{{end}}{{if and $repoPath $headSHA (ne .Status "deleted")}} · <a class="diffviewlink" href="/{{$repoPath}}/blob/{{$headSHA}}/{{.Path}}">view</a>{{end}}</span>
243293 </summary>
244294 {{if .Binary}}<p class="none">Binary file not shown.</p>
245295 {{else if $split}}<div class="tablewrap"><table class="difftable split"><colgroup><col class="cln"><col><col class="cln"><col></colgroup>
246 {{range .Rows}}{{if eq .Kind "hunk"}}<tr class="hunk"><td class="ln"></td><td class="src" colspan="3">{{.Text}}</td></tr>
296 {{range .Rows}}{{if eq .Kind "hunk"}}<tr class="hunk" data-hunk="{{.Text}}" data-file="{{$f.Path}}"><td class="ln"></td><td class="src" colspan="3">{{.Text}}</td></tr>
247297 {{else if eq .Kind "meta"}}<tr class="dmeta"><td class="ln"></td><td class="src" colspan="3">{{.Text}}</td></tr>
248298 {{else}}{{$r := .}}<tr class="pair">
249299 {{with .Old}}{{if eq .Class "del"}}<td class="ln del" id="f{{$fi}}-o{{.OldLine}}">{{template "cmtln" dict "N" .OldLine "Path" .Path "Side" "old" "Base" $base "Viewer" $viewer "Carry" $L.Carry}}</td><td class="src del chroma">{{if .Code}}{{.Code}}{{else}}{{.Content}}{{end}}{{with $r.OldNote}}<span class="nonl">{{.}}</span>{{end}}</td>{{else}}<td class="ln ctx old">{{.OldLine}}</td><td class="src ctx old chroma">{{if .Code}}{{.Code}}{{else}}{{.Content}}{{end}}{{with $r.OldNote}}<span class="nonl">{{.}}</span>{{end}}</td>{{end}}{{else}}<td class="ln none" aria-hidden="true"></td><td class="src none" aria-hidden="true"></td>{{end}}
@@ -263,7 +313,7 @@
263313 {{end}}{{end}}{{end}}
264314 </table></div>
265315 {{else}}<div class="tablewrap"><table class="difftable">
266 {{range .Lines}}{{if eq .Class "hunk"}}<tr class="hunk"><td class="ln" colspan="2"></td><td class="src">{{.Text}}</td></tr>
316 {{range .Lines}}{{if eq .Class "hunk"}}<tr class="hunk" data-hunk="{{.Text}}" data-file="{{$f.Path}}"><td class="ln" colspan="2"></td><td class="src">{{.Text}}</td></tr>
267317 {{else if eq .Class "meta"}}<tr class="dmeta"><td class="ln" colspan="2"></td><td class="src">{{.Text}}</td></tr>
268318 {{else}}<tr class="{{.Class}}" id="f{{$fi}}-{{if eq .Class "del"}}o{{.OldLine}}{{else}}n{{.NewLine}}{{end}}"><td class="ln">{{if .OldLine}}{{if eq .Class "del"}}{{template "cmtln" dict "N" .OldLine "Path" .Path "Side" "old" "Base" $base "Viewer" $viewer "Carry" $L.Carry}}{{else}}{{.OldLine}}{{end}}{{end}}</td><td class="ln">{{if .NewLine}}{{template "cmtln" dict "N" .NewLine "Path" .Path "Side" "new" "Base" $base "Viewer" $viewer "Carry" $L.Carry}}{{end}}</td><td class="src chroma">{{if .Code}}{{.Code}}{{else}}{{.Content}}{{end}}</td></tr>
269319 {{if .Compose}}<tr class="threadrow"><td colspan="3"><form id="compose" method="post" action="{{$base}}/diff-comment" class="thread composing">
@@ -280,7 +330,7 @@
280330 {{end}}{{end}}
281331 </table></div>{{end}}
282332</details>
283{{end}}{{end}}
333{{end}}</div></div>{{end}}
284334
285335{{/* cmtln turns a line number into the link that opens the comment form
286336 on that line. No JavaScript: the anchor travels in the query. */}}
internal/web/templates/log.html +1 −1 · view
@@ -19,7 +19,7 @@
1919 <p class="meta">{{template "authorname" dict "Name" .AuthorName "User" .AuthorUser "Email" .AuthorEmail}} · {{when .Date}}</p>
2020 </div>
2121 <div class="commitside">
22 {{with .Check}}<a class="badge badge-{{.}}" href="/{{$.Repo.OwnerName}}/{{$.Repo.Name}}/commit/{{$c.SHA}}" title="checks: {{.}}">{{.}}</a>{{end}}
22 {{with .Check}}<a class="badge check-{{.}}" href="/{{$.Repo.OwnerName}}/{{$.Repo.Name}}/commit/{{$c.SHA}}" title="checks: {{.}}">{{.}}</a>{{end}}
2323 {{template "sigbadge" .Sig}}
2424 <code><a href="/{{$.Repo.OwnerName}}/{{$.Repo.Name}}/commit/{{.SHA}}">{{.ShortSHA}}</a></code>
2525 </div>
internal/web/templates/milestones.html +1 −1 · view
@@ -28,7 +28,7 @@
2828<ul class="milestonelist">
2929{{range .Milestones}}<li>
3030 <div class="msmain">
31 <p class="title">{{.Title}} <span class="chip {{if eq .State "open"}}chip-open{{else}}chip-done{{end}}">{{.State}}</span>{{if .OrgID}} <span class="chip chip-neutral">org</span>{{end}}</p>
31 <p class="title"><a href="/{{$.Repo.OwnerName}}/{{$.Repo.Name}}/issues?milestone={{urlquery .Title}}">{{.Title}}</a> <span class="chip {{if eq .State "open"}}chip-open{{else}}chip-done{{end}}">{{.State}}</span>{{if .OrgID}} <span class="chip chip-neutral">org</span>{{end}}</p>
3232 {{if .Description}}<p class="desc">{{.Description}}</p>{{end}}
3333 <p class="meta">{{if .DueDate}}due {{.DueDate}} · {{end}}{{.ClosedItems}} closed, {{.OpenItems}} open · {{.Percent}}%</p>
3434 <div class="progress"><div class="bar" style="width: {{.Percent}}%"></div></div>
internal/web/templates/mr.html +56 −23 · view
@@ -15,14 +15,47 @@
1515
1616{{if .Notice}}<p class="error" role="alert">{{.Notice}}</p>{{end}}
1717
18<div class="withaside">
19<div class="mainside">
20
18{{$pc := field . "PendingComments"}}
19<div class="mrbar">
2120<nav class="subtabs" aria-label="Merge request">
2221 <a {{if eq .View "conversation"}}aria-current="page" {{end}}href="{{$base}}">Conversation{{if .Comments}} <i>{{len .Comments}}</i>{{end}}</a>
2322 <a {{if eq .View "commits"}}aria-current="page" {{end}}href="{{$base}}?view=commits">Commits{{if .Commits}} <i>{{len .Commits}}</i>{{end}}</a>
2423 <a {{if eq .View "diff"}}aria-current="page" {{end}}href="{{$base}}?view=diff">Files changed{{if .Stat.Files}} <i>{{.Stat.Files}}</i>{{end}}</a>
2524</nav>
25{{if and (eq .View "diff") .CanWrite (or (eq .MR.State "open") (eq .MR.State "source_gone"))}}
26<details class="popover finish-review">
27 <summary class="button">Review changes{{if $pc}} ({{$pc}}){{end}} ▾</summary>
28 <div class="popmenu review-popmenu">
29 {{if $pc}}<p class="review-pending">{{$pc}} pending diff comment{{if ne $pc 1}}s{{end}}</p>{{end}}
30 <form method="post" action="{{$base}}/review" class="actions">
31 <textarea name="body" aria-label="Review note" rows="3" placeholder="Summary review note (optional)…"></textarea>
32 <button type="submit" name="verdict" value="approve">Approve</button>
33 <button type="submit" name="verdict" value="request-changes" class="btn">Request changes</button>
34 {{if $pc}}<button type="submit" name="verdict" value="comment" class="btn">Submit comments</button>
35 <button type="submit" name="verdict" value="discard" class="danger">Discard pending</button>{{end}}
36 </form>
37 </div>
38</details>
39{{end}}
40</div>
41
42{{if eq .View "diff"}}
43{{$sel := str . "SelectedCommit"}}
44{{if gt (len .Commits) 1}}
45<nav class="statebar commit-picker" aria-label="Filter by commit">
46 <a {{if eq $sel ""}}aria-current="page" {{end}}href="{{$base}}?view=diff{{if .Layout.Carry}}&amp;layout={{.Layout.Carry}}{{end}}">All commits ({{len .Commits}})</a>
47 {{range .Commits}}<a {{if eq $sel .SHA}}aria-current="page" {{end}}href="{{$base}}?view=diff&amp;commit={{.SHA}}{{if $.Layout.Carry}}&amp;layout={{$.Layout.Carry}}{{end}}" title="{{.Subject}}"><code>{{.ShortSHA}}</code></a>{{end}}
48</nav>
49{{end}}
50{{if .DiffFiles}}<p class="diffstat">{{.Stat.Files}} file{{if ne .Stat.Files 1}}s{{end}} changed, <span class="add">+{{.Stat.Adds}}</span> <span class="del">−{{.Stat.Dels}}</span>{{if .DiffTruncated}} · shown up to 4 MiB; the counts and the last file are partial{{end}}</p>
51{{if .DiffTruncated}}<p class="error" role="alert">This diff is larger than 4 MiB and is cut off below. Fetch the branch to see all of it.</p>{{end}}
52{{template "difffiles" dict "Files" .DiffFiles "Base" $base "Viewer" .Viewer "L" .Layout "RepoPath" .Repo.Path "HeadSHA" .MR.HeadSHA}}
53{{else if .HeadPruned}}<p class="empty-note">The head of this merge request is no longer in the repository; its diff is not available.</p>
54{{else}}<p class="empty-note">No changes between the source and target.{{if .HeadMerged}} The source branch was already merged or fast-forwarded into <code>{{.MR.TargetRef}}</code>.{{end}}</p>{{end}}
55
56{{else}}
57<div class="withaside">
58<div class="mainside">
2659
2760{{if eq .View "conversation"}}
2861<div class="prose">
@@ -34,15 +67,15 @@
3467<p><textarea name="body" aria-label="Description" rows="8">{{.Draft.Or "edit" "body" .MR.Body}}</textarea></p>
3568<p><button type="submit" class="btn">Save</button> {{template "previewbtn"}}</p>
3669</form></details>{{end}}
37{{if .BodyHTML}}<article class="comment">
38 <header class="commenthead"><strong><a href="/{{.MR.Author}}">{{.MR.Author}}</a></strong></header>
70{{if .BodyHTML}}<article class="comment" id="mr-body">
71 <header class="commenthead"><strong><a href="/{{.MR.Author}}">{{.MR.Author}}</a></strong>{{if .MR.CreatedAt}} <span class="when">{{when .MR.CreatedAt}}</span>{{end}}{{if $.Viewer}}<span class="grow"></span><button type="button" class="linklike quote-btn" data-quote-from="mr-body">Quote</button>{{end}}</header>
3972 <div class="rendered">{{.BodyHTML}}</div>
4073 {{template "reactions" index .Reactions 0}}
4174</article>{{else}}{{template "reactions" index .Reactions 0}}{{end}}
4275{{range .Comments}}
4376{{if eq .Kind "system"}}<div class="syscomment">{{.BodyHTML}} <span class="when">{{when .CreatedAt}}</span></div>
44{{else}}<article class="comment">
45 <header class="commenthead"><strong><a href="/{{.Author}}">{{.Author}}</a></strong> <span class="when">{{when .CreatedAt}}</span></header>
77{{else}}<article class="comment" id="comment-{{.ID}}">
78 <header class="commenthead"><strong><a href="/{{.Author}}">{{.Author}}</a></strong> <a class="when" href="#comment-{{.ID}}">{{when .CreatedAt}}</a>{{if $.Viewer}}<span class="grow"></span><button type="button" class="linklike quote-btn" data-quote-from="comment-{{.ID}}">Quote</button>{{end}}</header>
4679 <div class="rendered">{{.BodyHTML}}</div>
4780 {{template "reactions" index $.Reactions .ID}}
4881</article>{{end}}
@@ -52,8 +85,8 @@
5285{{if .Viewer}}
5386{{if .Draft.Is "comment"}}{{template "previewblock" .Draft.HTML}}{{end}}
5487<form method="post" action="{{$base}}/comment" class="commentform">
55<p><textarea name="body" aria-label="Comment" rows="4" placeholder="Comment as {{.Viewer}}">{{.Draft.Or "comment" "body" ""}}</textarea></p>
56<p><button type="submit">Comment</button> {{template "previewbtn"}}</p>
88<p><textarea id="main-comment-box" name="body" aria-label="Comment" rows="4" placeholder="Comment as {{.Viewer}}">{{.Draft.Or "comment" "body" ""}}</textarea></p>
89<p class="btngroup"><button type="submit">Comment</button> {{template "previewbtn"}} <label class="format-inline"><span class="vh">Comment markup</span><select name="format" aria-label="Comment markup">{{$cfmt := .Draft.Or "comment" "format" "md"}}<option value="md"{{if ne $cfmt "org"}} selected{{end}}>Markdown</option><option value="org"{{if eq $cfmt "org"}} selected{{end}}>Org</option></select></label></p>
5790</form>
5891{{end}}
5992</div>
@@ -63,7 +96,7 @@
6396<ul class="loglist">
6497{{range .Commits}}<li>
6598 <div class="commitmain">
66 <p class="subject"><a href="/{{$.Repo.OwnerName}}/{{$.Repo.Name}}/commit/{{.SHA}}">{{.Subject}}</a></p>
99 <p class="subject"><a href="{{$base}}?view=diff&amp;commit={{.SHA}}">{{.Subject}}</a></p>
67100 <p class="meta">{{template "authorname" dict "Name" .AuthorName "User" .AuthorUser "Email" ""}} · {{when .Date}}</p>
68101 </div>
69102 <div class="commitside">
@@ -74,13 +107,6 @@
74107{{else}}<li class="empty">no commits on this merge request</li>
75108{{end}}
76109</ul>
77
78{{else}}
79{{if .DiffFiles}}<p class="diffstat">{{.Stat.Files}} file{{if ne .Stat.Files 1}}s{{end}} changed, <span class="add">+{{.Stat.Adds}}</span> <span class="del">−{{.Stat.Dels}}</span>{{if .DiffTruncated}} · shown up to 4 MiB; the counts and the last file are partial{{end}}</p>
80{{if .DiffTruncated}}<p class="error" role="alert">This diff is larger than 4 MiB and is cut off below. Fetch the branch to see all of it.</p>{{end}}
81{{template "difffiles" dict "Files" .DiffFiles "Base" $base "Viewer" .Viewer "L" .Layout}}
82{{else if .HeadPruned}}<p class="empty-note">The head of this merge request is no longer in the repository; its diff is not available.</p>
83{{else}}<p class="empty-note">No changes between the source and target.{{if .HeadMerged}} The source branch was already merged or fast-forwarded into <code>{{.MR.TargetRef}}</code>.{{end}}</p>{{end}}
84110{{end}}
85111
86112</div>
@@ -89,7 +115,7 @@
89115 {{if and .CanWrite (or (eq .MR.State "open") (eq .MR.State "source_gone"))}}
90116 <div class="grp">
91117 <h2>Review</h2>
92 {{$pc := field . "PendingComments"}}{{if $pc}}<p class="row review-pending">{{$pc}} pending diff comment{{if ne $pc 1}}s{{end}}</p>{{end}}
118 {{if $pc}}<p class="row review-pending">{{$pc}} pending diff comment{{if ne $pc 1}}s{{end}}</p>{{end}}
93119 <form method="post" action="{{$base}}/review" class="actions">
94120 <textarea name="body" aria-label="Review note" rows="2" placeholder="Optional review note"></textarea>
95121 <button type="submit" name="verdict" value="approve" class="btn">Approve</button>
@@ -107,18 +133,24 @@
107133 <input type="hidden" name="cancel" value="on">
108134 <button type="submit" class="btn">Cancel queued merge</button>
109135 </form>{{end}}
136 {{$reqSigned := .Repo.Settings.RequireSignedCommits}}{{$hasStacked := false}}{{with field . "Stacked"}}{{if .}}{{$hasStacked = true}}{{end}}{{end}}
110137 <form method="post" action="{{$base}}/merge" class="actions">
111138 <label class="none" for="strategy">Strategy</label>
112139 <select id="strategy" name="strategy">
113140 <option value="auto">Automatic</option>
114141 <option value="ff">Fast-forward</option>
115 <option value="merge">Merge commit</option>
116 <option value="squash">Squash</option>
117 <option value="rebase">Rebase</option>
142 <option value="merge"{{if $reqSigned}} disabled{{end}}>Merge commit{{if $reqSigned}} (disabled: signed commits){{end}}</option>
143 <option value="squash"{{if or $reqSigned $hasStacked}} disabled{{end}}>Squash{{if $reqSigned}} (disabled: signed commits){{else if $hasStacked}} (disabled: stacked MRs){{end}}</option>
144 <option value="rebase"{{if or $reqSigned $hasStacked}} disabled{{end}}>Rebase{{if $reqSigned}} (disabled: signed commits){{else if $hasStacked}} (disabled: stacked MRs){{end}}</option>
118145 </select>
119146 <button type="submit">Merge</button>
120147 <button type="submit" name="when_ready" value="on" class="btn">Merge when ready</button>
121148 </form>
149 {{with .Gates}}{{if and (not .FastForward) (not $reqSigned)}}
150 <form method="post" action="{{$base}}/rebase" class="actions">
151 <button type="submit" class="btn">Rebase onto {{$.MR.TargetRef}}</button>
152 </form>
153 {{end}}{{end}}
122154 </div>
123155 {{end}}
124156 {{if and .CanEdit (or (eq .MR.State "open") (eq .MR.State "source_gone"))}}
@@ -156,7 +188,7 @@
156188 </div>
157189 <div class="grp">
158190 <h2>Reviews</h2>
159 {{range .Reviews}}<p class="row"><span class="dot {{if eq .Verdict "approve"}}ok{{else}}pend{{end}}"></span><a href="/{{.Reviewer}}">{{.Reviewer}}</a> {{.Verdict}}{{if .Stale}} <span class="chip chip-stale">stale</span>{{end}}{{if not .Counts}} <span class="chip chip-neutral" title="This reviewer has no write access, so the merge gates do not count it">advisory</span>{{end}}<span class="sub">{{when .CreatedAt}}</span></p>
191 {{range .Reviews}}<p class="row"><span class="dot {{if eq .Verdict "approve"}}ok{{else if eq .Verdict "request_changes"}}bad{{else}}pend{{end}}"></span><a href="/{{.Reviewer}}">{{.Reviewer}}</a> {{if eq .Verdict "approve"}}approved{{else if eq .Verdict "request_changes"}}requested changes{{else if eq .Verdict "comment"}}commented{{else}}{{.Verdict}}{{end}}{{if .Stale}} <span class="chip chip-stale">stale</span>{{end}}{{if not .Counts}} <span class="chip chip-neutral" title="This reviewer has no write access, so the merge gates do not count it">advisory</span>{{end}}<span class="sub">{{when .CreatedAt}}</span></p>
160192 {{else}}<p class="none">none yet</p>{{end}}
161193 </div>
162194 {{if .Revisions}}<div class="grp">
@@ -198,7 +230,7 @@
198230 </div>
199231 {{if .MR.Milestone}}<div class="grp">
200232 <h2>Milestone</h2>
201 <p class="row"><a href="/{{.Repo.OwnerName}}/{{.Repo.Name}}/milestones">{{.MR.Milestone}}</a></p>
233 <p class="row"><a href="/{{.Repo.OwnerName}}/{{.Repo.Name}}/mrs?milestone={{urlquery .MR.Milestone}}">{{.MR.Milestone}}</a></p>
202234 </div>{{end}}
203235 <div class="grp">
204236 <div class="grp-head">
@@ -218,4 +250,5 @@
218250</aside>
219251</div>
220252{{end}}
253{{end}}
221254
internal/web/templates/mrrangediff.html +2 · view
@@ -8,6 +8,8 @@
88</div>
99<p class="meta">{{.MR.Title}}</p>
1010{{if .Error}}<p class="error" role="alert">{{.Error}}</p>
11{{else if field . "Lines"}}<pre class="code buildlog rangediff" tabindex="0">{{range .Lines}}<span class="{{.Class}}">{{.Text}}</span>
12{{end}}</pre>
1113{{else if .Diff}}<pre class="code buildlog" tabindex="0">{{.Diff}}</pre>
1214{{else}}<p class="empty-note">Nothing to compare: this merge request has one revision.</p>{{end}}
1315{{end}}
internal/web/templates/mrs.html +7 −2 · view
@@ -12,6 +12,11 @@
1212 <input type="hidden" name="state" value="{{.State}}">
1313 </form>
1414 {{range .Filters}}<p class="meta">{{.Key}}: {{if eq .Key "label"}}<span class="chip label" style="{{index $.LabelColors .Value}}">{{.Value}}</span>{{else}}<b>{{.Value}}</b>{{end}} <a href="{{.Clear}}">clear</a></p>{{end}}
15 {{with field . "People"}}{{if .}}
16 <details class="popover"><summary class="popbtn">Author ▾</summary><div class="popmenu">
17 <div class="picker-list">{{range .}}<a class="picker-btn" href="?state={{$.State}}&amp;author={{urlquery .}}">{{.}}</a>{{end}}</div>
18 </div></details>
19 {{end}}{{end}}
1520 <span class="spacer"></span>
1621 {{if .CanOpenMR}}<a class="button" href="/{{.Repo.OwnerName}}/{{.Repo.Name}}/mrs/new">New merge request</a>
1722 {{else if .Viewer}}<a class="button btn" href="/{{.Repo.OwnerName}}/{{.Repo.Name}}/fork">Fork this repository to propose a change</a>
@@ -23,10 +28,10 @@
2328 <div class="issuemain">
2429 <p class="title"><a href="/{{$.Repo.OwnerName}}/{{$.Repo.Name}}/mrs/{{.Number}}">{{.Title}}</a>
2530 {{range .Labels}}<a class="chip label" style="{{index $.LabelColors .}}" href="?label={{.}}">{{.}}</a> {{end}}</p>
26 <p class="meta">!{{.Number}} by <a href="/{{.Author}}">{{.Author}}</a> · {{if .SourcePath}}{{.SourcePath}}:{{end}}{{.SourceRef}} → {{.TargetRef}}</p>
31 <p class="meta">!{{.Number}} by <a href="/{{.Author}}">{{.Author}}</a> · {{if .SourcePath}}{{.SourcePath}}:{{end}}{{.SourceRef}} → {{.TargetRef}}{{if .Milestone}} · in <a href="/{{$.Repo.OwnerName}}/{{$.Repo.Name}}/mrs?milestone={{urlquery .Milestone}}">{{.Milestone}}</a>{{end}}{{if .UpdatedAt}} · {{when .UpdatedAt}}{{end}}</p>
2732 </div>
2833 <div class="issueside">
29 {{if .Draft}}<span class="chip chip-neutral">draft</span> {{end}}{{if eq $.State "all"}}<span class="chip chip-{{.State}}">{{.State}}</span> {{end}}{{with .Check}}<a class="chip check-{{.}}" href="/{{$.Repo.OwnerName}}/{{$.Repo.Name}}/mrs/{{$n}}?view=diff" title="checks: {{.}}">{{.}}</a> {{end}}{{if .Comments}}<span class="chip chip-neutral" title="{{.Comments}} comment{{if ne .Comments 1}}s{{end}}">{{.Comments}} <span class="vh">comments</span></span>{{end}}
34 {{if .Draft}}<span class="chip chip-neutral">draft</span> {{end}}{{if eq $.State "all"}}<span class="chip chip-{{.State}}">{{.State}}</span> {{end}}{{if eq .Review "approved"}}<span class="chip chip-open">approved</span> {{else if eq .Review "changes_requested"}}<span class="chip chip-closed">changes requested</span> {{end}}{{with .Check}}<a class="chip check-{{.}}" href="/{{$.Repo.OwnerName}}/{{$.Repo.Name}}/mrs/{{$n}}?view=diff" title="checks: {{.}}">{{.}}</a> {{end}}{{if .Comments}}<span class="chip chip-neutral" title="{{.Comments}} comment{{if ne .Comments 1}}s{{end}}">{{.Comments}} <span class="vh">comments</span></span>{{end}}
3035 </div>
3136</li>
3237{{else}}{{if .Query}}<li class="empty">no {{if ne .State "all"}}{{.State}} {{end}}merge requests matching “{{.Query}}”</li>
internal/web/templates/new.html +7 −7 · view
@@ -4,7 +4,7 @@
44<h1>New</h1>
55{{if .Error}}<p class="error" role="alert">{{.Error}}</p>{{end}}
66
7<nav class="tabs newtabs" aria-label="Create" data-panel-tabs="new-panels">
7<nav class="tabs newtabs" aria-label="Create" data-panel-tabs="new-panels" data-active-panel="{{index .Submitted "panel"}}">
88 <a href="#create" aria-current="page" data-panel="create">Repository</a>
99 <a href="#import" data-panel="import">Import</a>
1010 <a href="#org" data-panel="org">Organization</a>
@@ -20,14 +20,14 @@
2020 <div class="ownerpick">
2121 <label for="new-owner">Owner</label>
2222 <select id="new-owner" name="owner">
23 <option value="{{.Viewer}}">{{.Viewer}}</option>
24 {{range .Orgs}}<option value="{{.}}">{{.}}</option>{{end}}
23 {{$co := index .Submitted "owner"}}<option value="{{.Viewer}}">{{.Viewer}}</option>
24 {{range .Orgs}}<option value="{{.}}"{{if eq . $co}} selected{{end}}>{{.}}</option>{{end}}
2525 </select>
2626 </div>
2727 <span class="slash" aria-hidden="true">/</span>
2828 <div class="namepick">
2929 <label for="new-name">Repository name</label>
30 <input id="new-name" name="name" required maxlength="63" pattern="[a-z0-9][a-z0-9._\-]{0,62}" aria-describedby="namehint" autocomplete="off" spellcheck="false" placeholder="my-project">
30 <input id="new-name" name="name" value="{{if ne (index .Submitted "panel") "import"}}{{if ne (index .Submitted "panel") "org"}}{{index .Submitted "name"}}{{end}}{{end}}" required maxlength="63" pattern="[a-z0-9][a-z0-9._\-]{0,62}" aria-describedby="namehint" autocomplete="off" spellcheck="false" placeholder="my-project">
3131 </div>
3232 </div>
3333 <span class="hint" id="namehint">Lowercase letters, digits, dot, dash and underscore; must start with a letter or digit; up to 63 characters.</span>
@@ -35,8 +35,8 @@
3535 <fieldset class="segmented">
3636 <legend>Visibility</legend>
3737 <div class="options">
38 <label><input type="radio" name="visibility" value="public" checked><span>Public</span></label>
39 <label><input type="radio" name="visibility" value="private"><span>Private</span></label>
38 <label><input type="radio" name="visibility" value="public"{{if ne (index .Submitted "visibility") "private"}} checked{{end}}><span>Public</span></label>
39 <label><input type="radio" name="visibility" value="private"{{if eq (index .Submitted "visibility") "private"}} checked{{end}}><span>Private</span></label>
4040 </div>
4141 </fieldset>
4242 <p><button type="submit">Create repository</button></p>
@@ -90,7 +90,7 @@
9090 <input type="hidden" name="field" value="org-create">
9191 <div class="field">
9292 <label for="org-name">Organization name</label>
93 <input id="org-name" name="name" required maxlength="63" pattern="[a-z0-9][a-z0-9._\-]{0,62}" aria-describedby="orghint" autocomplete="off" spellcheck="false" placeholder="acme-labs">
93 <input id="org-name" name="name" value="{{if eq (index .Submitted "panel") "org"}}{{index .Submitted "name"}}{{end}}" required maxlength="63" pattern="[a-z0-9][a-z0-9._\-]{0,62}" aria-describedby="orghint" autocomplete="off" spellcheck="false" placeholder="acme-labs">
9494 <span class="hint" id="orghint">Same naming rules as a repository; becomes a top-level path.</span>
9595 </div>
9696 <p><button type="submit">Create organization</button></p>
internal/web/templates/owner.html +2 −2 · view
@@ -71,7 +71,7 @@
7171 <span class="count">{{.Bookmarks}}</span></p>
7272 {{if .Description}}<p class="desc">{{.Description}}</p>{{end}}
7373</li>
74{{else}}<li class="empty">nothing bookmarked yet. open a repository and press Bookmark</li>{{end}}
74{{else}}<li class="empty">Nothing bookmarked yet — open a repository and press Bookmark.</li>{{end}}
7575</ul>
7676{{end}}
7777
@@ -80,7 +80,7 @@
8080{{if .Self}}<div class="listhead">
8181 <p class="meta"><code>gitbay snippet create &lt;file&gt; &lt; file</code></p>
8282 <span class="spacer"></span>
83 <a class="button" href="/{{.Owner}}/-/snippets/new">new snippet</a>
83 <a class="button" href="/{{.Owner}}/-/snippets/new" title="Create a new snippet">New snippet</a>
8484</div>{{end}}
8585<section class="setcard">
8686{{if .SnippetRows}}<div class="tablewrap"><table class="keys">
internal/web/templates/queries.html +77 −14 · view
@@ -1,28 +1,55 @@
11{{define "width"}}wide{{end}}
22{{define "title"}}{{if .Query.Name}}{{.Query.Name}} · {{end}}queries · {{.Site}}{{end}}
3{{define "content"}}
4{{if .Query.Name}}
5<div id="query-root">
6<div class="pagehead">
7 <h1>{{.Query.Name}} <span class="count">{{.Count}}</span></h1>
8 <span class="grow"></span>
9 <div class="btngroup">
10 <button type="button" class="btn" data-refresh="self" data-refresh-target="query-root">Refresh</button>
11 <a class="button btn" href="/{{.Viewer}}/-/queries">Saved queries</a>
12 </div>
13</div>
14<p class="meta"><code>{{.Query.Query}}</code> · the same read as <code>gitbay query run {{.Query.Name}}</code></p>
3{{define "queryrows"}}
154<ul class="issuelist rows">
165{{range .Items}}<li>
176 <div class="issuemain">
187 <p class="title"><a href="/{{.Repo}}/{{if eq .Kind "mr"}}mrs{{else}}issues{{end}}/{{.Number}}">{{.Title}}</a></p>
198 <p class="meta"><span class="repo">{{.Ref}}</span> · <a href="/{{.Author}}">{{.Author}}</a>{{if .Milestone}} · in {{.Milestone}}{{end}} · {{when .CreatedAt}}</p>
209 </div>
21 <span class="chip {{if eq .State "open"}}chip-open{{else if eq .State "merged"}}chip-done{{else}}chip-closed{{end}}">{{if .Draft}}draft{{else}}{{.State}}{{end}}</span>
10 <span class="chip {{if .Draft}}chip-neutral{{else if eq .State "open"}}chip-open{{else if or (eq .State "merged") (and (eq .Kind "issue") (eq .State "closed"))}}chip-done{{else if eq .State "source_gone"}}chip-source_gone{{else}}chip-closed{{end}}">{{if .Draft}}draft{{else}}{{.State}}{{end}}</span>
2211</li>
2312{{else}}<li class="empty">nothing matches</li>{{end}}
2413</ul>
2514{{if .Next}}<p class="pager"><a href="{{.Next}}">older →</a></p>{{end}}
15{{end}}
16{{define "content"}}
17{{$base := printf "/%s/-/queries" .Viewer}}
18{{if .Notice}}<p class="error" role="alert">{{.Notice}}</p>{{end}}
19{{if .Query.Name}}
20<div id="query-root">
21<div class="pagehead">
22 <h1>{{.Query.Name}} <span class="count">{{.Count}}</span>{{if .Query.Pinned}} <span class="chip">pinned</span>{{end}}</h1>
23 <span class="grow"></span>
24 <div class="btngroup">
25 <button type="button" class="btn" data-refresh="self" data-refresh-target="query-root">Refresh</button>
26 <form method="post" action="{{$base}}" class="inline">
27 <input type="hidden" name="action" value="{{if .Query.Pinned}}unpin{{else}}pin{{end}}">
28 <input type="hidden" name="name" value="{{.Query.Name}}">
29 <button type="submit" class="btn">{{if .Query.Pinned}}Unpin from dashboard{{else}}Pin to dashboard{{end}}</button>
30 </form>
31 <details class="popover"><summary class="popbtn popbtn-danger">Remove</summary><div class="popmenu">
32 <form method="post" action="{{$base}}" class="popform popform-stack">
33 <input type="hidden" name="action" value="remove">
34 <input type="hidden" name="name" value="{{.Query.Name}}">
35 <button type="submit" class="danger">Remove {{.Query.Name}}</button>
36 </form>
37 </div></details>
38 <a class="button btn" href="{{$base}}">Saved queries</a>
39 </div>
40</div>
41<p class="meta"><code>{{.Query.Query}}</code> · the same read as <code>gitbay query run {{.Query.Name}}</code></p>
42<details class="editbox"><summary>Edit query</summary>
43<form method="post" action="{{$base}}" class="setform stack">
44 <input type="hidden" name="action" value="save">
45 <input type="hidden" name="name" value="{{.Query.Name}}">
46 <input type="hidden" name="force" value="on">
47 <label for="edit-q-text">Query</label>
48 <input type="text" id="edit-q-text" name="query" value="{{.Query.Query}}" required spellcheck="false">
49 <span class="btngroup"><button type="submit">Update query</button></span>
50</form>
51</details>
52{{template "queryrows" .}}
2653</div>
2754{{else}}
2855<div class="pagehead">
@@ -30,13 +57,49 @@
3057 <span class="grow"></span>
3158 {{if .Saved}}<input type="search" class="tablefilter" placeholder="Filter queries…" aria-label="Filter queries" data-filter-list="saved-queries">{{end}}
3259</div>
33<p class="meta">Saved with <code>gitbay query save &lt;name&gt; &lt;query&gt;</code>; <code>gitbay query pin &lt;name&gt;</code> puts one on the dashboard.</p>
60<section class="setcard">
61<form method="get" action="{{$base}}" class="searchform querybar">
62 <label class="vh" for="adhoc-q">Query across repositories</label>
63 <input type="search" id="adhoc-q" name="q" value="{{.AdHoc}}" placeholder="is:open assignee:@me · is:mr author:@me · repo:owner/* label:bug" spellcheck="false">
64 <button type="submit">Run query</button>
65</form>
66<p class="hint">Qualifiers: <code>is:open|closed|merged|draft</code>, <code>is:issue|mr</code>, <code>author:@me|user</code>, <code>assignee:@me|user</code>, <code>label:name</code>, <code>milestone:name</code>, <code>repo:owner/*</code>, <code>owner:name</code>.</p>
67<details class="editbox"{{if .AdHoc}} open{{end}}><summary>Save as named query</summary>
68<form method="post" action="{{$base}}" class="setform stack">
69 <input type="hidden" name="action" value="save">
70 <label for="save-q-name">Name</label>
71 <input type="text" id="save-q-name" name="name" required placeholder="e.g. mine or triage" pattern="[a-z0-9][a-z0-9._-]{0,63}" spellcheck="false">
72 <label for="save-q-text">Query</label>
73 <input type="text" id="save-q-text" name="query" value="{{.AdHoc}}" required placeholder="is:open assignee:@me" spellcheck="false">
74 <label class="check"><input type="checkbox" name="force" value="on"> Replace existing query with this name</label>
75 <span class="btngroup"><button type="submit">Save query</button></span>
76</form>
77</details>
78</section>
79{{if .AdHoc}}
80<h2>Results <span class="count">{{.Count}}</span></h2>
81{{template "queryrows" .}}
82{{end}}
3483<ul class="issuelist rows" id="saved-queries">
3584{{range .Saved}}<li>
3685 <div class="issuemain">
3786 <p class="title"><a href="/{{$.Viewer}}/-/queries/{{.Name}}">{{.Name}}</a>{{if .Pinned}} <span class="chip">pinned</span>{{end}}</p>
3887 <p class="meta"><code>{{.Query}}</code></p>
3988 </div>
89 <div class="issueside">
90 <form method="post" action="{{$base}}" class="inline">
91 <input type="hidden" name="action" value="{{if .Pinned}}unpin{{else}}pin{{end}}">
92 <input type="hidden" name="name" value="{{.Name}}">
93 <button type="submit" class="btn">{{if .Pinned}}Unpin{{else}}Pin{{end}}</button>
94 </form>
95 <details class="popover"><summary class="popbtn popbtn-danger">Remove</summary><div class="popmenu">
96 <form method="post" action="{{$base}}" class="popform popform-stack">
97 <input type="hidden" name="action" value="remove">
98 <input type="hidden" name="name" value="{{.Name}}">
99 <button type="submit" class="danger">Remove {{.Name}}</button>
100 </form>
101 </div></details>
102 </div>
40103</li>
41104{{else}}<li class="empty">no saved queries</li>{{end}}
42105</ul>
internal/web/templates/registered.html +14 −1 · view
@@ -2,8 +2,21 @@
22{{define "title"}}welcome · {{.Site}}{{end}}
33{{define "content"}}
44<div class="landing">
5<h1>Welcome, {{.Username}}</h1>
5<h1>welcome, {{.Username}}</h1>
6{{if str . "Error"}}<p class="error" role="alert">{{str . "Error"}}</p>{{end}}
67<pre class="quickstart" tabindex="0">{{.Message}}</pre>
8{{if eq (str . "Mode") "open"}}
9<section class="setcard">
10<h2>Verify your email now</h2>
11<p class="meta">Paste the verification code from your inbox to activate your account and sign straight in.</p>
12<form method="post" action="/register/verify" class="setform">
13 <input type="hidden" name="username" value="{{.Username}}">
14 <label for="reg-code">Verification code</label>
15 <input type="text" id="reg-code" name="code" required autocomplete="one-time-code" autocapitalize="none" spellcheck="false" placeholder="from the mail">
16 <button type="submit">Verify &amp; sign in</button>
17</form>
18</section>
19{{end}}
720<section class="setcard">
821<h2>On the web</h2>
922<ol>
internal/web/templates/releases.html +1 −1 · view
@@ -19,7 +19,7 @@
1919 </p>
2020 <p><input type="text" name="title" aria-label="Title" placeholder="title (defaults to the tag)" value="{{.Draft.Or "release" "title" ""}}"></p>
2121 <p><textarea name="notes" aria-label="Notes" rows="6" placeholder="what changed">{{.Draft.Or "release" "notes" ""}}</textarea></p>
22 <p class="btngroup"><button type="submit">Create release</button> {{template "previewbtn"}} <button type="submit" name="summarize" value="1" class="btn">Summarize changes</button></p>
22 <p class="btngroup"><button type="submit">Create release</button> {{template "previewbtn"}} <button type="submit" name="summarize" value="1" class="btn">Summarize changes</button> <label class="format-inline"><span class="vh">Notes markup</span><select name="format" aria-label="Notes markup">{{$rfmt := .Draft.Or "release" "format" "md"}}<option value="md"{{if ne $rfmt "org"}} selected{{end}}>Markdown</option><option value="org"{{if eq $rfmt "org"}} selected{{end}}>Org</option></select></label></p>
2323</form>
2424</details>
2525{{else if .CanWrite}}<p class="meta">Push a tag to create a release from it.</p>{{end}}
internal/web/templates/settings.html +136 −5 · view
@@ -22,6 +22,10 @@
2222 <li><a href="#tags">Protected tags</a></li>
2323 <li><a href="#deps">Dependencies</a></li>
2424 <li><a href="#runners">Runners</a></li>
25 <li><a href="#buildsecrets">Build secrets</a></li>
26 <li><a href="#deploykeys">Deploy keys</a></li>
27 <li><a href="#mirrors">Mirrors</a></li>
28 <li><a href="#domains">Pages domains</a></li>
2529 <li><a href="#lifecycle">Lifecycle</a></li>
2630 </ul></div>
2731</details>
@@ -56,7 +60,7 @@
5660</section>
5761
5862<section id="access" class="setcard"><h2>Access</h2>
59<form method="post" action="{{$base}}" class="setform">
63<form method="post" action="{{$base}}" class="setform" data-autosave="1">
6064 <input type="hidden" name="field" value="visibility">
6165 <div><span class="fieldname">Visibility</span></div>
6266 <div class="check">
@@ -179,7 +183,7 @@
179183</section>
180184
181185{{if or .ScanAvailable .Security.Enabled}}<section id="security" class="setcard"><h2>Code scanning</h2>
182<form method="post" action="{{$base}}" class="setform">
186<form method="post" action="{{$base}}" class="setform" data-autosave="1">
183187 <input type="hidden" name="field" value="security">
184188 <div><label for="security-enabled">Scheduled scan</label><p class="hint">Runs the instance's code scanner over <code>{{.Repo.DefaultBranch}}</code> on its schedule, on a runner attached to this repository, and keeps an issue of what it finds.</p></div>
185189 <div class="check"><input type="checkbox" id="security-enabled" name="security" value="on"{{if .Security.Enabled}} checked{{end}}></div>
@@ -197,7 +201,7 @@
197201{{if .Security.Findings}}<div class="tablewrap"><table class="keys">
198202<tr class="cols"><th scope="col">location</th><th scope="col">rule</th><th scope="col">level</th><th scope="col"><span class="vh">dismiss</span></th></tr>
199203{{range .Security.Findings}}<tr>
200 <td class="mono">{{.Path}}:{{.Line}}</td>
204 <td class="mono"><a href="/{{$.Repo.OwnerName}}/{{$.Repo.Name}}/blob/{{$.Repo.DefaultBranch}}/{{.Path}}#L{{.Line}}">{{.Path}}:{{.Line}}</a></td>
201205 <td class="mono">{{.Rule}}</td>
202206 <td>{{.Level}}</td>
203207 <td><form method="post" action="{{$base}}" class="inline">
@@ -214,7 +218,7 @@
214218<div class="tablewrap"><table class="keys" id="sec-dismissed">
215219<thead><tr class="cols"><th scope="col">location</th><th scope="col">rule</th><th scope="col">reason</th><th scope="col"><span class="vh">reopen</span></th></tr></thead>
216220<tbody>{{range .Security.Dismissed}}<tr>
217 <td class="mono">{{.Path}}:{{.Line}}</td>
221 <td class="mono"><a href="/{{$.Repo.OwnerName}}/{{$.Repo.Name}}/blob/{{$.Repo.DefaultBranch}}/{{.Path}}#L{{.Line}}">{{.Path}}:{{.Line}}</a></td>
218222 <td class="mono">{{.Rule}}</td>
219223 <td>{{.Reason}}{{if .DismissedBy}} <span class="meta">by {{.DismissedBy}}</span>{{end}}</td>
220224 <td><form method="post" action="{{$base}}" class="inline">
@@ -302,7 +306,7 @@
302306</section>
303307
304308<section id="deps" class="setcard"><h2>Dependencies</h2>
305<form method="post" action="{{$base}}" class="setform">
309<form method="post" action="{{$base}}" class="setform" data-autosave="1">
306310 <input type="hidden" name="field" value="deps">
307311 <div><label for="deps-enabled">Check for updates and advisories</label><p class="hint">Evaluates the manifests and lockfiles on <code>{{.Repo.DefaultBranch}}</code> against the registries and OSV, and opens an issue for each. Updates for Go, NPM, Crates, and PyPI; advisories for those and SwiftPM.</p></div>
308312 <div class="check"><input type="checkbox" id="deps-enabled" name="deps" value="on"{{if .DepsEnabled}} checked{{end}}></div>
@@ -382,6 +386,133 @@
382386</details>
383387</section>
384388
389<section id="buildsecrets" class="setcard"><h2>Build secrets</h2>
390<p class="meta">Injected into CI job environments on trusted branches. Values are write-only and never shown again.</p>
391{{if .Secrets}}
392<ul class="protlist">
393{{range .Secrets}}<li><code>{{.}}</code>
394 <form method="post" action="{{$base}}" class="inline">
395 <input type="hidden" name="field" value="secret-remove">
396 <input type="hidden" name="secret-name" value="{{.}}">
397 <button type="submit" class="danger">Remove</button>
398 </form></li>
399{{end}}
400</ul>
401{{else}}<p class="meta">No build secrets.</p>{{end}}
402<details class="editbox"{{if index .Submitted "secret-name"}} open{{end}}>
403 <summary>Set a build secret</summary>
404 <form method="post" action="{{$base}}" class="setform stack" autocomplete="off">
405 <input type="hidden" name="field" value="secret-set">
406 <label for="secret-name">Name</label>
407 <input type="text" id="secret-name" name="secret-name" value="{{index .Submitted "secret-name"}}" placeholder="DEPLOY_TOKEN" spellcheck="false" required>
408 <label for="secret-value">Value</label>
409 <input type="password" id="secret-value" name="secret-value" value="" autocomplete="new-password" required>
410 <span class="btngroup"><button type="submit">Save secret</button></span>
411 </form>
412</details>
413</section>
414
415<section id="deploykeys" class="setcard"><h2>Deploy keys</h2>
416<p class="meta">SSH keys bound to this repository only, for automated fetches or pushes.</p>
417{{if .DeployKeys}}<div class="tablewrap"><table class="keys nowrap">
418<thead><tr class="cols"><th scope="col">label</th><th scope="col">fingerprint</th><th scope="col">mode</th><th scope="col">last used</th><th scope="col">expires</th><th scope="col"><span class="vh">actions</span></th></tr></thead>
419<tbody>{{range .DeployKeys}}<tr>
420 <td>{{.Label}}</td>
421 <td class="mono">{{.Fingerprint}}</td>
422 <td><span class="chip">{{.Mode}}</span></td>
423 <td>{{if .LastUsedAt}}{{when .LastUsedAt}}{{else}}never{{end}}</td>
424 <td>{{if .ExpiresAt}}{{when .ExpiresAt}}{{else}}never{{end}}</td>
425 <td class="act"><form method="post" action="{{$base}}" class="inline">
426 <input type="hidden" name="field" value="deploykey-remove">
427 <input type="hidden" name="fingerprint" value="{{.Fingerprint}}">
428 <button type="submit" class="danger">Remove</button>
429 </form></td>
430</tr>{{end}}</tbody></table></div>
431{{else}}<p class="meta">No deploy keys.</p>{{end}}
432<details class="editbox"{{if index .Submitted "deploy-key"}} open{{end}}>
433 <summary>Add a deploy key</summary>
434 <form method="post" action="{{$base}}" class="setform stack">
435 <input type="hidden" name="field" value="deploykey-add">
436 <label for="deploy-key">Public key</label>
437 <textarea id="deploy-key" name="deploy-key" rows="3" spellcheck="false" placeholder="ssh-ed25519 AAAA… deploy@host" required>{{index .Submitted "deploy-key"}}</textarea>
438 <label for="deploy-ttl">Expires after</label>
439 <input type="text" id="deploy-ttl" name="ttl" placeholder="e.g. 30d or 720h; empty never expires" autocomplete="off">
440 <label class="check"><input type="checkbox" name="rw" value="on"> Allow push access (<code>--rw</code>)</label>
441 <span class="btngroup"><button type="submit">Add deploy key</button></span>
442 </form>
443</details>
444</section>
445
446<section id="mirrors" class="setcard"><h2>Mirrors</h2>
447<p class="meta">Push commits to an upstream HTTPS remote or pull refs from one.</p>
448{{if .Mirrors}}<div class="tablewrap"><table class="keys">
449<thead><tr class="cols"><th scope="col">id</th><th scope="col">direction</th><th scope="col">url</th><th scope="col">status</th><th scope="col"><span class="vh">actions</span></th></tr></thead>
450<tbody>{{range .Mirrors}}<tr>
451 <td class="mono">#{{.ID}}</td>
452 <td><span class="chip">{{.Direction}}</span></td>
453 <td class="mono">{{.URL}}</td>
454 <td>{{if .LastError}}<span class="check-failure">{{.LastError}}</span>{{else if .Pending}}pending sync{{else if .LastSync}}synced {{when .LastSync}}{{else}}never synced{{end}}</td>
455 <td class="act"><form method="post" action="{{$base}}" class="inline">
456 <input type="hidden" name="field" value="mirror-remove">
457 <input type="hidden" name="id" value="{{.ID}}">
458 <button type="submit" class="danger">Remove</button>
459 </form></td>
460</tr>{{end}}</tbody></table></div>
461<form method="post" action="{{$base}}" class="actions">
462 <input type="hidden" name="field" value="mirror-sync">
463 <button type="submit" class="btn">Sync mirrors now</button>
464</form>
465{{else}}<p class="meta">No mirrors configured.</p>{{end}}
466<details class="editbox"{{if index .Submitted "mirror-url"}} open{{end}}>
467 <summary>Add a mirror</summary>
468 <form method="post" action="{{$base}}" class="setform stack" autocomplete="off">
469 <input type="hidden" name="field" value="mirror-add">
470 <label for="mirror-url">Remote HTTPS URL</label>
471 <input type="text" id="mirror-url" name="mirror-url" value="{{index .Submitted "mirror-url"}}" placeholder="https://example.org/owner/repo.git" spellcheck="false" required>
472 <label for="mirror-dir">Direction</label>
473 <select id="mirror-dir" name="direction">
474 <option value="push">push: replicate local refs to remote</option>
475 <option value="pull">pull: track upstream refs (refuses local pushes)</option>
476 </select>
477 <label for="mirror-user">Remote username (optional)</label>
478 <input type="text" id="mirror-user" name="mirror-user" value="{{index .Submitted "mirror-user"}}" autocomplete="off" spellcheck="false">
479 <label for="mirror-token">Credential token (optional)</label>
480 <p class="hint">Sent once over stdin and stored encrypted; never shown again.</p>
481 <input type="password" id="mirror-token" name="mirror-token" value="" autocomplete="new-password">
482 <span class="btngroup"><button type="submit">Add mirror</button></span>
483 </form>
484</details>
485</section>
486
487<section id="domains" class="setcard"><h2>Pages domains</h2>
488<p class="meta">Custom hostnames serving this repository's pages branch once verified by DNS TXT record.</p>
489{{if .Domains}}<div class="tablewrap"><table class="keys">
490<thead><tr class="cols"><th scope="col">domain</th><th scope="col">state</th><th scope="col"><span class="vh">actions</span></th></tr></thead>
491<tbody>{{range .Domains}}<tr>
492 <td class="mono">{{.Domain}}</td>
493 <td><span class="chip {{if eq .State "verified"}}chip-open{{else if eq .State "expired"}}chip-closed{{else}}chip-stale{{end}}">{{.State}}</span></td>
494 <td class="act">
495 {{if ne .State "verified"}}<form method="post" action="{{$base}}" class="inline">
496 <input type="hidden" name="field" value="domain-verify">
497 <input type="hidden" name="domain" value="{{.Domain}}">
498 <button type="submit" class="btn">Verify DNS</button>
499 </form> {{end}}
500 <form method="post" action="{{$base}}" class="inline">
501 <input type="hidden" name="field" value="domain-remove">
502 <input type="hidden" name="domain" value="{{.Domain}}">
503 <button type="submit" class="danger">Remove</button>
504 </form>
505 </td>
506</tr>{{end}}</tbody></table></div>
507{{else}}<p class="meta">No custom pages domains.</p>{{end}}
508<form method="post" action="{{$base}}" class="setform">
509 <input type="hidden" name="field" value="domain-add">
510 <div><label for="pages-domain">Claim a domain</label><p class="hint">Public repositories only.</p></div>
511 <div><input type="text" id="pages-domain" name="domain" value="{{index .Submitted "domain"}}" placeholder="docs.example.org" spellcheck="false"></div>
512 <div><button type="submit" class="btn">Claim</button></div>
513</form>
514</section>
515
385516<section id="lifecycle" class="setcard setcard-danger"><h2>Lifecycle</h2>
386517<form method="post" action="{{$base}}" class="setform">
387518 <input type="hidden" name="field" value="archive">
internal/web/templates/tree.html +2 −2 · view
@@ -9,7 +9,7 @@
99 {{template "refmenu" .}}
1010 <span class="crumbs"><a href="/{{.Repo.OwnerName}}/{{.Repo.Name}}">{{.Repo.Name}}</a>/{{range .Crumbs}}<a href="{{.URL}}">{{.Name}}</a>/{{end}}</span>
1111 <span class="spacer"></span>
12 {{if .Entries}}<input type="search" class="treefilter" placeholder="Filter files…" aria-label="Filter files" data-filter-table="repo-tree">{{end}}
12 {{if .Entries}}<input type="search" class="treefilter" placeholder="Filter files…" aria-label="Filter files" data-filter-table="repo-tree" data-filter-col=".name">{{end}}
1313 <div class="acts">
1414 <a class="button btn" href="/{{.Repo.OwnerName}}/{{.Repo.Name}}/search">Search code</a>
1515 <a class="button btn" href="/{{.Repo.OwnerName}}/{{.Repo.Name}}/log/{{.Ref}}">History</a>
@@ -51,7 +51,7 @@
5151 {{if .Facts.Bookmarks}}<span><b>{{.Facts.Bookmarks}}</b> bookmark{{if ne .Facts.Bookmarks 1}}s{{end}}</span>{{end}}
5252 {{with .Facts.License}}<span class="fact">{{.}}</span>{{end}}
5353 {{with .Facts.Release}}<a href="{{$r}}/releases">latest <b>{{.}}</b></a>{{end}}
54 {{with .Facts.Build}}<a href="{{$r}}/builds">build <span class="badge badge-{{.}}">{{.}}</span></a>{{end}}
54 {{with .Facts.Build}}<a href="{{$r}}/builds">build <span class="badge check-{{.}}">{{.}}</span></a>{{end}}
5555 </div>
5656 {{with .Facts.Languages}}<p class="langbar" aria-hidden="true">{{range .}}<span class="lang lang-{{slug .Name}}" style="width:{{pct .Percent}}%"></span>{{end}}</p>
5757 <p class="langs">{{range .}}<span class="lang-name"><span class="dot lang-{{slug .Name}}"></span>{{.Name}} <span class="muted">{{pct .Percent}}%</span></span>{{end}}</p>{{end}}
internal/web/tokens_test.go +20 · view
@@ -149,3 +149,23 @@ func TestTokenContrast(t *testing.T) {
149149 }
150150 }
151151}
152
153// TestEveryCSSVarIsDefined fails when style.css references a var(--name)
154// that neither :root nor a local component rule defines, catching stale
155// token names left over from earlier palettes.
156func TestEveryCSSVarIsDefined(t *testing.T) {
157 css := string(StyleCSS)
158 defined := map[string]bool{
159 // Supplied inline on .chip.label via style="--chip-l:...;--chip-d:..."
160 "chip-l": true,
161 "chip-d": true,
162 }
163 for _, m := range regexp.MustCompile(`--([a-zA-Z0-9_-]+)\s*:`).FindAllStringSubmatch(css, -1) {
164 defined[m[1]] = true
165 }
166 for _, m := range regexp.MustCompile(`var\(--([a-zA-Z0-9_-]+)`).FindAllStringSubmatch(css, -1) {
167 if !defined[m[1]] {
168 t.Errorf("style.css references undefined custom property --%s", m[1])
169 }
170 }
171}
Keyboard shortcuts

Global

⌘K
Command palette & jump
/
Focus search
?
Show this help
g d
Dashboard
g e
Explore repositories
g n
Notifications

Repository & editor

t
Find file in repository
y
Copy immutable SHA permalink
g c
Code tab
g i
Issues tab
g m
Merge requests tab
g b
Builds tab
⌘↵
Submit active form