Commit 6521399c1c
Verified · cmc ci/build: success ci/quality: success ci/test: success
Changed files (49)
- .gitbay/wiki/Parity.org +7 −7
- internal/control/commitfile.go +9 −5
- internal/control/query.go +37
- internal/control/register.go +29
- internal/gitutil/merge.go +25 −7
- internal/httpd/account.go +66 −24
- internal/httpd/accounts.go +130 −21
- internal/httpd/builds.go +113 −5
- internal/httpd/diff.go +141
- internal/httpd/diff_test.go +25
- internal/httpd/mractions.go +6
- internal/httpd/mrrangediff.go +33 −1
- internal/httpd/notifyweb.go +9 −1
- internal/httpd/palette_test.go +1 −1
- internal/httpd/queries.go +69 −11
- internal/httpd/releaseactions.go +3
- internal/httpd/routes.go +6
- internal/httpd/searchweb.go +116
- internal/httpd/settings.go +133
- internal/httpd/web.go +168 −31
- internal/httpd/webux_test.go +124
- internal/web/classes_test.go +17
- internal/web/static/app.js +690 −41
- internal/web/static/style.css +332 −69
- internal/web/templates/account.html +29 −1
- internal/web/templates/blame.html +2 −2
- internal/web/templates/blob.html +3 −1
- internal/web/templates/build.html +8 −2
- internal/web/templates/commit.html +1 −1
- internal/web/templates/compare.html +1 −1
- internal/web/templates/dashboard.html +1
- internal/web/templates/edit.html +3 −1
- internal/web/templates/globalsearch.html +1 −1
- internal/web/templates/issue.html +9 −9
- internal/web/templates/issues.html +13 −3
- internal/web/templates/layout.html +67 −17
- internal/web/templates/log.html +1 −1
- internal/web/templates/milestones.html +1 −1
- internal/web/templates/mr.html +56 −23
- internal/web/templates/mrrangediff.html +2
- internal/web/templates/mrs.html +7 −2
- internal/web/templates/new.html +7 −7
- internal/web/templates/owner.html +2 −2
- internal/web/templates/queries.html +77 −14
- internal/web/templates/registered.html +14 −1
- internal/web/templates/releases.html +1 −1
- internal/web/templates/settings.html +136 −5
- internal/web/templates/tree.html +2 −2
- internal/web/tokens_test.go +20
.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. | ||
| 215 | 215 | | access grants | yes | yes | yes | |
| 216 | 216 | | effective access | yes | yes | yes | |
| 217 | 217 | | 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 | | |
| 222 | 222 | | runners attach, list, detach | yes | yes | n/a | |
| 223 | 223 | | runner attached for some jobs | yes | yes | n/a | |
| 224 | 224 | | 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. | ||
| 340 | 340 | |----------------------------------+-----+-----+-----| |
| 341 | 341 | | search repositories | yes | yes | yes | |
| 342 | 342 | | 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 | | |
| 344 | 344 | | saved query list and results | yes | yes | yes | |
| 345 | 345 | | pinned queries on the dashboard | yes | yes | yes | |
| 346 | 346 | | browse all public repositories | yes | yes | yes | |
| @@ -414,7 +414,7 @@ client has no use for one (krz/gitbay#57). | ||
| 414 | 414 | |-----------------------------+-----+-----+-----| |
| 415 | 415 | | SSH keys: list, add, remove | yes | yes | yes | |
| 416 | 416 | | 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 | | |
| 418 | 418 | | PGP keys: list, add, remove | yes | yes | yes | |
| 419 | 419 | | email add and verify | yes | yes | yes | |
| 420 | 420 | | email list, remove, primary | yes | yes | yes | |
| @@ -432,7 +432,7 @@ client has no use for one (krz/gitbay#57). | ||
| 432 | 432 | | API token mint | yes | yes | yes | |
| 433 | 433 | | API token list, revoke | yes | yes | yes | |
| 434 | 434 | | 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 | | |
| 436 | 436 | | account export bundle | yes | yes | n/a | |
| 437 | 437 | | delete your own account | yes | yes | yes | |
| 438 | 438 | | profile set | yes | yes | yes | |
internal/control/commitfile.go +9 −5 · view
| @@ -16,9 +16,10 @@ func init() { | ||
| 16 | 16 | Path: []string{"repo", "commit-file"}, |
| 17 | 17 | Summary: "write a file and commit it", |
| 18 | 18 | Usage: "repo commit-file <owner/name> <path> " + |
| 19 | "--ref <branch> [--message <m>] [--file -]", | |
| 19 | "--ref <branch> [--from <base>] [--message <m>] [--file -]", | |
| 20 | 20 | Flags: []Flag{ |
| 21 | 21 | {"--ref", "<branch>", "branch to commit to", ""}, |
| 22 | {"--from", "<base>", "base branch when creating a new branch", ""}, | |
| 22 | 23 | {"--message", "<m>", "the commit message", ""}, |
| 23 | 24 | {"--file", "-", "read the new content from stdin", ""}, |
| 24 | 25 | }, |
| @@ -43,15 +44,18 @@ const maxCommitFileBytes = 1 << 20 | ||
| 43 | 44 | // A repository that requires verified signatures therefore refuses the |
| 44 | 45 | // command rather than writing a commit its own policy would reject. |
| 45 | 46 | func 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}) | |
| 47 | 48 | if err != nil { |
| 48 | 49 | return c.fail(protocol.ExitUsage, "%v", err) |
| 49 | 50 | } |
| 50 | 51 | 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") | |
| 52 | 53 | if len(rest) != 2 || ref == "" { |
| 53 | 54 | return c.usage() |
| 54 | 55 | } |
| 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 | } | |
| 55 | 59 | repo, code := resolveRepo(c, rest[0], policy.CanWrite) |
| 56 | 60 | if code >= 0 { |
| 57 | 61 | return code |
| @@ -101,9 +105,9 @@ func runCommitFile(c *Ctx, args []string) int { | ||
| 101 | 105 | |
| 102 | 106 | dir := RepoDir(c.Cfg.Server.Root, repo.OwnerName, repo.Name) |
| 103 | 107 | // 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. | |
| 105 | 109 | 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, | |
| 107 | 111 | c.User.Username, email, message) |
| 108 | 112 | if err != nil { |
| 109 | 113 | 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) { | ||
| 158 | 158 | return out, nil |
| 159 | 159 | } |
| 160 | 160 | |
| 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. | |
| 163 | func 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 | ||
| 161 | 198 | func encodeItemCursor(k store.ItemCursor) string { |
| 162 | 199 | return encodeCursor("query", fmt.Sprintf("%s|%d|%d", k.CreatedAt, k.Kind, k.ID)) |
| 163 | 200 | } |
internal/control/register.go +29 · view
| @@ -333,3 +333,32 @@ func RegisterAccount(cfg config.Config, st *store.Store, pub ssh.PublicKey, user | ||
| 333 | 333 | return "", "registration is closed on this instance", protocol.ExitDenied |
| 334 | 334 | } |
| 335 | 335 | } |
| 336 | ||
| 337 | // VerifyPendingSignup redeems an emailed verification code right on the web | |
| 338 | // post-registration screen, activating the account in one step. | |
| 339 | func 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) { | ||
| 199 | 199 | // advances the branch with compare-and-swap. Used by web edits; hooks do not |
| 200 | 200 | // run, so callers enforce policy themselves. |
| 201 | 201 | func 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. | |
| 207 | func CommitFileFrom(dir, branch, fromBranch, path string, content []byte, name, email, message string) (string, error) { | |
| 202 | 208 | branchRef := "refs/heads/" + branch |
| 209 | oldRef := "" | |
| 203 | 210 | parent, err := ResolveRef(dir, branchRef) |
| 204 | 211 | 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 = "" | |
| 210 | 227 | } |
| 211 | parent = "" | |
| 228 | } else { | |
| 229 | oldRef = parent | |
| 212 | 230 | } |
| 213 | 231 | |
| 214 | 232 | sha, err := CommitWithFile(dir, parent, path, "100644", content, name, email, message) |
| 215 | 233 | if err != nil { |
| 216 | 234 | return "", err |
| 217 | 235 | } |
| 218 | if err := UpdateRefCAS(dir, branchRef, sha, parent); err != nil { | |
| 236 | if err := UpdateRefCAS(dir, branchRef, sha, oldRef); err != nil { | |
| 219 | 237 | return "", fmt.Errorf("branch moved during edit; reload and retry: %w", err) |
| 220 | 238 | } |
| 221 | 239 | return sha, nil |
internal/httpd/account.go +66 −24 · view
| @@ -21,6 +21,8 @@ type accountKey struct { | ||
| 21 | 21 | Algo string |
| 22 | 22 | Scope string |
| 23 | 23 | Label string |
| 24 | LastUsed string | |
| 25 | Expires string | |
| 24 | 26 | Confirm string // the 8 characters after SHA256: — a label can be empty |
| 25 | 27 | } |
| 26 | 28 | |
| @@ -73,7 +75,14 @@ func (s *Server) renderAccount(w http.ResponseWriter, r *http.Request, u store.U | ||
| 73 | 75 | if list, err := s.st.ListSSHKeys(u.ID); err == nil { |
| 74 | 76 | for _, k := range list { |
| 75 | 77 | 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 | }) | |
| 77 | 86 | } |
| 78 | 87 | } |
| 79 | 88 | var pgp []accountPGP |
| @@ -122,6 +131,15 @@ func (s *Server) renderAccount(w http.ResponseWriter, r *http.Request, u store.U | ||
| 122 | 131 | } |
| 123 | 132 | } |
| 124 | 133 | |
| 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 | ||
| 125 | 143 | // The about text is a file. The page points at it rather than editing |
| 126 | 144 | // it: the repository's own editor already does that job. |
| 127 | 145 | aboutRepo := u.Username + "/" + control.ProfileRepoName |
| @@ -135,33 +153,35 @@ func (s *Server) renderAccount(w http.ResponseWriter, r *http.Request, u store.U | ||
| 135 | 153 | |
| 136 | 154 | s.render(w, "account.html", struct { |
| 137 | 155 | 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 | |
| 160 | 180 | }{s.baseFor(u), "account", keys, pgp, emails, profile, profileLinksText(profile.Links), |
| 161 | 181 | aboutRepo, aboutEdit, s.cfg.SiteHost(), |
| 162 | 182 | notice, r.URL.Query().Get("m"), mailOn, watchOn, pushOn, |
| 163 | 183 | replyOn, s.cfg.Mail.Inbound.Enabled, devices, theme, diffPref, |
| 164 | tokens, tokenShown, reauth}) | |
| 184 | tokens, tokenShown, sessions, currentSession, reauth}) | |
| 165 | 185 | } |
| 166 | 186 | |
| 167 | 187 | // 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 | ||
| 238 | 258 | if label := strings.TrimSpace(r.FormValue("label")); label != "" { |
| 239 | 259 | argv = append(argv, "--label", label) |
| 240 | 260 | } |
| 261 | if ttl := strings.TrimSpace(r.FormValue("ttl")); ttl != "" { | |
| 262 | argv = append(argv, "--ttl", ttl) | |
| 263 | } | |
| 241 | 264 | if msg, ok := s.runControlStdin(u, argv, body+"\n"); !ok { |
| 242 | 265 | back(msg, "") |
| 243 | 266 | return |
| 244 | 267 | } |
| 245 | 268 | 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) | |
| 246 | 288 | case "account-delete": |
| 247 | 289 | if ok, msg := confirmed(r, u.Username); !ok { |
| 248 | 290 | back(msg, "") |
internal/httpd/accounts.go +130 −21 · view
| @@ -212,9 +212,17 @@ func (s *Server) adminOrgs(u store.User) []string { | ||
| 212 | 212 | |
| 213 | 213 | func (s *Server) renderNewRepo(w http.ResponseWriter, u store.User, errMsg string, submitted url.Values) { |
| 214 | 214 | // 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 | } | |
| 215 | 222 | subm := map[string]string{ |
| 216 | 223 | "owner": submitted.Get("owner"), "name": submitted.Get("name"), |
| 217 | 224 | "from": submitted.Get("from"), "visibility": submitted.Get("visibility"), |
| 225 | "panel": panel, | |
| 218 | 226 | } |
| 219 | 227 | s.render(w, "new.html", struct { |
| 220 | 228 | basePage |
| @@ -232,10 +240,11 @@ func (s *Server) newRepoForm(w http.ResponseWriter, r *http.Request, u store.Use | ||
| 232 | 240 | // forms, told apart by the org form's field. An organization's page is |
| 233 | 241 | // the redirect, the same as org-create from anywhere else. |
| 234 | 242 | func (s *Server) newSubmit(w http.ResponseWriter, r *http.Request, u store.User) { |
| 243 | r.ParseForm() | |
| 235 | 244 | if r.FormValue("field") == "org-create" { |
| 236 | 245 | name := strings.TrimSpace(r.FormValue("name")) |
| 237 | 246 | 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) | |
| 239 | 248 | return |
| 240 | 249 | } |
| 241 | 250 | http.Redirect(w, r, "/"+name, http.StatusSeeOther) |
| @@ -269,12 +278,37 @@ func (s *Server) newSubmit(w http.ResponseWriter, r *http.Request, u store.User) | ||
| 269 | 278 | argv = append(argv, "--private") |
| 270 | 279 | } |
| 271 | 280 | if _, msg, ok := s.runControl(u, argv); !ok { |
| 272 | s.renderNewRepo(w, u, msg, nil) | |
| 281 | s.renderNewRepo(w, u, msg, r.Form) | |
| 273 | 282 | return |
| 274 | 283 | } |
| 275 | 284 | http.Redirect(w, r, "/"+owner+"/"+name, http.StatusSeeOther) |
| 276 | 285 | } |
| 277 | 286 | |
| 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. | |
| 290 | func 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 | ||
| 278 | 312 | // pinToggle pins or unpins the repo for the logged-in viewer, through |
| 279 | 313 | // repo pin/repo unpin — the same commands the CLI runs — rather than |
| 280 | 314 | // writing the store directly (#261). |
| @@ -290,7 +324,7 @@ func (s *Server) pinToggle(w http.ResponseWriter, r *http.Request, u store.User) | ||
| 290 | 324 | if _, msg, ok := s.runControl(u, []string{"repo", verb, repo.Path()}); !ok { |
| 291 | 325 | s.setFlash(w, msg) |
| 292 | 326 | } |
| 293 | http.Redirect(w, r, "/"+repo.Path(), http.StatusSeeOther) | |
| 327 | http.Redirect(w, r, safeReturnTo(r, "/"+repo.Path()), http.StatusSeeOther) | |
| 294 | 328 | } |
| 295 | 329 | |
| 296 | 330 | // 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. | ||
| 308 | 342 | if _, msg, ok := s.runControl(u, []string{"repo", verb, repo.Path()}); !ok { |
| 309 | 343 | s.setFlash(w, msg) |
| 310 | 344 | } |
| 311 | http.Redirect(w, r, "/"+repo.Path(), http.StatusSeeOther) | |
| 345 | http.Redirect(w, r, safeReturnTo(r, "/"+repo.Path()), http.StatusSeeOther) | |
| 312 | 346 | } |
| 313 | 347 | |
| 314 | 348 | // bookmarksPage lists what the viewer has saved. |
| @@ -427,7 +461,42 @@ func (s *Server) signupSubmit(w http.ResponseWriter, r *http.Request) { | ||
| 427 | 461 | Username string |
| 428 | 462 | Message string |
| 429 | 463 | 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 | ||
| 469 | func (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) | |
| 431 | 500 | } |
| 432 | 501 | |
| 433 | 502 | // 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 | ||
| 615 | 684 | func (s *Server) commentSubmit(w http.ResponseWriter, r *http.Request, u store.User, noun, segment string) { |
| 616 | 685 | repoPath := r.PathValue("owner") + "/" + r.PathValue("repo") |
| 617 | 686 | 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"))) | |
| 619 | 688 | if code != protocol.ExitOK { |
| 620 | 689 | http.Error(w, msg, statusForExit(code)) |
| 621 | 690 | return |
| @@ -631,6 +700,11 @@ type editPage struct { | ||
| 631 | 700 | Content string |
| 632 | 701 | Error string |
| 633 | 702 | 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 | |
| 634 | 708 | // Creating marks a path the branch does not have yet. |
| 635 | 709 | Creating bool |
| 636 | 710 | // Markup is set for a path the forge renders, which is where a |
| @@ -640,6 +714,17 @@ type editPage struct { | ||
| 640 | 714 | Nav fileNav |
| 641 | 715 | } |
| 642 | 716 | |
| 717 | func 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 | ||
| 643 | 728 | func (s *Server) editForm(w http.ResponseWriter, r *http.Request, u store.User) { |
| 644 | 729 | repo, ok := s.repoForUser(w, r, u, policy.CanWrite) |
| 645 | 730 | if !ok { |
| @@ -648,14 +733,6 @@ func (s *Server) editForm(w http.ResponseWriter, r *http.Request, u store.User) | ||
| 648 | 733 | ref := r.PathValue("ref") |
| 649 | 734 | filePath := strings.Trim(r.PathValue("path"), "/") |
| 650 | 735 | |
| 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 | ||
| 659 | 736 | dir := control.RepoDir(s.cfg.Server.Root, repo.OwnerName, repo.Name) |
| 660 | 737 | // A branch that does not exist has nothing to edit. A path that does |
| 661 | 738 | // 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) | ||
| 663 | 740 | s.notFound(w, r) |
| 664 | 741 | return |
| 665 | 742 | } |
| 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 | ||
| 666 | 755 | content, err := gitutil.ReadBlob(dir, "refs/heads/"+ref, filePath, maxRenderBytes) |
| 667 | 756 | creating := err != nil |
| 668 | 757 | if creating { |
| @@ -676,7 +765,8 @@ func (s *Server) editForm(w http.ResponseWriter, r *http.Request, u store.User) | ||
| 676 | 765 | nav := fileNavFor(repo.Path(), ref, filePath, navEntries) |
| 677 | 766 | s.render(w, "edit.html", editPage{ |
| 678 | 767 | 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, | |
| 680 | 770 | Markup: markupFile(filePath), |
| 681 | 771 | Nav: nav, |
| 682 | 772 | }) |
| @@ -689,6 +779,8 @@ func (s *Server) editSubmit(w http.ResponseWriter, r *http.Request, u store.User | ||
| 689 | 779 | } |
| 690 | 780 | ref := r.PathValue("ref") |
| 691 | 781 | 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) | |
| 692 | 784 | |
| 693 | 785 | // Preview: the file as the blob page will render it, above the |
| 694 | 786 | // 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 | ||
| 699 | 791 | }) |
| 700 | 792 | s.render(w, "edit.html", editPage{ |
| 701 | 793 | 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, | |
| 703 | 797 | }) |
| 704 | 798 | return |
| 705 | 799 | } |
| 706 | 800 | |
| 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 != "" { | |
| 712 | 811 | argv = append(argv, "--message", message) |
| 713 | 812 | } |
| 714 | 813 | if msg, ok := s.runControlStdin(u, argv, r.FormValue("content")); !ok { |
| 715 | 814 | s.render(w, "edit.html", editPage{ |
| 716 | 815 | basePage: s.baseFor(u), Repo: repo, |
| 717 | 816 | Ref: ref, Path: filePath, Content: r.FormValue("content"), Error: msg, |
| 817 | ProposeBranch: targetBranch, RequireMR: requireMR, | |
| 718 | 818 | Markup: markupFile(filePath), |
| 719 | 819 | }) |
| 720 | 820 | return |
| 721 | 821 | } |
| 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 | } | |
| 722 | 831 | http.Redirect(w, r, fmt.Sprintf("/%s/blob/%s/%s", repo.Path(), ref, filePath), http.StatusSeeOther) |
| 723 | 832 | } |
internal/httpd/builds.go +113 −5 · view
| @@ -283,6 +283,7 @@ func (s *Server) build(w http.ResponseWriter, r *http.Request) { | ||
| 283 | 283 | return |
| 284 | 284 | } |
| 285 | 285 | v.Log, _, _ = s.runControl(viewer, []string{"build", "log", p.Repo.Path(), n}) |
| 286 | v.LogHTML = ansiHTML(v.Log) | |
| 286 | 287 | v.Steps, v.Failed = logSteps(v.Log, b) |
| 287 | 288 | if b.DurationS > 0 { |
| 288 | 289 | v.Duration = (time.Duration(b.DurationS) * time.Second).String() |
| @@ -292,8 +293,9 @@ func (s *Server) build(w http.ResponseWriter, r *http.Request) { | ||
| 292 | 293 | |
| 293 | 294 | type buildView struct { |
| 294 | 295 | repoPage |
| 295 | Build control.BuildOut | |
| 296 | Log string | |
| 296 | Build control.BuildOut | |
| 297 | Log string | |
| 298 | LogHTML template.HTML | |
| 297 | 299 | // Steps is the finished log cut at its steps, nil when there is no |
| 298 | 300 | // step to cut at; Failed says whether one of them is marked failed. |
| 299 | 301 | Steps []logStep |
| @@ -308,8 +310,9 @@ type logStep struct { | ||
| 308 | 310 | control.LogSection |
| 309 | 311 | // Head is the step's first line, which its fold's summary shows, as |
| 310 | 312 | // 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 | |
| 313 | 316 | } |
| 314 | 317 | |
| 315 | 318 | // 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) { | ||
| 330 | 333 | out := make([]logStep, len(sections)) |
| 331 | 334 | for i, s := range sections { |
| 332 | 335 | 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} | |
| 334 | 337 | } |
| 335 | 338 | return out, failed >= 0 |
| 336 | 339 | } |
| 337 | 340 | |
| 341 | // ansiHTML escapes build log text and converts standard SGR ANSI sequences | |
| 342 | // (\x1b[...m) into semantic <span class="ansi-*"> elements. | |
| 343 | func 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 | ||
| 338 | 446 | // liveLogMarker stands in for the log when build.html is rendered for a |
| 339 | 447 | // live build; streamBuild splits the page there and streams the log into |
| 340 | 448 | // 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) { | ||
| 190 | 190 | hunk := f.Lines[start:end] |
| 191 | 191 | assign(hunk, "del", highlightLines(lexer, sideText(hunk, "del"))) |
| 192 | 192 | assign(hunk, "add", highlightLines(lexer, sideText(hunk, "add"))) |
| 193 | highlightIntraLine(hunk) | |
| 193 | 194 | start = end |
| 194 | 195 | } |
| 195 | 196 | } |
| 196 | 197 | |
| 198 | // highlightIntraLine marks the changed interior span on paired -/+ runs so | |
| 199 | // single-token edits pop out without scanning whole lines character by character. | |
| 200 | func 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. | |
| 251 | func 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 | ||
| 329 | func 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 | ||
| 197 | 338 | // sideText joins one side of a hunk: context plus the given change class. |
| 198 | 339 | // Content, not Text: the marker is already off it. Taking it off Text here |
| 199 | 340 | // 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) { | ||
| 206 | 206 | } |
| 207 | 207 | } |
| 208 | 208 | } |
| 209 | ||
| 210 | func 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 | ||
| 179 | 179 | s.done(w, r, code, msg, s.mrRedirect) |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | // mrRebaseSubmit rebases the merge request's source branch onto its target. | |
| 183 | func (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 | ||
| 182 | 188 | // mrThreadSubmit resolves or reopens one review thread. |
| 183 | 189 | func (s *Server) mrThreadSubmit(w http.ResponseWriter, r *http.Request, u store.User) { |
| 184 | 190 | verb := "resolve" |
internal/httpd/mrrangediff.go +33 −1 · view
| @@ -3,11 +3,42 @@ package httpd | ||
| 3 | 3 | import ( |
| 4 | 4 | "net/http" |
| 5 | 5 | "strconv" |
| 6 | "strings" | |
| 6 | 7 | |
| 7 | 8 | "gitbay.org/gitbay/internal/protocol" |
| 8 | 9 | "gitbay.org/gitbay/internal/store" |
| 9 | 10 | ) |
| 10 | 11 | |
| 12 | type rangeDiffLine struct { | |
| 13 | Class string | |
| 14 | Text string | |
| 15 | } | |
| 16 | ||
| 17 | func 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 | ||
| 11 | 42 | // mrRangeDiff renders what changed between two revisions of a merge |
| 12 | 43 | // request — the same comparison `mr range-diff` prints on the CLI and |
| 13 | 44 | // 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) { | ||
| 50 | 81 | repoPage |
| 51 | 82 | MR store.MR |
| 52 | 83 | Diff string |
| 84 | Lines []rangeDiffLine | |
| 53 | 85 | Error string |
| 54 | }{p, m, out, errMsg}) | |
| 86 | }{p, m, out, parseRangeDiffLines(out), errMsg}) | |
| 55 | 87 | } |
internal/httpd/notifyweb.go +9 −1 · view
| @@ -64,8 +64,16 @@ func (s *Server) watchToggle(w http.ResponseWriter, r *http.Request, u store.Use | ||
| 64 | 64 | } |
| 65 | 65 | next := map[string]string{"": "watch", "watching": "mute", "muted": "unwatch"} |
| 66 | 66 | 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 | } | |
| 67 | 75 | if _, msg, ok := s.runControl(u, []string{"repo", verb, repo.Path()}); !ok { |
| 68 | 76 | s.setFlash(w, msg) |
| 69 | 77 | } |
| 70 | http.Redirect(w, r, "/"+repo.Path(), http.StatusSeeOther) | |
| 78 | http.Redirect(w, r, safeReturnTo(r, "/"+repo.Path()), http.StatusSeeOther) | |
| 71 | 79 | } |
internal/httpd/palette_test.go +1 −1 · view
| @@ -52,7 +52,7 @@ func TestSyntaxPaletteContrast(t *testing.T) { | ||
| 52 | 52 | exempt map[chroma.TokenType]bool |
| 53 | 53 | }{ |
| 54 | 54 | {lightStyle, map[string]chroma.Colour{ |
| 55 | "page": chroma.NewColour(0xff, 0xff, 0xff), | |
| 55 | "page": chroma.NewColour(0xf7, 0xf8, 0xfa), | |
| 56 | 56 | "code": chroma.NewColour(0xff, 0xff, 0xff), |
| 57 | 57 | "add": chroma.NewColour(0xe4, 0xf6, 0xea), |
| 58 | 58 | "del": chroma.NewColour(0xfd, 0xea, 0xea), |
internal/httpd/queries.go +69 −11 · view
| @@ -4,6 +4,7 @@ import ( | ||
| 4 | 4 | "net/http" |
| 5 | 5 | "net/url" |
| 6 | 6 | "strconv" |
| 7 | "strings" | |
| 7 | 8 | |
| 8 | 9 | "gitbay.org/gitbay/internal/control" |
| 9 | 10 | "gitbay.org/gitbay/internal/protocol" |
| @@ -14,30 +15,44 @@ import ( | ||
| 14 | 15 | // offering the next, through query run's own cursor. |
| 15 | 16 | const queryPerPage = 50 |
| 16 | 17 | |
| 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. | |
| 21 | 21 | func (s *Server) queriesPage(w http.ResponseWriter, r *http.Request, viewer store.User) { |
| 22 | 22 | if r.PathValue("owner") != viewer.Username { |
| 23 | 23 | s.notFound(w, r) |
| 24 | 24 | return |
| 25 | 25 | } |
| 26 | 26 | name := r.PathValue("name") |
| 27 | adHoc := strings.TrimSpace(r.URL.Query().Get("q")) | |
| 27 | 28 | data := struct { |
| 28 | 29 | 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)} | |
| 36 | 39 | if name == "" { |
| 37 | 40 | if msg, ok := s.runControlInto(viewer, []string{"query", "list"}, &data.Saved); !ok { |
| 38 | 41 | http.Error(w, msg, http.StatusInternalServerError) |
| 39 | 42 | return |
| 40 | 43 | } |
| 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 | } | |
| 41 | 56 | s.render(w, "queries.html", data) |
| 42 | 57 | return |
| 43 | 58 | } |
| @@ -76,3 +91,46 @@ func (s *Server) queriesPage(w http.ResponseWriter, r *http.Request, viewer stor | ||
| 76 | 91 | } |
| 77 | 92 | s.render(w, "queries.html", data) |
| 78 | 93 | } |
| 94 | ||
| 95 | // queriesSubmit saves, pins, unpins, or removes a saved query through the | |
| 96 | // same query commands the CLI runs. | |
| 97 | func (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 | ||
| 73 | 73 | verb = "edit" |
| 74 | 74 | } |
| 75 | 75 | argv := []string{"release", verb, repo, tag} |
| 76 | if verb == "create" { | |
| 77 | argv = append(argv, "--format", bodyFormat(r)) | |
| 78 | } | |
| 76 | 79 | if title != "" { |
| 77 | 80 | argv = append(argv, "--title", title) |
| 78 | 81 | } |
internal/httpd/routes.go +6 · view
| @@ -151,6 +151,8 @@ func (s *Server) Routes() []Route { | ||
| 151 | 151 | Route{Method: "GET", Pattern: "/register", Handler: s.signupForm}, |
| 152 | 152 | Route{Method: "POST", Pattern: "/register", Mutating: true, |
| 153 | 153 | Handler: s.checkOrigin(s.signupSubmit)}, |
| 154 | Route{Method: "POST", Pattern: "/register/verify", Mutating: true, | |
| 155 | Handler: s.checkOrigin(s.signupVerifySubmit)}, | |
| 154 | 156 | ) |
| 155 | 157 | } |
| 156 | 158 | routes = append(routes, |
| @@ -193,6 +195,8 @@ func (s *Server) Routes() []Route { | ||
| 193 | 195 | Handler: s.checkOrigin(s.requireUser(s.orgMilestoneSubmit))}, |
| 194 | 196 | Route{Method: "GET", Pattern: "/bookmarks", Handler: s.requireUser(s.bookmarksPage)}, |
| 195 | 197 | 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))}, | |
| 196 | 200 | Route{Method: "GET", Pattern: "/{owner}/-/queries/{name}", Handler: s.requireUser(s.queriesPage)}, |
| 197 | 201 | Route{Method: "GET", Pattern: "/{owner}/-/snippets/new", Handler: s.requireUser(s.snippetNewForm)}, |
| 198 | 202 | Route{Method: "POST", Pattern: "/{owner}/-/snippets/new", Mutating: true, |
| @@ -243,6 +247,8 @@ func (s *Server) Routes() []Route { | ||
| 243 | 247 | Handler: s.checkOrigin(s.requireUser(s.mrDraftSubmit))}, |
| 244 | 248 | Route{Method: "POST", Pattern: "/{owner}/{repo}/mrs/{n}/retarget", Mutating: true, |
| 245 | 249 | 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))}, | |
| 246 | 252 | Route{Method: "POST", Pattern: "/{owner}/{repo}/mrs/{n}/thread", Mutating: true, |
| 247 | 253 | Handler: s.checkOrigin(s.requireUser(s.mrThreadSubmit))}, |
| 248 | 254 | Route{Method: "POST", Pattern: "/{owner}/{repo}/mrs/{n}/diff-comment", Mutating: true, |
internal/httpd/searchweb.go +116 · view
| @@ -1,11 +1,14 @@ | ||
| 1 | 1 | package httpd |
| 2 | 2 | |
| 3 | 3 | import ( |
| 4 | "encoding/json" | |
| 4 | 5 | "net/http" |
| 5 | 6 | "strconv" |
| 6 | 7 | "strings" |
| 7 | 8 | |
| 8 | 9 | "gitbay.org/gitbay/internal/control" |
| 10 | "gitbay.org/gitbay/internal/gitutil" | |
| 11 | "gitbay.org/gitbay/internal/policy" | |
| 9 | 12 | "gitbay.org/gitbay/internal/store" |
| 10 | 13 | ) |
| 11 | 14 | |
| @@ -17,6 +20,12 @@ type searchResult struct { | ||
| 17 | 20 | Href string |
| 18 | 21 | } |
| 19 | 22 | |
| 23 | type paletteEntry struct { | |
| 24 | Group string `json:"group"` | |
| 25 | Label string `json:"label"` | |
| 26 | Href string `json:"href"` | |
| 27 | } | |
| 28 | ||
| 20 | 29 | // globalSearch is /search: repositories, issues and merge requests across |
| 21 | 30 | // the instance. It is readable without a session — a visitor sees exactly |
| 22 | 31 | // 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) { | ||
| 26 | 35 | if s.cfg.Web.Mode == "accounts" { |
| 27 | 36 | viewer = s.viewer(r) |
| 28 | 37 | } |
| 38 | if r.URL.Query().Get("format") == "palette" { | |
| 39 | s.servePalette(w, r, viewer) | |
| 40 | return | |
| 41 | } | |
| 29 | 42 | q := strings.TrimSpace(r.URL.Query().Get("q")) |
| 30 | 43 | kind := r.URL.Query().Get("kind") |
| 31 | 44 | if kind != "repo" && kind != "issue" && kind != "mr" { |
| @@ -71,3 +84,106 @@ func searchHref(h control.SearchResult) string { | ||
| 71 | 84 | return "/" + h.Repo |
| 72 | 85 | } |
| 73 | 86 | } |
| 87 | ||
| 88 | // servePalette answers Cmd+K / 't' jump queries with files, symbols, issues, | |
| 89 | // merge requests, and repositories the viewer can read. | |
| 90 | func (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 { | ||
| 32 | 32 | ScanFrequency string |
| 33 | 33 | ScanHour int |
| 34 | 34 | Runners []store.RepoRunner |
| 35 | Secrets []string | |
| 36 | DeployKeys []deployKeyRow | |
| 37 | Mirrors []mirrorRow | |
| 38 | Domains []domainRow | |
| 35 | 39 | Access []accessRow |
| 36 | 40 | Hooks []hookRow |
| 37 | 41 | Deliveries []deliveryRow |
| @@ -41,6 +45,31 @@ type settingsPage struct { | ||
| 41 | 45 | Submitted map[string]string |
| 42 | 46 | } |
| 43 | 47 | |
| 48 | type 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 | ||
| 57 | type 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 | ||
| 67 | type domainRow struct { | |
| 68 | Domain string `json:"domain"` | |
| 69 | State string `json:"state"` | |
| 70 | Verified string `json:"verified_at"` | |
| 71 | } | |
| 72 | ||
| 44 | 73 | type accessRow struct { |
| 45 | 74 | User string `json:"user"` |
| 46 | 75 | Role string `json:"role"` |
| @@ -92,6 +121,14 @@ func (s *Server) settingsFormWith(w http.ResponseWriter, r *http.Request, u stor | ||
| 92 | 121 | s.runControlInto(u, []string{"repo", "security", "status", repo.Path()}, &security) |
| 93 | 122 | var runners []store.RepoRunner |
| 94 | 123 | 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) | |
| 95 | 132 | var access []accessRow |
| 96 | 133 | s.runControlInto(u, []string{"repo", "access", "list", repo.Path()}, &access) |
| 97 | 134 | var hooks []hookRow |
| @@ -105,6 +142,7 @@ func (s *Server) settingsFormWith(w http.ResponseWriter, r *http.Request, u stor | ||
| 105 | 142 | "website": submitted.Get("website"), |
| 106 | 143 | "topics": submitted.Get("topics"), |
| 107 | 144 | "key": submitted.Get("key"), |
| 145 | "deploy-key": submitted.Get("deploy-key"), | |
| 108 | 146 | "user": submitted.Get("user"), |
| 109 | 147 | "role": submitted.Get("role"), |
| 110 | 148 | "url": submitted.Get("url"), |
| @@ -112,6 +150,10 @@ func (s *Server) settingsFormWith(w http.ResponseWriter, r *http.Request, u stor | ||
| 112 | 150 | "name": submitted.Get("name"), |
| 113 | 151 | "new-owner": submitted.Get("new-owner"), |
| 114 | 152 | "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"), | |
| 115 | 157 | } |
| 116 | 158 | } |
| 117 | 159 | s.render(w, "settings.html", settingsPage{ |
| @@ -122,6 +164,10 @@ func (s *Server) settingsFormWith(w http.ResponseWriter, r *http.Request, u stor | ||
| 122 | 164 | ScanFrequency: s.cfg.Security.Frequency(repo.Settings.SecurityFrequency), |
| 123 | 165 | ScanHour: s.cfg.Security.Hour, |
| 124 | 166 | Runners: runners, |
| 167 | Secrets: secrets, | |
| 168 | DeployKeys: deployKeys, | |
| 169 | Mirrors: mirrors, | |
| 170 | Domains: domains, | |
| 125 | 171 | Access: access, Hooks: hooks, Deliveries: deliveries, |
| 126 | 172 | Notice: notice, |
| 127 | 173 | Saved: strings.HasPrefix(notice, "Saved "), |
| @@ -283,6 +329,85 @@ func (s *Server) settingsSubmit(w http.ResponseWriter, r *http.Request, u store. | ||
| 283 | 329 | return |
| 284 | 330 | case "runner-remove": |
| 285 | 331 | 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")} | |
| 286 | 411 | case "access-grant": |
| 287 | 412 | argv = []string{"repo", "access", "grant", repo, v("user"), v("role")} |
| 288 | 413 | case "access-revoke": |
| @@ -401,6 +526,14 @@ func fieldLabel(field string) string { | ||
| 401 | 526 | return "topics" |
| 402 | 527 | case "runner-add", "runner-remove": |
| 403 | 528 | 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" | |
| 404 | 537 | case "access-grant", "access-revoke": |
| 405 | 538 | return "access" |
| 406 | 539 | case "webhook-remove": |
internal/httpd/web.go +168 −31 · view
| @@ -4,6 +4,7 @@ import ( | ||
| 4 | 4 | "bytes" |
| 5 | 5 | "crypto/sha256" |
| 6 | 6 | "encoding/hex" |
| 7 | "encoding/json" | |
| 7 | 8 | "errors" |
| 8 | 9 | "fmt" |
| 9 | 10 | "hash/fnv" |
| @@ -354,6 +355,8 @@ type repoPage struct { | ||
| 354 | 355 | Topics []string |
| 355 | 356 | Pinned bool // by the viewer |
| 356 | 357 | Marked bool // bookmarked by the viewer |
| 358 | Bookmarks int // public bookmark count | |
| 359 | Forks int // public fork count | |
| 357 | 360 | Watch string // the viewer's watch state: watching, muted, or "" |
| 358 | 361 | HasWiki bool |
| 359 | 362 | Host string |
| @@ -436,12 +439,16 @@ func (s *Server) repoFor(w http.ResponseWriter, r *http.Request, ref string) (re | ||
| 436 | 439 | } |
| 437 | 440 | } |
| 438 | 441 | openIssues, openMRs := s.st.OpenCounts(repo.ID) |
| 442 | bookmarksCount := s.st.BookmarkCount(repo.ID) | |
| 443 | forksList, _ := s.st.ListForks(repo.ID) | |
| 439 | 444 | return repoPage{ |
| 440 | 445 | basePage: s.baseFor(viewer), |
| 441 | 446 | CanAdmin: canAdmin, |
| 442 | 447 | Mirrors: mirrors, |
| 443 | 448 | Pinned: pinned, |
| 444 | 449 | Marked: marked, |
| 450 | Bookmarks: bookmarksCount, | |
| 451 | Forks: len(forksList), | |
| 445 | 452 | Watch: watch, |
| 446 | 453 | HasWiki: s.hasWiki(repo), |
| 447 | 454 | Host: s.cfg.SiteHost(), |
| @@ -777,6 +784,10 @@ func (s *Server) blob(w http.ResponseWriter, r *http.Request) { | ||
| 777 | 784 | return |
| 778 | 785 | } |
| 779 | 786 | 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 | } | |
| 780 | 791 | _, image := imageTypes[strings.ToLower(path.Ext(filePath))] |
| 781 | 792 | |
| 782 | 793 | var codeHTML template.HTML |
| @@ -814,6 +825,12 @@ func (s *Server) blob(w http.ResponseWriter, r *http.Request) { | ||
| 814 | 825 | // The file listing leads with the last commit now, so the facts about |
| 815 | 826 | // the file itself are reported here instead. |
| 816 | 827 | 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 | } | |
| 817 | 834 | s.render(w, "blob.html", struct { |
| 818 | 835 | repoPage |
| 819 | 836 | Crumbs []crumb |
| @@ -821,6 +838,8 @@ func (s *Server) blob(w http.ResponseWriter, r *http.Request) { | ||
| 821 | 838 | Path string |
| 822 | 839 | DirPath string |
| 823 | 840 | RefKind string |
| 841 | Commit string | |
| 842 | Tip namedCommit | |
| 824 | 843 | Binary bool |
| 825 | 844 | Image bool |
| 826 | 845 | Size int |
| @@ -834,10 +853,48 @@ func (s *Server) blob(w http.ResponseWriter, r *http.Request) { | ||
| 834 | 853 | RenderedHTML template.HTML |
| 835 | 854 | Nav fileNav |
| 836 | 855 | 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, | |
| 838 | 857 | entry.Mode == "100755", entry.Mode == "120000", branches, codeHTML, renderable, rendered, renderedHTML, nav, fileSymbols}) |
| 839 | 858 | } |
| 840 | 859 | |
| 860 | func (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 | ||
| 841 | 898 | // releases lists tag-anchored releases with notes and assets. |
| 842 | 899 | func (s *Server) releases(w http.ResponseWriter, r *http.Request) { |
| 843 | 900 | s.releasesPage(w, r, "") |
| @@ -881,12 +938,13 @@ func (s *Server) releasesPage(w http.ResponseWriter, r *http.Request, previewFor | ||
| 881 | 938 | } |
| 882 | 939 | } |
| 883 | 940 | } |
| 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. | |
| 886 | 943 | var d *draft |
| 887 | 944 | if previewForm != "" { |
| 888 | format := "md" | |
| 945 | format := bodyFormat(r) | |
| 889 | 946 | if tag, ok := strings.CutPrefix(previewForm, "release:"); ok { |
| 947 | format = "md" | |
| 890 | 948 | for _, v := range views { |
| 891 | 949 | if v.Tag == tag { |
| 892 | 950 | format = v.NotesFormat |
| @@ -1098,18 +1156,24 @@ func (s *Server) blame(w http.ResponseWriter, r *http.Request) { | ||
| 1098 | 1156 | |
| 1099 | 1157 | type hunkView struct { |
| 1100 | 1158 | 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 | |
| 1105 | 1164 | } |
| 1165 | blameLexer := lexers.Match(filePath) | |
| 1106 | 1166 | var hunks []hunkView |
| 1107 | 1167 | sigs := map[string]sigView{} |
| 1168 | parents := map[string]string{} | |
| 1108 | 1169 | for _, h := range out.Hunks { |
| 1109 | 1170 | v, seen := sigs[h.SHA] |
| 1110 | 1171 | if !seen { |
| 1111 | 1172 | v, _ = s.sigFor(p.Repo, p.Dir, h.SHA) |
| 1112 | 1173 | sigs[h.SHA] = v |
| 1174 | if ps := gitutil.Parents(p.Dir, h.SHA); len(ps) > 0 { | |
| 1175 | parents[h.SHA] = ps[0] | |
| 1176 | } | |
| 1113 | 1177 | } |
| 1114 | 1178 | date := h.Date |
| 1115 | 1179 | 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) { | ||
| 1119 | 1183 | BlameHunk: gitutil.BlameHunk{SHA: h.SHA, AuthorName: h.AuthorName, |
| 1120 | 1184 | AuthorEmail: h.AuthorEmail, Summary: h.Summary, |
| 1121 | 1185 | 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") | |
| 1123 | 1191 | } |
| 1124 | 1192 | 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}) | |
| 1126 | 1198 | } |
| 1127 | 1199 | hunks = append(hunks, hv) |
| 1128 | 1200 | } |
| @@ -1158,6 +1230,7 @@ func (s *Server) blame(w http.ResponseWriter, r *http.Request) { | ||
| 1158 | 1230 | type numberedLine struct { |
| 1159 | 1231 | N int |
| 1160 | 1232 | Text string |
| 1233 | Code template.HTML | |
| 1161 | 1234 | } |
| 1162 | 1235 | |
| 1163 | 1236 | // chromaFormatter emits class-based markup (no inline colors), so the |
| @@ -1915,7 +1988,7 @@ var hexColorPat = regexp.MustCompile(`^#[0-9a-fA-F]{6}$`) | ||
| 1915 | 1988 | // 4.5:1. TestChipCanvasMatchesStylesheet keeps these in step with the |
| 1916 | 1989 | // tokens. |
| 1917 | 1990 | const ( |
| 1918 | chipCanvasLight = "#ffffff" | |
| 1991 | chipCanvasLight = "#f7f8fa" | |
| 1919 | 1992 | chipCanvasDark = "#101114" |
| 1920 | 1993 | chipRatio = 4.5 |
| 1921 | 1994 | ) |
| @@ -2091,11 +2164,24 @@ func (s *Server) issues(w http.ResponseWriter, r *http.Request) { | ||
| 2091 | 2164 | issues = issues[:listPage] |
| 2092 | 2165 | older = olderLink(r, issues[len(issues)-1].Number) |
| 2093 | 2166 | } |
| 2167 | ids := make([]int64, len(issues)) | |
| 2168 | for i, iss := range issues { | |
| 2169 | ids[i] = iss.ID | |
| 2170 | } | |
| 2094 | 2171 | if labels, err := s.st.ListIssueLabels(p.Repo); err == nil { |
| 2095 | 2172 | for i := range issues { |
| 2096 | 2173 | issues[i].Labels = labels[issues[i].ID] |
| 2097 | 2174 | } |
| 2098 | 2175 | } |
| 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 | } | |
| 2099 | 2185 | base := url.Values{"state": {state}, "label": {f.Label}, "assignee": {f.Assignee}, "author": {f.Author}, "milestone": {f.Milestone}, "q": {f.Search}} |
| 2100 | 2186 | readable, _ := control.ReadableScope(s.st, s.viewer(r), p.Repo) |
| 2101 | 2187 | allLabels, _ := s.st.ListLabels(p.Repo, readable) |
| @@ -2103,17 +2189,19 @@ func (s *Server) issues(w http.ResponseWriter, r *http.Request) { | ||
| 2103 | 2189 | facets := listFacets(base, []string{"open", "closed", "all"}, state, allLabels, openMS, false) |
| 2104 | 2190 | s.render(w, "issues.html", struct { |
| 2105 | 2191 | 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 | |
| 2114 | 2202 | }{p, state, f.Label, f.Search, |
| 2115 | 2203 | 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}) | |
| 2117 | 2205 | } |
| 2118 | 2206 | |
| 2119 | 2207 | func (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 | ||
| 2146 | 2234 | return |
| 2147 | 2235 | } |
| 2148 | 2236 | 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. | |
| 2152 | 2238 | var d *draft |
| 2153 | 2239 | if previewForm != "" { |
| 2154 | 2240 | format := iss.BodyFormat |
| 2155 | 2241 | if previewForm == "comment" { |
| 2156 | format = "md" | |
| 2242 | format = bodyFormat(r) | |
| 2157 | 2243 | } |
| 2158 | 2244 | d = s.draftFor(r, p.Repo, previewForm, "body", format) |
| 2159 | 2245 | } |
| @@ -2237,9 +2323,41 @@ func (s *Server) canEditItem(r *http.Request, repo store.Repo, author string) bo | ||
| 2237 | 2323 | type mrRow struct { |
| 2238 | 2324 | store.MR |
| 2239 | 2325 | Check string |
| 2326 | Review string | |
| 2240 | 2327 | Comments int |
| 2241 | 2328 | } |
| 2242 | 2329 | |
| 2330 | // summarizeReviews computes the aggregate non-stale review state among | |
| 2331 | // reviewers who count for merge gates: "changes_requested" beats "approved". | |
| 2332 | func 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 | ||
| 2243 | 2361 | func (s *Server) mrs(w http.ResponseWriter, r *http.Request) { |
| 2244 | 2362 | p, ok := s.repoFor(w, r, "") |
| 2245 | 2363 | if !ok { |
| @@ -2283,6 +2401,10 @@ func (s *Server) mrs(w http.ResponseWriter, r *http.Request) { | ||
| 2283 | 2401 | if err != nil { |
| 2284 | 2402 | comments = map[int64]int{} |
| 2285 | 2403 | } |
| 2404 | reviewsMap, err := s.st.MRReviewsFor(ids) | |
| 2405 | if err != nil { | |
| 2406 | reviewsMap = map[int64][]store.MRReview{} | |
| 2407 | } | |
| 2286 | 2408 | labels, err := s.st.ListMRLabels(p.Repo) |
| 2287 | 2409 | if err != nil { |
| 2288 | 2410 | labels = map[int64][]string{} |
| @@ -2290,7 +2412,11 @@ func (s *Server) mrs(w http.ResponseWriter, r *http.Request) { | ||
| 2290 | 2412 | rows := make([]mrRow, len(mrs)) |
| 2291 | 2413 | for i, m := range mrs { |
| 2292 | 2414 | 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 | } | |
| 2294 | 2420 | } |
| 2295 | 2421 | base := url.Values{"state": {state}, "label": {mf.Label}, "author": {mf.Author}, "milestone": {mf.Milestone}, "q": {mf.Search}} |
| 2296 | 2422 | readable, _ := control.ReadableScope(s.st, s.viewer(r), p.Repo) |
| @@ -2305,12 +2431,13 @@ func (s *Server) mrs(w http.ResponseWriter, r *http.Request) { | ||
| 2305 | 2431 | Filters []listFilter |
| 2306 | 2432 | Facets []facetGroup |
| 2307 | 2433 | MRs []mrRow |
| 2434 | People []string | |
| 2308 | 2435 | LabelColors map[string]template.CSS |
| 2309 | 2436 | Older string |
| 2310 | 2437 | CanOpenMR bool |
| 2311 | 2438 | }{p, state, mf.Search, |
| 2312 | 2439 | 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}) | |
| 2314 | 2441 | } |
| 2315 | 2442 | |
| 2316 | 2443 | func (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 | ||
| 2369 | 2496 | } |
| 2370 | 2497 | } |
| 2371 | 2498 | 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 != "" { | |
| 2373 | 2510 | if patch, truncated, err := gitutil.Diff(p.Dir, base, headRef, 4<<20); err == nil { |
| 2374 | 2511 | files, diffTruncated = parseDiff(patch), truncated |
| 2375 | 2512 | } |
| @@ -2478,13 +2615,12 @@ func (s *Server) mrPage(w http.ResponseWriter, r *http.Request, previewForm stri | ||
| 2478 | 2615 | // The merge requests this one superseded when it was closed, so the |
| 2479 | 2616 | // page it points to can also say what it supersedes. |
| 2480 | 2617 | 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. | |
| 2483 | 2619 | var d *draft |
| 2484 | 2620 | if previewForm != "" { |
| 2485 | 2621 | format := m.BodyFormat |
| 2486 | 2622 | if previewForm == "comment" { |
| 2487 | format = "md" | |
| 2623 | format = bodyFormat(r) | |
| 2488 | 2624 | } |
| 2489 | 2625 | d = s.draftFor(r, p.Repo, previewForm, "body", format) |
| 2490 | 2626 | } |
| @@ -2525,11 +2661,12 @@ func (s *Server) mrPage(w http.ResponseWriter, r *http.Request, previewForm stri | ||
| 2525 | 2661 | People []string |
| 2526 | 2662 | Draft *draft |
| 2527 | 2663 | Layout diffLayout |
| 2664 | SelectedCommit string | |
| 2528 | 2665 | Reactions map[int64]reactionBar |
| 2529 | 2666 | }{p, m, view, md(m.Body, m.BodyFormat), checks, combined, renderComments(comments, md), |
| 2530 | 2667 | reviewRows, files, diffTruncated, stat, commits, commitsTotal, branches, s.canEditItem(r, p.Repo, m.Author), |
| 2531 | 2668 | 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}) | |
| 2533 | 2670 | } |
| 2534 | 2671 | |
| 2535 | 2672 | // 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) { | ||
| 172 | 172 | } |
| 173 | 173 | } |
| 174 | 174 | } |
| 175 | ||
| 176 | func 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 | ||
| 224 | func 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>`, `<script>`, `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 | ||
| 273 | func 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) { | ||
| 76 | 76 | for _, m := range attrRe.FindAllStringSubmatch(clean, -1) { |
| 77 | 77 | for _, c := range strings.Fields(m[1]) { |
| 78 | 78 | 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 | } | |
| 79 | 92 | continue // composed at render time; the concrete values have rules |
| 80 | 93 | } |
| 81 | 94 | if !styled[c] { |
| @@ -83,6 +96,10 @@ func TestEveryTemplateClassHasARule(t *testing.T) { | ||
| 83 | 96 | } |
| 84 | 97 | } |
| 85 | 98 | } |
| 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 | } | |
| 86 | 103 | } |
| 87 | 104 | var names []string |
| 88 | 105 | for c := range missing { |
internal/web/static/app.js +690 −41 · view
| @@ -53,8 +53,9 @@ | ||
| 53 | 53 | if (pre.dataset.copyWired) continue; |
| 54 | 54 | pre.dataset.copyWired = '1'; |
| 55 | 55 | const code = pre.querySelector('code') || pre; |
| 56 | const rawText = code.textContent.trim(); | |
| 56 | 57 | const wrap = document.createElement('div'); |
| 57 | wrap.className = 'copywrap'; | |
| 58 | wrap.className = rawText.includes('\n') ? 'copywrap' : 'copywrap oneline'; | |
| 58 | 59 | pre.parentNode.insertBefore(wrap, pre); |
| 59 | 60 | wrap.appendChild(pre); |
| 60 | 61 | const btn = document.createElement('button'); |
| @@ -77,6 +78,38 @@ | ||
| 77 | 78 | } |
| 78 | 79 | |
| 79 | 80 | 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 | } | |
| 80 | 113 | const btn = e.target.closest('button[data-copy]'); |
| 81 | 114 | if (!btn) return; |
| 82 | 115 | const orig = btn.textContent; |
| @@ -124,17 +157,27 @@ | ||
| 124 | 157 | } |
| 125 | 158 | |
| 126 | 159 | 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)}"]`; | |
| 129 | 164 | } else if (form.closest('.identity')) { |
| 130 | 165 | swapSel = '.identity'; |
| 131 | 166 | } else if (form.closest('.aside .popover')) { |
| 132 | 167 | swapSel = '.aside'; |
| 168 | const openPop = form.closest('.aside .popover'); | |
| 169 | const allPops = Array.from(document.querySelectorAll('.aside .popover')); | |
| 170 | keepPopoverIdx = allPops.indexOf(openPop); | |
| 133 | 171 | } else if (form.dataset.notifForm) { |
| 134 | 172 | 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 | } | |
| 137 | 179 | } |
| 180 | if (!swapSel) return; | |
| 138 | 181 | e.preventDefault(); |
| 139 | 182 | const data = new FormData(form); |
| 140 | 183 | if (e.submitter && e.submitter.name) { |
| @@ -151,12 +194,29 @@ | ||
| 151 | 194 | if (!res.ok) { form.submit(); return; } |
| 152 | 195 | const html = await res.text(); |
| 153 | 196 | 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 | } | |
| 154 | 202 | const next = doc.querySelector(swapSel); |
| 155 | 203 | const cur = document.querySelector(swapSel); |
| 156 | 204 | if (next && cur) { |
| 205 | if (foldId) next.open = true; | |
| 157 | 206 | cur.replaceWith(next); |
| 158 | 207 | 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') { | |
| 160 | 220 | const nextBell = doc.querySelector('.rail a[href="/notifications"]'); |
| 161 | 221 | const curBell = document.querySelector('.rail a[href="/notifications"]'); |
| 162 | 222 | if (nextBell && curBell) curBell.replaceWith(nextBell); |
| @@ -187,7 +247,8 @@ | ||
| 187 | 247 | if (existing) existing.remove(); |
| 188 | 248 | |
| 189 | 249 | 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; | |
| 191 | 252 | const tr = document.createElement('tr'); |
| 192 | 253 | tr.id = 'inline-compose-row'; |
| 193 | 254 | tr.className = 'threadrow'; |
| @@ -208,25 +269,52 @@ | ||
| 208 | 269 | }; |
| 209 | 270 | form.append(hidden('path', cpath), hidden('line', cline), hidden('side', cside)); |
| 210 | 271 | |
| 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 | ||
| 218 | 272 | const pArea = document.createElement('p'); |
| 219 | 273 | const ta = document.createElement('textarea'); |
| 220 | 274 | ta.name = 'body'; |
| 221 | ta.rows = 3; | |
| 275 | ta.rows = 4; | |
| 222 | 276 | ta.placeholder = `Comment on ${cpath}:${cline}`; |
| 223 | 277 | ta.required = true; |
| 224 | 278 | pArea.appendChild(ta); |
| 225 | 279 | |
| 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 | ||
| 226 | 313 | const pAct = document.createElement('p'); |
| 227 | 314 | pAct.className = 'btngroup'; |
| 228 | 315 | const bNow = document.createElement('button'); |
| 229 | 316 | bNow.type = 'submit'; |
| 317 | bNow.className = 'btn'; | |
| 230 | 318 | bNow.textContent = 'Comment'; |
| 231 | 319 | const bPend = document.createElement('button'); |
| 232 | 320 | bPend.type = 'submit'; |
| @@ -248,7 +336,13 @@ | ||
| 248 | 336 | ta.focus(); |
| 249 | 337 | }); |
| 250 | 338 | |
| 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 | ||
| 252 | 346 | function collectCommands() { |
| 253 | 347 | const items = []; |
| 254 | 348 | const seen = new Set(); |
| @@ -263,6 +357,12 @@ | ||
| 263 | 357 | for (const a of document.querySelectorAll('.railpins .raildrop a')) { |
| 264 | 358 | add('Pinned', a.textContent.trim(), a.getAttribute('href')); |
| 265 | 359 | } |
| 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 | } | |
| 266 | 366 | add('Navigate', 'Dashboard', '/'); |
| 267 | 367 | add('Navigate', 'Explore repositories', '/explore'); |
| 268 | 368 | add('Navigate', 'Global search', '/search'); |
| @@ -272,31 +372,44 @@ | ||
| 272 | 372 | return items; |
| 273 | 373 | } |
| 274 | 374 | |
| 275 | function openPalette() { | |
| 375 | let paletteFetchTimer = 0; | |
| 376 | function openPalette(filesOnly = false) { | |
| 276 | 377 | const dlg = document.getElementById('cmdk'); |
| 277 | 378 | if (!(dlg instanceof HTMLDialogElement)) return; |
| 278 | 379 | const input = dlg.querySelector('input'); |
| 279 | 380 | const list = dlg.querySelector('ul'); |
| 280 | const all = collectCommands(); | |
| 381 | const ctx = currentRepoContext(); | |
| 382 | const localItems = filesOnly ? [] : collectCommands(); | |
| 383 | let remoteItems = []; | |
| 281 | 384 | let active = 0; |
| 282 | 385 | |
| 283 | 386 | const render = () => { |
| 284 | 387 | const raw = input.value.trim(); |
| 285 | 388 | 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 | } | |
| 287 | 397 | 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) }); | |
| 289 | 402 | } |
| 290 | active = Math.min(active, Math.max(0, filtered.length - 1)); | |
| 403 | active = Math.min(active, Math.max(0, merged.length - 1)); | |
| 291 | 404 | list.textContent = ''; |
| 292 | if (filtered.length === 0) { | |
| 405 | if (merged.length === 0) { | |
| 293 | 406 | const li = document.createElement('li'); |
| 294 | 407 | 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'; | |
| 296 | 409 | list.appendChild(li); |
| 297 | 410 | return; |
| 298 | 411 | } |
| 299 | filtered.forEach((it, idx) => { | |
| 412 | merged.slice(0, 50).forEach((it, idx) => { | |
| 300 | 413 | const li = document.createElement('li'); |
| 301 | 414 | const a = document.createElement('a'); |
| 302 | 415 | a.href = it.href; |
| @@ -312,12 +425,34 @@ | ||
| 312 | 425 | }); |
| 313 | 426 | }; |
| 314 | 427 | |
| 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…'; | |
| 315 | 444 | input.value = ''; |
| 316 | 445 | render(); |
| 446 | loadRemote(''); | |
| 317 | 447 | if (!dlg.open) dlg.showModal(); |
| 318 | 448 | input.focus(); |
| 319 | 449 | |
| 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 | }; | |
| 321 | 456 | input.onkeydown = (ev) => { |
| 322 | 457 | const links = list.querySelectorAll('a'); |
| 323 | 458 | if (ev.key === 'ArrowDown') { |
| @@ -333,14 +468,30 @@ | ||
| 333 | 468 | }; |
| 334 | 469 | } |
| 335 | 470 | |
| 471 | function openShortcutsHelp() { | |
| 472 | const dlg = document.getElementById('kbhelp'); | |
| 473 | if (dlg instanceof HTMLDialogElement && !dlg.open) dlg.showModal(); | |
| 474 | } | |
| 475 | ||
| 336 | 476 | document.addEventListener('click', (e) => { |
| 337 | 477 | if (e.target.closest('.cmdk-trigger')) { |
| 338 | 478 | e.preventDefault(); |
| 339 | openPalette(); | |
| 479 | openPalette(false); | |
| 340 | 480 | return; |
| 341 | 481 | } |
| 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 | } | |
| 344 | 495 | }); |
| 345 | 496 | |
| 346 | 497 | // ---- 6. Keyboard shortcuts ---- |
| @@ -367,6 +518,27 @@ | ||
| 367 | 518 | } |
| 368 | 519 | if (isTyping(e.target) || e.metaKey || e.ctrlKey || e.altKey) return; |
| 369 | 520 | |
| 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 | } | |
| 370 | 542 | if (e.key === '/') { |
| 371 | 543 | const search = document.querySelector('main input[type="search"], .railsearch input[type="search"]'); |
| 372 | 544 | if (search) { e.preventDefault(); search.focus(); return; } |
| @@ -408,6 +580,7 @@ | ||
| 408 | 580 | document.addEventListener('change', async (e) => { |
| 409 | 581 | const form = e.target.closest('form[data-autosave]'); |
| 410 | 582 | if (!(form instanceof HTMLFormElement)) return; |
| 583 | const prevTheme = document.documentElement.dataset.theme || 'system'; | |
| 411 | 584 | if (e.target.matches('[data-live-theme]')) { |
| 412 | 585 | const val = e.target.value; |
| 413 | 586 | if (val === 'system') delete document.documentElement.dataset.theme; |
| @@ -422,6 +595,24 @@ | ||
| 422 | 595 | credentials: 'same-origin', |
| 423 | 596 | }); |
| 424 | 597 | 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 | } | |
| 425 | 616 | showToast('Saved'); |
| 426 | 617 | } catch { |
| 427 | 618 | showToast('Save failed', true); |
| @@ -436,16 +627,58 @@ | ||
| 436 | 627 | if (inp.dataset.filterLinks) { |
| 437 | 628 | const box = inp.closest('.' + inp.dataset.filterLinks); |
| 438 | 629 | if (!box) return; |
| 630 | let shown = 0; | |
| 439 | 631 | 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; | |
| 441 | 649 | } |
| 442 | 650 | return; |
| 443 | 651 | } |
| 444 | 652 | 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'); | |
| 446 | 655 | 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; | |
| 449 | 682 | } |
| 450 | 683 | return; |
| 451 | 684 | } |
| @@ -453,9 +686,24 @@ | ||
| 453 | 686 | if (!list) return; |
| 454 | 687 | const ul = list.tagName === 'UL' ? list : list.querySelector('ul'); |
| 455 | 688 | 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)')) { | |
| 457 | 691 | 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; | |
| 459 | 707 | } |
| 460 | 708 | }); |
| 461 | 709 | |
| @@ -486,7 +734,8 @@ | ||
| 486 | 734 | } |
| 487 | 735 | }); |
| 488 | 736 | |
| 489 | // ---- 9b. Smooth in-place tab switching (profile tabs) ---- | |
| 737 | // ---- 9b. Smooth in-place tab switching (profile & list tabs) ---- | |
| 738 | let tabSwappedOnPage = false; | |
| 490 | 739 | document.addEventListener('click', async (e) => { |
| 491 | 740 | if (e.metaKey || e.ctrlKey || e.shiftKey || e.altKey || e.button !== 0) return; |
| 492 | 741 | const a = e.target.closest('nav[data-tab-swap] a'); |
| @@ -502,15 +751,35 @@ | ||
| 502 | 751 | const doc = new DOMParser().parseFromString(html, 'text/html'); |
| 503 | 752 | const next = doc.getElementById(targetId); |
| 504 | 753 | 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; | |
| 505 | 758 | cur.replaceWith(next); |
| 759 | if (doc.title) document.title = doc.title; | |
| 506 | 760 | history.pushState({ tabSwap: targetId }, '', a.href); |
| 507 | 761 | initCopyButtons(next); |
| 508 | 762 | } catch { |
| 509 | 763 | location.href = a.href; |
| 510 | 764 | } |
| 511 | 765 | }); |
| 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 | } | |
| 514 | 783 | }); |
| 515 | 784 | |
| 516 | 785 | // ---- 10. Scroll-spy on sticky section navs ---- |
| @@ -554,7 +823,7 @@ | ||
| 554 | 823 | else a.removeAttribute('aria-current'); |
| 555 | 824 | } |
| 556 | 825 | }; |
| 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'); | |
| 558 | 827 | show(initial); |
| 559 | 828 | for (const a of links) { |
| 560 | 829 | a.addEventListener('click', (e) => { |
| @@ -579,11 +848,391 @@ | ||
| 579 | 848 | if (e.target.id === 'imp-name') e.target.dataset.userEdited = e.target.value ? '1' : ''; |
| 580 | 849 | }); |
| 581 | 850 | |
| 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() { | |
| 585 | 1224 | initCopyButtons(); |
| 586 | 1225 | initScrollSpy(); |
| 587 | 1226 | 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(); | |
| 588 | 1237 | } |
| 589 | 1238 | })(); |
internal/web/static/style.css +332 −69 · view
| @@ -34,12 +34,14 @@ | ||
| 34 | 34 | scrollbars per scheme, and opt out of browser auto-darkening */ |
| 35 | 35 | color-scheme: light dark; |
| 36 | 36 | |
| 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; | |
| 40 | 42 | --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 */ | |
| 43 | 45 | --faint: #d8dce2; |
| 44 | 46 | |
| 45 | 47 | /* ink */ |
| @@ -57,11 +59,11 @@ | ||
| 57 | 59 | /* orange: where you are, what wants you. Two cuts because the floor |
| 58 | 60 | differs by size: --mark for bars, --warn at text size. */ |
| 59 | 61 | --mark: #e4572e; |
| 60 | --warn: #b8400f; | |
| 62 | --warn: #a8380b; | |
| 61 | 63 | |
| 62 | 64 | /* state */ |
| 63 | 65 | --ok: #0a7536; |
| 64 | --bad: #c62828; | |
| 66 | --bad: #b91c1c; | |
| 65 | 67 | --done: #6b21a8; |
| 66 | 68 | |
| 67 | 69 | /* diff row tints: enough to scan, light enough that the syntax |
| @@ -143,6 +145,8 @@ | ||
| 143 | 145 | color-scheme: dark; |
| 144 | 146 | |
| 145 | 147 | --canvas: #101114; |
| 148 | --card: #16181d; | |
| 149 | --card-line: #2d3139; | |
| 146 | 150 | --surface: #212429; |
| 147 | 151 | --inset: #0b0c0e; |
| 148 | 152 | --hover: #2b2f36; |
| @@ -476,8 +480,8 @@ footer a:hover { color: var(--link); } | ||
| 476 | 480 | /* ---- repository header ---- */ |
| 477 | 481 | .repohead { |
| 478 | 482 | 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); | |
| 481 | 485 | } |
| 482 | 486 | .repohead .wrap { max-width: calc(var(--container) + 2 * var(--sp-6)); margin: 0 auto; padding: 0 var(--sp-6); } |
| 483 | 487 | .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; } | ||
| 559 | 563 | .commithead p { margin: var(--sp-1) 0; } |
| 560 | 564 | .commithead h2 { margin-top: 0; margin-bottom: var(--sp-1); } |
| 561 | 565 | |
| 562 | nav.filters { display: inline-flex; gap: var(--sp-2); flex-wrap: wrap; } | |
| 563 | nav.filters a { | |
| 566 | nav.filters, nav.statebar { display: inline-flex; gap: var(--sp-2); flex-wrap: wrap; } | |
| 567 | nav.statebar { margin: 0 0 var(--sp-3); } | |
| 568 | nav.filters a, nav.statebar a { | |
| 564 | 569 | display: inline-flex; |
| 565 | 570 | align-items: center; |
| 566 | 571 | height: 32px; |
| 567 | 572 | 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); | |
| 570 | 575 | border-radius: var(--r-ctl); |
| 571 | color: var(--fg); | |
| 576 | color: var(--muted); | |
| 572 | 577 | font-size: var(--fs-2); |
| 573 | 578 | font-weight: 500; |
| 579 | text-decoration: none; | |
| 580 | } | |
| 581 | nav.filters a:hover, nav.statebar a:hover { background: var(--hover); color: var(--fg); text-decoration: none; } | |
| 582 | nav.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; | |
| 574 | 587 | } |
| 575 | nav.filters a:hover { background: var(--hover); text-decoration: none; } | |
| 576 | nav.filters a.active { background: var(--surface); border-color: var(--link); color: var(--link); } | |
| 577 | 588 | |
| 578 | 589 | form.searchform, form.logfilter, form.compareform { |
| 579 | 590 | display: flex; |
| @@ -609,7 +620,7 @@ button, .button { | ||
| 609 | 620 | } |
| 610 | 621 | button:hover, .button.primary:hover { filter: brightness(1.12); text-decoration: none; } |
| 611 | 622 | button.btn, .button.btn { |
| 612 | background: var(--canvas); | |
| 623 | background: var(--card); | |
| 613 | 624 | color: var(--fg); |
| 614 | 625 | border-color: var(--line); |
| 615 | 626 | filter: none; |
| @@ -857,12 +868,13 @@ ul.plain li > form:first-of-type { margin-left: auto; } | ||
| 857 | 868 | .notice { border-left-color: var(--ok); background: color-mix(in srgb, var(--ok) 6%, transparent); } |
| 858 | 869 | .empty-note, .none, .empty, li.empty, td.empty { color: var(--muted); } |
| 859 | 870 | |
| 860 | /* ---- containers: calm hairline borders and clean surfaces ---- */ | |
| 871 | /* ---- containers: crisp elevated card surfaces ---- */ | |
| 861 | 872 | .card, ul.list, ul.loglist, ul.repolist, ul.issuelist, |
| 862 | 873 | ul.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); | |
| 865 | 876 | border-radius: var(--r-card); |
| 877 | box-shadow: 0 1px 2px rgb(0 0 0 / 0.03); | |
| 866 | 878 | overflow: hidden; |
| 867 | 879 | } |
| 868 | 880 | .cardhead { |
| @@ -897,7 +909,7 @@ tbody tr:hover td { background: var(--hover); } | ||
| 897 | 909 | /* every header row a template writes, by the class it or its table |
| 898 | 910 | carries: TestHeaderRowsAreLeftAligned reads these selectors */ |
| 899 | 911 | tr.cols th, table.tree th, table.refs th, table.keys th, table.assets th { text-align: left; } |
| 900 | tr.cols th { background: var(--canvas); } | |
| 912 | tr.cols th { background: var(--card); } | |
| 901 | 913 | /* right-aligned columns keep their header with their values */ |
| 902 | 914 | tr.cols th.age, tr.cols th.size { text-align: right; } |
| 903 | 915 | /* 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; } | ||
| 905 | 917 | .tablewrap { overflow-x: auto; max-width: 100%; } |
| 906 | 918 | |
| 907 | 919 | table.tree, table.refs { |
| 908 | background: var(--canvas); | |
| 909 | border: 1px solid var(--faint); | |
| 920 | background: var(--card); | |
| 921 | border: 1px solid var(--card-line); | |
| 910 | 922 | border-radius: var(--r-card); |
| 923 | box-shadow: 0 1px 2px rgb(0 0 0 / 0.03); | |
| 911 | 924 | /* collapsed borders defeat a radius on the table itself */ |
| 912 | 925 | border-collapse: separate; |
| 913 | 926 | border-spacing: 0; |
| @@ -1203,7 +1216,7 @@ pre.matchline mark { background: color-mix(in srgb, var(--mark) 25%, transparent | ||
| 1203 | 1216 | p.pager { margin-top: var(--sp-4); } |
| 1204 | 1217 | .snippetfile { margin-bottom: var(--sp-5); } |
| 1205 | 1218 | p.filefacts { color: var(--muted); font-size: var(--fs-1); margin: 0 0 var(--sp-3); } |
| 1206 | pre.buildlog { max-height: 40rem; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; } | |
| 1219 | pre.buildlog { overflow-x: auto; white-space: pre-wrap; overflow-wrap: anywhere; } | |
| 1207 | 1220 | details.buildstep pre.buildlog { margin: 0; border: 0; border-radius: 0; } |
| 1208 | 1221 | details.buildstep summary code { overflow-wrap: anywhere; } |
| 1209 | 1222 | |
| @@ -1327,7 +1340,8 @@ form.actions select, form.actions textarea { width: 100%; } | ||
| 1327 | 1340 | /* ---- comments and threads ---- */ |
| 1328 | 1341 | article.comment { |
| 1329 | 1342 | max-width: 48rem; |
| 1330 | border: 1px solid var(--line); | |
| 1343 | background: var(--card); | |
| 1344 | border: 1px solid var(--card-line); | |
| 1331 | 1345 | border-radius: var(--r-card); |
| 1332 | 1346 | margin: var(--sp-4) 0; |
| 1333 | 1347 | overflow: hidden; |
| @@ -1699,6 +1713,7 @@ a.memberchip .role { color: var(--muted); } | ||
| 1699 | 1713 | .sidedrop:not(:has(.grp)) { display: none; } |
| 1700 | 1714 | |
| 1701 | 1715 | @media (min-width: 62.01rem) { |
| 1716 | .withcol:has(.statebar) .sidecol .grp-state { display: none; } | |
| 1702 | 1717 | @supports selector(::details-content) { |
| 1703 | 1718 | .sidedrop > summary { display: none; } |
| 1704 | 1719 | .sidedrop::details-content { content-visibility: visible; } |
| @@ -1995,21 +2010,16 @@ svg.icon { vertical-align: -0.125em; } | ||
| 1995 | 2010 | ul.loglist .commitside { width: 100%; justify-content: flex-start; } |
| 1996 | 2011 | } |
| 1997 | 2012 | |
| 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. */ | |
| 2006 | 2015 | @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; } | |
| 2011 | 2017 | a.brand { width: var(--rail-hit); } |
| 2012 | 2018 | } |
| 2019 | .railpins-mob { display: none; } | |
| 2020 | @media (max-width: 44rem) { | |
| 2021 | .railpins-mob { display: block; } | |
| 2022 | } | |
| 2013 | 2023 | |
| 2014 | 2024 | /* ---- reactions ---- */ |
| 2015 | 2025 | .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 { | ||
| 2021 | 2031 | padding: 0 var(--sp-2); |
| 2022 | 2032 | min-height: 24px; |
| 2023 | 2033 | border: 1px solid var(--line); |
| 2024 | border-radius: var(--r-sm); | |
| 2034 | border-radius: var(--r-ctl); | |
| 2025 | 2035 | background: transparent; |
| 2026 | 2036 | color: var(--muted); |
| 2027 | 2037 | } |
| 2028 | 2038 | button.react { cursor: pointer; } |
| 2029 | 2039 | button.react:hover { background: var(--surface); } |
| 2030 | button.react.mine { border-color: var(--accent); background: var(--surface); color: var(--fg); } | |
| 2040 | button.react.mine { border-color: var(--link); background: var(--surface); color: var(--fg); } | |
| 2031 | 2041 | |
| 2032 | 2042 | /* ---- rail pinned switcher ---- */ |
| 2033 | 2043 | .railusermenu, .railcreate { position: relative; } |
| @@ -2139,28 +2149,48 @@ button.react.mine { border-color: var(--accent); background: var(--surface); col | ||
| 2139 | 2149 | font-weight: 600; |
| 2140 | 2150 | } |
| 2141 | 2151 | |
| 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; | |
| 2148 | 2161 | } |
| 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; | |
| 2153 | 2174 | border-radius: var(--r-ctl); |
| 2154 | color: var(--muted); | |
| 2155 | text-decoration: none; | |
| 2175 | text-align: left; | |
| 2176 | white-space: normal; | |
| 2177 | filter: none; | |
| 2156 | 2178 | } |
| 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); | |
| 2161 | 2186 | font-weight: 600; |
| 2187 | padding: 0 6px; | |
| 2188 | border-radius: var(--r-ctl); | |
| 2162 | 2189 | background: var(--surface); |
| 2190 | color: var(--muted); | |
| 2191 | font-variant-numeric: tabular-nums; | |
| 2163 | 2192 | } |
| 2193 | .filter-empty { color: var(--muted); } | |
| 2164 | 2194 | |
| 2165 | 2195 | /* ---- sidebar group headers & floating popovers ---- */ |
| 2166 | 2196 | .grp-head { |
| @@ -2193,8 +2223,8 @@ button.react.mine { border-color: var(--accent); background: var(--surface); col | ||
| 2193 | 2223 | width: 16rem; |
| 2194 | 2224 | max-width: 85vw; |
| 2195 | 2225 | 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); | |
| 2198 | 2228 | border-radius: var(--r-card); |
| 2199 | 2229 | box-shadow: var(--shadow); |
| 2200 | 2230 | display: flex; |
| @@ -2299,22 +2329,25 @@ dialog.cmdk::backdrop { background: rgb(0 0 0 / 0.45); } | ||
| 2299 | 2329 | } |
| 2300 | 2330 | .cmdk-empty { padding: var(--sp-4); color: var(--muted); text-align: center; font-size: var(--fs-2); } |
| 2301 | 2331 | |
| 2302 | /* ---- copy button on clone blocks ---- */ | |
| 2332 | /* ---- copy button on code & clone blocks ---- */ | |
| 2303 | 2333 | .copywrap { position: relative; } |
| 2304 | 2334 | .copywrap pre { padding-right: 4.5rem; } |
| 2305 | 2335 | .copybtn { |
| 2306 | 2336 | position: absolute; |
| 2307 | top: 50%; | |
| 2337 | top: 6px; | |
| 2308 | 2338 | right: var(--sp-2); |
| 2309 | transform: translateY(-50%); | |
| 2310 | 2339 | height: 24px; |
| 2311 | 2340 | padding: 0 var(--sp-2); |
| 2312 | 2341 | font-size: var(--fs-0); |
| 2313 | 2342 | background: var(--surface); |
| 2314 | 2343 | color: var(--fg); |
| 2315 | border: 1px solid var(--faint); | |
| 2344 | border: 1px solid var(--card-line); | |
| 2316 | 2345 | border-radius: var(--r-ctl); |
| 2317 | 2346 | } |
| 2347 | .copywrap.oneline .copybtn { | |
| 2348 | top: 50%; | |
| 2349 | transform: translateY(-50%); | |
| 2350 | } | |
| 2318 | 2351 | .copybtn:hover { background: var(--hover); filter: none; } |
| 2319 | 2352 | |
| 2320 | 2353 | @media (max-width: 44rem) { |
| @@ -2324,9 +2357,10 @@ dialog.cmdk::backdrop { background: rgb(0 0 0 / 0.45); } | ||
| 2324 | 2357 | |
| 2325 | 2358 | /* ---- account & admin redesign ---- */ |
| 2326 | 2359 | .setcard, section.activity { |
| 2327 | background: var(--canvas); | |
| 2328 | border: 1px solid var(--faint); | |
| 2360 | background: var(--card); | |
| 2361 | border: 1px solid var(--card-line); | |
| 2329 | 2362 | border-radius: var(--r-card); |
| 2363 | box-shadow: 0 1px 2px rgb(0 0 0 / 0.03); | |
| 2330 | 2364 | padding: var(--sp-5); |
| 2331 | 2365 | margin: 0 0 var(--sp-5); |
| 2332 | 2366 | } |
| @@ -2364,6 +2398,8 @@ nav.admintabs { | ||
| 2364 | 2398 | .tablefilter { min-width: 14rem; } |
| 2365 | 2399 | pre.copyable { margin: var(--sp-2) 0 0; } |
| 2366 | 2400 | html.js form[data-autosave] button[type="submit"] { display: none; } |
| 2401 | html.js form.setform[data-autosave] { grid-template-columns: minmax(14rem, 1fr) minmax(0, 28rem); } | |
| 2402 | html.js form.setform[data-autosave] > div:has(> button[type="submit"]) { display: none; } | |
| 2367 | 2403 | .toast { |
| 2368 | 2404 | position: fixed; |
| 2369 | 2405 | right: var(--sp-5); |
| @@ -2385,9 +2421,10 @@ html.js form[data-autosave] button[type="submit"] { display: none; } | ||
| 2385 | 2421 | |
| 2386 | 2422 | /* ---- dashboard & profile polish ---- */ |
| 2387 | 2423 | .dashpins, .feedcol { |
| 2388 | background: var(--canvas); | |
| 2389 | border: 1px solid var(--faint); | |
| 2424 | background: var(--card); | |
| 2425 | border: 1px solid var(--card-line); | |
| 2390 | 2426 | border-radius: var(--r-card); |
| 2427 | box-shadow: 0 1px 2px rgb(0 0 0 / 0.03); | |
| 2391 | 2428 | padding: var(--sp-4); |
| 2392 | 2429 | } |
| 2393 | 2430 | .dashcard-head { |
| @@ -2410,9 +2447,10 @@ html.js form[data-autosave] button[type="submit"] { display: none; } | ||
| 2410 | 2447 | margin: 0 0 var(--sp-2); |
| 2411 | 2448 | } |
| 2412 | 2449 | .profilecard { |
| 2413 | background: var(--canvas); | |
| 2414 | border: 1px solid var(--faint); | |
| 2450 | background: var(--card); | |
| 2451 | border: 1px solid var(--card-line); | |
| 2415 | 2452 | border-radius: var(--r-card); |
| 2453 | box-shadow: 0 1px 2px rgb(0 0 0 / 0.03); | |
| 2416 | 2454 | padding: var(--sp-5); |
| 2417 | 2455 | margin-bottom: var(--sp-4); |
| 2418 | 2456 | } |
| @@ -2478,9 +2516,10 @@ ul.issuelist li.unread { | ||
| 2478 | 2516 | font-size: var(--fs-1); |
| 2479 | 2517 | } |
| 2480 | 2518 | .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); | |
| 2483 | 2521 | border-radius: var(--r-card); |
| 2522 | box-shadow: 0 1px 2px rgb(0 0 0 / 0.03); | |
| 2484 | 2523 | padding: var(--sp-4); |
| 2485 | 2524 | } |
| 2486 | 2525 | .popform-stack { |
| @@ -2534,3 +2573,227 @@ article.release.setcard { | ||
| 2534 | 2573 | font-weight: 600; |
| 2535 | 2574 | } |
| 2536 | 2575 | .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 | } | |
| 2615 | details.difffold { overflow: visible; } | |
| 2616 | details.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 | } | |
| 2623 | details.difffold:not([open]) > summary { border-radius: var(--r-card); } | |
| 2624 | details.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); } | |
| 2682 | article.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); } | |
| 2685 | dialog.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; } } | |
| 2691 | dl.kblist { margin: 0; display: flex; flex-direction: column; gap: var(--sp-2); font-size: var(--fs-2); } | |
| 2692 | dl.kblist > div { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); } | |
| 2693 | dl.kblist dt { font-family: var(--mono); font-size: var(--fs-0); } | |
| 2694 | dl.kblist dd { margin: 0; color: var(--muted); text-align: right; } | |
| 2695 | kbd { | |
| 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 | } | |
| 2766 | html.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 @@ | ||
| 22 | 22 | <li><a href="#notifications">Notifications</a></li> |
| 23 | 23 | <li><a href="#appearance">Appearance</a></li> |
| 24 | 24 | <li><a href="#tokens">API tokens</a></li> |
| 25 | <li><a href="#sessions">Browser sessions</a></li> | |
| 25 | 26 | <li><a href="#export">Export</a></li> |
| 26 | 27 | <li><a href="#cli">On the command line</a></li> |
| 27 | 28 | <li><a href="#delete">Delete account</a></li> |
| @@ -56,12 +57,14 @@ Write it with a push, or edit it here.</p> | ||
| 56 | 57 | <p class="meta">Your keys are your identity here. A <code>full</code> key can run |
| 57 | 58 | commands and push; a <code>git</code> key can only move git data (e.g., CI).</p> |
| 58 | 59 | {{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> | |
| 60 | 61 | {{range .Keys}}<tr> |
| 61 | 62 | <td>{{.Label}}</td> |
| 62 | 63 | <td class="mono">{{.Fingerprint}}</td> |
| 63 | 64 | <td>{{.Algo}}</td> |
| 64 | 65 | <td><span class="chip">{{.Scope}}</span></td> |
| 66 | <td>{{if .LastUsed}}{{when .LastUsed}}{{else}}never{{end}}</td> | |
| 67 | <td>{{.Expires}}</td> | |
| 65 | 68 | <td class="act"><details class="popover"><summary class="popbtn popbtn-danger">Remove</summary><div class="popmenu"> |
| 66 | 69 | <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> |
| 67 | 70 | </div></details></td> |
| @@ -81,6 +84,8 @@ commands and push; a <code>git</code> key can only move git data (e.g., CI).</p> | ||
| 81 | 84 | <option value="full">full: commands and git</option> |
| 82 | 85 | <option value="git">git: git transport only</option> |
| 83 | 86 | </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"> | |
| 84 | 89 | <span class="btngroup"><button type="submit">Add key</button></span> |
| 85 | 90 | </form> |
| 86 | 91 | </details> |
| @@ -241,6 +246,29 @@ account and where notifications go.</p> | ||
| 241 | 246 | </details> |
| 242 | 247 | </section> |
| 243 | 248 | |
| 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 | ||
| 244 | 272 | <section id="export" class="setcard"><h2>Export</h2> |
| 245 | 273 | <p class="meta">Your profile, repositories, issues and merge requests as one JSON bundle, matching <code>gitbay auth export</code>. Keys are excluded.</p> |
| 246 | 274 | <p><a class="button btn" href="/settings/export">Download bundle</a></p> |
internal/web/templates/blame.html +2 −2 · view
| @@ -20,9 +20,9 @@ | ||
| 20 | 20 | {{range .Hunks}}<div class="blamehunk"> |
| 21 | 21 | <div class="blameinfo"> |
| 22 | 22 | <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> | |
| 24 | 24 | </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}} | |
| 26 | 26 | {{end}}</pre> |
| 27 | 27 | </div> |
| 28 | 28 | {{else}}<p class="empty-note">empty file</p>{{end}} |
internal/web/templates/blob.html +3 −1 · view
| @@ -4,7 +4,7 @@ | ||
| 4 | 4 | <h1 class="vh">{{.Path}}</h1> |
| 5 | 5 | <div class="blobgrid"> |
| 6 | 6 | {{template "filenav" .Nav}} |
| 7 | <div class="blobmain"> | |
| 7 | <div class="blobmain" data-commit="{{.Commit}}" data-permalink="/{{.Repo.OwnerName}}/{{.Repo.Name}}/blob/{{.Commit}}/{{.Path}}"> | |
| 8 | 8 | <div class="pathbar"> |
| 9 | 9 | {{template "refmenu" .}} |
| 10 | 10 | <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 @@ | ||
| 13 | 13 | {{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}} |
| 14 | 14 | <a class="button btn" href="/{{.Repo.OwnerName}}/{{.Repo.Name}}/log/{{.Ref}}?path={{.Path}}">history</a> |
| 15 | 15 | {{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}} | |
| 16 | 17 | <a class="button btn" href="/{{.Repo.OwnerName}}/{{.Repo.Name}}/raw/{{.Ref}}/{{.Path}}">raw</a> |
| 17 | 18 | {{if .Viewer}}<a class="button" href="/{{.Repo.OwnerName}}/{{.Repo.Name}}/edit/{{.Ref}}/{{.Path}}">edit</a>{{end}} |
| 18 | 19 | </div> |
| 19 | 20 | </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}} | |
| 20 | 22 | <p class="filefacts">{{if .Lines}}{{.Lines}} lines · {{end}}{{.Size}} bytes{{if .Exec}} · executable{{end}}{{if .Symlink}} · symlink{{end}}</p> |
| 21 | 23 | {{if .Symbols}}<details class="symlist"><summary>{{len .Symbols}} symbol{{if ne (len .Symbols) 1}}s{{end}} in this file</summary> |
| 22 | 24 | <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 @@ | ||
| 8 | 8 | <span class="spacer"></span> |
| 9 | 9 | <div class="btngroup"> |
| 10 | 10 | {{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}} | |
| 11 | 17 | {{if and .CanWrite (or (eq .Build.Status "pending") (eq .Build.Status "running"))}} |
| 12 | 18 | <form method="post" action="/{{.Repo.OwnerName}}/{{.Repo.Name}}/builds/{{.Build.Number}}/cancel" class="inline"> |
| 13 | 19 | <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 @@ | ||
| 21 | 27 | {{else if .Steps}}{{$total := len .Build.Steps}}{{range .Steps}} |
| 22 | 28 | <details class="difffold buildstep"{{if .Failed}} id="failed" open{{end}}> |
| 23 | 29 | <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> | |
| 25 | 31 | </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}} | |
| 27 | 33 | </div> |
| 28 | 34 | {{end}} |
internal/web/templates/commit.html +1 −1 · view
| @@ -15,5 +15,5 @@ | ||
| 15 | 15 | <pre class="message" tabindex="0">{{.Message}}</pre> |
| 16 | 16 | </div> |
| 17 | 17 | {{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}} | |
| 19 | 19 | {{end}} |
internal/web/templates/compare.html +1 −1 · view
| @@ -18,5 +18,5 @@ | ||
| 18 | 18 | </ul>{{else}}<p class="empty-note"><code>{{.Head}}</code> has nothing that <code>{{.Base}}</code> does not.</p>{{end}} |
| 19 | 19 | {{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> |
| 20 | 20 | {{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}} | |
| 22 | 22 | {{end}} |
internal/web/templates/dashboard.html +1 · view
| @@ -23,6 +23,7 @@ | ||
| 23 | 23 | <div class="pagehead"> |
| 24 | 24 | <h1>Dashboard</h1> |
| 25 | 25 | <span class="grow"></span> |
| 26 | <a class="button btn" href="/{{.Viewer}}/-/queries">Saved queries</a> | |
| 26 | 27 | <button type="button" class="btn" data-refresh="/" data-refresh-target="dash-root">Refresh</button> |
| 27 | 28 | <a class="button" href="/new">New repository</a> |
| 28 | 29 | </div> |
internal/web/templates/edit.html +3 −1 · view
| @@ -12,13 +12,15 @@ | ||
| 12 | 12 | {{if .Error}}<p class="error" role="alert">{{.Error}}</p>{{end}} |
| 13 | 13 | {{if .Blocked}}<p class="empty-note">{{.Blocked}}</p>{{else}} |
| 14 | 14 | <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}} | |
| 15 | 16 | {{if .Creating}}<p class="meta"><code>{{.Path}}</code> does not exist on {{.Ref}}; committing creates it.</p>{{end}} |
| 16 | 17 | {{if .Draft.Is "content"}}{{template "previewblock" .Draft.HTML}}{{end}} |
| 17 | 18 | <form method="post" action="/{{.Repo.OwnerName}}/{{.Repo.Name}}/edit/{{.Ref}}/{{.Path}}" class="editform"> |
| 18 | 19 | <p><textarea name="content" aria-label="File contents" rows="24" spellcheck="false">{{.Content}}</textarea></p> |
| 19 | 20 | <div class="commitbar"> |
| 20 | 21 | <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> | |
| 22 | 24 | {{if .Markup}}{{template "previewbtn"}}{{end}} |
| 23 | 25 | </div> |
| 24 | 26 | <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 @@ | ||
| 36 | 36 | {{/* the kind in the words the CLI prints, so a hit reads the same in |
| 37 | 37 | both places; it is why the meta no longer says "repository" */}} |
| 38 | 38 | <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}} | |
| 40 | 40 | </li> |
| 41 | 41 | {{end}} |
| 42 | 42 | </ul> |
internal/web/templates/issue.html +9 −9 · view
| @@ -5,13 +5,13 @@ | ||
| 5 | 5 | <a href="/{{.Issue.Author}}">{{.Issue.Author}}</a> opened this on {{when .Issue.CreatedAt}} |
| 6 | 6 | {{if .Issue.Labels}} · {{range .Issue.Labels}}<a class="chip label" style="{{index $.LabelColors .}}" href="/{{$.Repo.OwnerName}}/{{$.Repo.Name}}/issues?label={{.}}">{{.}}</a> {{end}}{{end}} |
| 7 | 7 | {{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> | |
| 9 | 9 | {{if .Notice}}<p class="error" role="alert">{{.Notice}}</p>{{end}} |
| 10 | 10 | |
| 11 | 11 | <div class="withaside"> |
| 12 | 12 | <div class="mainside"> |
| 13 | 13 | <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> | |
| 15 | 15 | {{if .Draft.Is "edit"}}{{template "previewblock" .Draft.HTML}}{{end}} |
| 16 | 16 | <form method="post" action="/{{.Repo.OwnerName}}/{{.Repo.Name}}/issues/{{.Issue.Number}}/edit" class="commentform"> |
| 17 | 17 | <p><input type="text" name="title" aria-label="Title" value="{{.Draft.Or "edit" "title" .Issue.Title}}" required></p> |
| @@ -19,15 +19,15 @@ | ||
| 19 | 19 | <p><input type="text" name="labels" aria-label="Labels" value="{{$.Draft.Or "edit" "labels" (join .Issue.Labels " ")}}" placeholder="labels, space-separated (write access)"></p> |
| 20 | 20 | <p><button type="submit" class="btn">Save</button> {{template "previewbtn"}}</p> |
| 21 | 21 | </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> | |
| 24 | 24 | <div class="rendered">{{.BodyHTML}}</div> |
| 25 | 25 | {{template "reactions" index .Reactions 0}} |
| 26 | 26 | </article>{{else}}{{template "reactions" index .Reactions 0}}{{end}} |
| 27 | 27 | {{range .Comments}} |
| 28 | 28 | {{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> | |
| 31 | 31 | <div class="rendered">{{.BodyHTML}}</div> |
| 32 | 32 | {{template "reactions" index $.Reactions .ID}} |
| 33 | 33 | </article>{{end}} |
| @@ -35,8 +35,8 @@ | ||
| 35 | 35 | {{if .Viewer}} |
| 36 | 36 | {{if .Draft.Is "comment"}}{{template "previewblock" .Draft.HTML}}{{end}} |
| 37 | 37 | <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> | |
| 40 | 40 | </form> |
| 41 | 41 | {{end}} |
| 42 | 42 | </div> |
| @@ -87,7 +87,7 @@ | ||
| 87 | 87 | </form> |
| 88 | 88 | </div></details>{{end}} |
| 89 | 89 | </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> | |
| 91 | 91 | {{else}}<p class="none">None</p>{{end}} |
| 92 | 92 | </div> |
| 93 | 93 | {{if .CanEdit}} |
internal/web/templates/issues.html +13 −3 · view
| @@ -12,6 +12,14 @@ | ||
| 12 | 12 | <input type="hidden" name="state" value="{{.State}}"> |
| 13 | 13 | </form> |
| 14 | 14 | {{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}}&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}}&assignee={{urlquery .}}">{{.}}</a>{{end}}</div> | |
| 21 | </div></details> | |
| 22 | {{end}}{{end}} | |
| 15 | 23 | <span class="spacer"></span> |
| 16 | 24 | <div class="btngroup"> |
| 17 | 25 | <a class="button btn" href="/{{.Repo.OwnerName}}/{{.Repo.Name}}/milestones">Milestones</a> |
| @@ -21,13 +29,15 @@ | ||
| 21 | 29 | </div> |
| 22 | 30 | {{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}} |
| 23 | 31 | <ul class="issuelist rows"> |
| 24 | {{range .Issues}}<li> | |
| 32 | {{range $iss := .Issues}}<li> | |
| 25 | 33 | <div class="issuemain"> |
| 26 | 34 | <p class="title"><a href="/{{$.Repo.OwnerName}}/{{$.Repo.Name}}/issues/{{.Number}}">{{.Title}}</a> |
| 27 | 35 | {{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}}&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}} | |
| 29 | 40 | </div> |
| 30 | {{if eq $.State "all"}}<span class="chip {{if eq .State "open"}}chip-open{{else}}chip-done{{end}}">{{.State}}</span>{{end}} | |
| 31 | 41 | </li> |
| 32 | 42 | {{else}}{{if .Query}}<li class="empty">no {{if ne .State "all"}}{{.State}} {{end}}issues matching “{{.Query}}”</li> |
| 33 | 43 | {{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 @@ | ||
| 35 | 35 | </form> |
| 36 | 36 | <span class="railgap"></span> |
| 37 | 37 | <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> | |
| 38 | 39 | {{if .Viewer}} |
| 39 | 40 | <details class="railcreate"> |
| 40 | 41 | <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 @@ | ||
| 42 | 43 | <a href="/new#create">{{template "icon" "plus"}} New repository</a> |
| 43 | 44 | <a href="/new#import">{{template "icon" "file"}} Import repository</a> |
| 44 | 45 | <a href="/new#org">{{template "icon" "person"}} New organization</a> |
| 46 | <a href="/{{.Viewer}}/-/snippets/new">{{template "icon" "snippet"}} New snippet</a> | |
| 45 | 47 | </div> |
| 46 | 48 | </details> |
| 47 | 49 | {{template "raillink" dict "Href" "/notifications" "Icon" "bell" "Name" "Notifications" "Current" (eq (str . "Tab") "notifications") "Count" .Rail.Unread}} |
| @@ -50,7 +52,10 @@ | ||
| 50 | 52 | <div class="raildrop"> |
| 51 | 53 | <a class="railuser" href="/{{.Viewer}}">{{template "icon" "person"}} <span><strong>{{.Viewer}}</strong></span></a> |
| 52 | 54 | <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}} | |
| 54 | 59 | <hr class="railsep"> |
| 55 | 60 | {{$settings := index $items 1}}<a{{if $settings.Current}} aria-current="page"{{end}} href="{{$settings.Href}}">{{template "icon" $settings.Icon}} {{$settings.Name}}</a> |
| 56 | 61 | {{$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 @@ | ||
| 67 | 72 | <header class="repohead"> |
| 68 | 73 | <div class="wrap"> |
| 69 | 74 | {{$top := topTab (str $ "Tab")}} |
| 70 | <div class="identity"> | |
| 75 | <div class="identity" data-repo="{{.OwnerName}}/{{.Name}}" data-ref="{{or (str $ "Ref") .DefaultBranch}}"> | |
| 71 | 76 | {{if field $ "RepoHome"}}<h1 class="repotitle"><a class="owner" href="/{{.OwnerName}}">{{.OwnerName}}</a><span class="sep">/</span>{{.Name}}</h1> |
| 72 | 77 | {{else}}<p class="repotitle"><a class="owner" href="/{{.OwnerName}}">{{.OwnerName}}</a><span class="sep">/</span><a href="/{{.OwnerName}}/{{.Name}}">{{.Name}}</a></p>{{end}} |
| 73 | 78 | {{if eq .Visibility "private"}}<span class="chip">Private</span>{{end}} |
| @@ -76,10 +81,14 @@ | ||
| 76 | 81 | with the name so the header is two rows on every page. */}} |
| 77 | 82 | {{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}} |
| 78 | 83 | <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}} | |
| 83 | 92 | </div> |
| 84 | 93 | {{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}} |
| 85 | 94 | {{/* A tab's own count badge is omitted at zero (an empty <i> reads as |
| @@ -111,10 +120,41 @@ | ||
| 111 | 120 | </div> |
| 112 | 121 | <dialog id="cmdk" class="cmdk" aria-label="Jump to"> |
| 113 | 122 | <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…"> | |
| 115 | 124 | <ul class="cmdk-list"></ul> |
| 116 | 125 | </div> |
| 117 | 126 | </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 & 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 & 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> | |
| 118 | 158 | </body> |
| 119 | 159 | </html>{{end}} |
| 120 | 160 | |
| @@ -137,6 +177,12 @@ | ||
| 137 | 177 | {{- 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"/> |
| 138 | 178 | {{- 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"/> |
| 139 | 179 | {{- 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"/> | |
| 140 | 186 | {{- end}}</svg>{{end}} |
| 141 | 187 | |
| 142 | 188 | {{/* raillink draws one square in the rail: the icon, the name for a |
| @@ -179,7 +225,7 @@ | ||
| 179 | 225 | {{define "sidecol"}}<nav class="sidecol" aria-label="Filters"> |
| 180 | 226 | <details class="sidedrop"> |
| 181 | 227 | <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}}"> | |
| 183 | 229 | <h2 class="colhead">{{.Title}}</h2> |
| 184 | 230 | <ul>{{range .Items}}<li><a{{if .Active}} aria-current="page"{{end}} href="{{.Href}}">{{.Label}}{{if .Count}} <i>{{.Count}}</i>{{end}}</a></li>{{end}}</ul> |
| 185 | 231 | </div>{{end}}{{end}} |
| @@ -208,7 +254,7 @@ | ||
| 208 | 254 | hands the page back instead of writing (#235). */}} |
| 209 | 255 | {{/* reactions is one item's reaction bar (reactionBar in httpd). A |
| 210 | 256 | 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}} | |
| 212 | 258 | {{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> |
| 213 | 259 | {{end}}</form>{{else}}<p class="reactions">{{range .Items}}<span class="react" aria-label="{{.Label}}">{{.Emoji}} {{.Count}}</span> {{end}}</p>{{end}}{{end}}{{end}} |
| 214 | 260 | |
| @@ -229,21 +275,25 @@ | ||
| 229 | 275 | line-number gutters and review threads inline. Base is the MR's |
| 230 | 276 | endpoint and Viewer the signed-in account; the commit page passes |
| 231 | 277 | 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}}> | |
| 234 | 281 | {{if gt (len .Files) 1}}<details class="difftoc" open> |
| 235 | 282 | <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> | |
| 237 | 285 | </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}}> | |
| 239 | 288 | <summary> |
| 240 | 289 | <span class="fpath">{{if eq .Status "renamed"}}<span class="was">{{.OldPath}} →</span> {{end}}{{.Path}}</span> |
| 241 | 290 | {{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> | |
| 243 | 293 | </summary> |
| 244 | 294 | {{if .Binary}}<p class="none">Binary file not shown.</p> |
| 245 | 295 | {{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> | |
| 247 | 297 | {{else if eq .Kind "meta"}}<tr class="dmeta"><td class="ln"></td><td class="src" colspan="3">{{.Text}}</td></tr> |
| 248 | 298 | {{else}}{{$r := .}}<tr class="pair"> |
| 249 | 299 | {{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 @@ | ||
| 263 | 313 | {{end}}{{end}}{{end}} |
| 264 | 314 | </table></div> |
| 265 | 315 | {{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> | |
| 267 | 317 | {{else if eq .Class "meta"}}<tr class="dmeta"><td class="ln" colspan="2"></td><td class="src">{{.Text}}</td></tr> |
| 268 | 318 | {{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> |
| 269 | 319 | {{if .Compose}}<tr class="threadrow"><td colspan="3"><form id="compose" method="post" action="{{$base}}/diff-comment" class="thread composing"> |
| @@ -280,7 +330,7 @@ | ||
| 280 | 330 | {{end}}{{end}} |
| 281 | 331 | </table></div>{{end}} |
| 282 | 332 | </details> |
| 283 | {{end}}{{end}} | |
| 333 | {{end}}</div></div>{{end}} | |
| 284 | 334 | |
| 285 | 335 | {{/* cmtln turns a line number into the link that opens the comment form |
| 286 | 336 | on that line. No JavaScript: the anchor travels in the query. */}} |
internal/web/templates/log.html +1 −1 · view
| @@ -19,7 +19,7 @@ | ||
| 19 | 19 | <p class="meta">{{template "authorname" dict "Name" .AuthorName "User" .AuthorUser "Email" .AuthorEmail}} · {{when .Date}}</p> |
| 20 | 20 | </div> |
| 21 | 21 | <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}} | |
| 23 | 23 | {{template "sigbadge" .Sig}} |
| 24 | 24 | <code><a href="/{{$.Repo.OwnerName}}/{{$.Repo.Name}}/commit/{{.SHA}}">{{.ShortSHA}}</a></code> |
| 25 | 25 | </div> |
internal/web/templates/milestones.html +1 −1 · view
| @@ -28,7 +28,7 @@ | ||
| 28 | 28 | <ul class="milestonelist"> |
| 29 | 29 | {{range .Milestones}}<li> |
| 30 | 30 | <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> | |
| 32 | 32 | {{if .Description}}<p class="desc">{{.Description}}</p>{{end}} |
| 33 | 33 | <p class="meta">{{if .DueDate}}due {{.DueDate}} · {{end}}{{.ClosedItems}} closed, {{.OpenItems}} open · {{.Percent}}%</p> |
| 34 | 34 | <div class="progress"><div class="bar" style="width: {{.Percent}}%"></div></div> |
internal/web/templates/mr.html +56 −23 · view
| @@ -15,14 +15,47 @@ | ||
| 15 | 15 | |
| 16 | 16 | {{if .Notice}}<p class="error" role="alert">{{.Notice}}</p>{{end}} |
| 17 | 17 | |
| 18 | <div class="withaside"> | |
| 19 | <div class="mainside"> | |
| 20 | ||
| 18 | {{$pc := field . "PendingComments"}} | |
| 19 | <div class="mrbar"> | |
| 21 | 20 | <nav class="subtabs" aria-label="Merge request"> |
| 22 | 21 | <a {{if eq .View "conversation"}}aria-current="page" {{end}}href="{{$base}}">Conversation{{if .Comments}} <i>{{len .Comments}}</i>{{end}}</a> |
| 23 | 22 | <a {{if eq .View "commits"}}aria-current="page" {{end}}href="{{$base}}?view=commits">Commits{{if .Commits}} <i>{{len .Commits}}</i>{{end}}</a> |
| 24 | 23 | <a {{if eq .View "diff"}}aria-current="page" {{end}}href="{{$base}}?view=diff">Files changed{{if .Stat.Files}} <i>{{.Stat.Files}}</i>{{end}}</a> |
| 25 | 24 | </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}}&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&commit={{.SHA}}{{if $.Layout.Carry}}&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"> | |
| 26 | 59 | |
| 27 | 60 | {{if eq .View "conversation"}} |
| 28 | 61 | <div class="prose"> |
| @@ -34,15 +67,15 @@ | ||
| 34 | 67 | <p><textarea name="body" aria-label="Description" rows="8">{{.Draft.Or "edit" "body" .MR.Body}}</textarea></p> |
| 35 | 68 | <p><button type="submit" class="btn">Save</button> {{template "previewbtn"}}</p> |
| 36 | 69 | </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> | |
| 39 | 72 | <div class="rendered">{{.BodyHTML}}</div> |
| 40 | 73 | {{template "reactions" index .Reactions 0}} |
| 41 | 74 | </article>{{else}}{{template "reactions" index .Reactions 0}}{{end}} |
| 42 | 75 | {{range .Comments}} |
| 43 | 76 | {{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> | |
| 46 | 79 | <div class="rendered">{{.BodyHTML}}</div> |
| 47 | 80 | {{template "reactions" index $.Reactions .ID}} |
| 48 | 81 | </article>{{end}} |
| @@ -52,8 +85,8 @@ | ||
| 52 | 85 | {{if .Viewer}} |
| 53 | 86 | {{if .Draft.Is "comment"}}{{template "previewblock" .Draft.HTML}}{{end}} |
| 54 | 87 | <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> | |
| 57 | 90 | </form> |
| 58 | 91 | {{end}} |
| 59 | 92 | </div> |
| @@ -63,7 +96,7 @@ | ||
| 63 | 96 | <ul class="loglist"> |
| 64 | 97 | {{range .Commits}}<li> |
| 65 | 98 | <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&commit={{.SHA}}">{{.Subject}}</a></p> | |
| 67 | 100 | <p class="meta">{{template "authorname" dict "Name" .AuthorName "User" .AuthorUser "Email" ""}} · {{when .Date}}</p> |
| 68 | 101 | </div> |
| 69 | 102 | <div class="commitside"> |
| @@ -74,13 +107,6 @@ | ||
| 74 | 107 | {{else}}<li class="empty">no commits on this merge request</li> |
| 75 | 108 | {{end}} |
| 76 | 109 | </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}} | |
| 84 | 110 | {{end}} |
| 85 | 111 | |
| 86 | 112 | </div> |
| @@ -89,7 +115,7 @@ | ||
| 89 | 115 | {{if and .CanWrite (or (eq .MR.State "open") (eq .MR.State "source_gone"))}} |
| 90 | 116 | <div class="grp"> |
| 91 | 117 | <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}} | |
| 93 | 119 | <form method="post" action="{{$base}}/review" class="actions"> |
| 94 | 120 | <textarea name="body" aria-label="Review note" rows="2" placeholder="Optional review note"></textarea> |
| 95 | 121 | <button type="submit" name="verdict" value="approve" class="btn">Approve</button> |
| @@ -107,18 +133,24 @@ | ||
| 107 | 133 | <input type="hidden" name="cancel" value="on"> |
| 108 | 134 | <button type="submit" class="btn">Cancel queued merge</button> |
| 109 | 135 | </form>{{end}} |
| 136 | {{$reqSigned := .Repo.Settings.RequireSignedCommits}}{{$hasStacked := false}}{{with field . "Stacked"}}{{if .}}{{$hasStacked = true}}{{end}}{{end}} | |
| 110 | 137 | <form method="post" action="{{$base}}/merge" class="actions"> |
| 111 | 138 | <label class="none" for="strategy">Strategy</label> |
| 112 | 139 | <select id="strategy" name="strategy"> |
| 113 | 140 | <option value="auto">Automatic</option> |
| 114 | 141 | <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> | |
| 118 | 145 | </select> |
| 119 | 146 | <button type="submit">Merge</button> |
| 120 | 147 | <button type="submit" name="when_ready" value="on" class="btn">Merge when ready</button> |
| 121 | 148 | </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}} | |
| 122 | 154 | </div> |
| 123 | 155 | {{end}} |
| 124 | 156 | {{if and .CanEdit (or (eq .MR.State "open") (eq .MR.State "source_gone"))}} |
| @@ -156,7 +188,7 @@ | ||
| 156 | 188 | </div> |
| 157 | 189 | <div class="grp"> |
| 158 | 190 | <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> | |
| 160 | 192 | {{else}}<p class="none">none yet</p>{{end}} |
| 161 | 193 | </div> |
| 162 | 194 | {{if .Revisions}}<div class="grp"> |
| @@ -198,7 +230,7 @@ | ||
| 198 | 230 | </div> |
| 199 | 231 | {{if .MR.Milestone}}<div class="grp"> |
| 200 | 232 | <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> | |
| 202 | 234 | </div>{{end}} |
| 203 | 235 | <div class="grp"> |
| 204 | 236 | <div class="grp-head"> |
| @@ -218,4 +250,5 @@ | ||
| 218 | 250 | </aside> |
| 219 | 251 | </div> |
| 220 | 252 | {{end}} |
| 253 | {{end}} | |
| 221 | 254 | |
internal/web/templates/mrrangediff.html +2 · view
| @@ -8,6 +8,8 @@ | ||
| 8 | 8 | </div> |
| 9 | 9 | <p class="meta">{{.MR.Title}}</p> |
| 10 | 10 | {{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> | |
| 11 | 13 | {{else if .Diff}}<pre class="code buildlog" tabindex="0">{{.Diff}}</pre> |
| 12 | 14 | {{else}}<p class="empty-note">Nothing to compare: this merge request has one revision.</p>{{end}} |
| 13 | 15 | {{end}} |
internal/web/templates/mrs.html +7 −2 · view
| @@ -12,6 +12,11 @@ | ||
| 12 | 12 | <input type="hidden" name="state" value="{{.State}}"> |
| 13 | 13 | </form> |
| 14 | 14 | {{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}}&author={{urlquery .}}">{{.}}</a>{{end}}</div> | |
| 18 | </div></details> | |
| 19 | {{end}}{{end}} | |
| 15 | 20 | <span class="spacer"></span> |
| 16 | 21 | {{if .CanOpenMR}}<a class="button" href="/{{.Repo.OwnerName}}/{{.Repo.Name}}/mrs/new">New merge request</a> |
| 17 | 22 | {{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 @@ | ||
| 23 | 28 | <div class="issuemain"> |
| 24 | 29 | <p class="title"><a href="/{{$.Repo.OwnerName}}/{{$.Repo.Name}}/mrs/{{.Number}}">{{.Title}}</a> |
| 25 | 30 | {{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> | |
| 27 | 32 | </div> |
| 28 | 33 | <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}} | |
| 30 | 35 | </div> |
| 31 | 36 | </li> |
| 32 | 37 | {{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 @@ | ||
| 4 | 4 | <h1>New</h1> |
| 5 | 5 | {{if .Error}}<p class="error" role="alert">{{.Error}}</p>{{end}} |
| 6 | 6 | |
| 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"}}"> | |
| 8 | 8 | <a href="#create" aria-current="page" data-panel="create">Repository</a> |
| 9 | 9 | <a href="#import" data-panel="import">Import</a> |
| 10 | 10 | <a href="#org" data-panel="org">Organization</a> |
| @@ -20,14 +20,14 @@ | ||
| 20 | 20 | <div class="ownerpick"> |
| 21 | 21 | <label for="new-owner">Owner</label> |
| 22 | 22 | <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}} | |
| 25 | 25 | </select> |
| 26 | 26 | </div> |
| 27 | 27 | <span class="slash" aria-hidden="true">/</span> |
| 28 | 28 | <div class="namepick"> |
| 29 | 29 | <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"> | |
| 31 | 31 | </div> |
| 32 | 32 | </div> |
| 33 | 33 | <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 @@ | ||
| 35 | 35 | <fieldset class="segmented"> |
| 36 | 36 | <legend>Visibility</legend> |
| 37 | 37 | <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> | |
| 40 | 40 | </div> |
| 41 | 41 | </fieldset> |
| 42 | 42 | <p><button type="submit">Create repository</button></p> |
| @@ -90,7 +90,7 @@ | ||
| 90 | 90 | <input type="hidden" name="field" value="org-create"> |
| 91 | 91 | <div class="field"> |
| 92 | 92 | <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"> | |
| 94 | 94 | <span class="hint" id="orghint">Same naming rules as a repository; becomes a top-level path.</span> |
| 95 | 95 | </div> |
| 96 | 96 | <p><button type="submit">Create organization</button></p> |
internal/web/templates/owner.html +2 −2 · view
| @@ -71,7 +71,7 @@ | ||
| 71 | 71 | <span class="count">{{.Bookmarks}}</span></p> |
| 72 | 72 | {{if .Description}}<p class="desc">{{.Description}}</p>{{end}} |
| 73 | 73 | </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}} | |
| 75 | 75 | </ul> |
| 76 | 76 | {{end}} |
| 77 | 77 | |
| @@ -80,7 +80,7 @@ | ||
| 80 | 80 | {{if .Self}}<div class="listhead"> |
| 81 | 81 | <p class="meta"><code>gitbay snippet create <file> < file</code></p> |
| 82 | 82 | <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> | |
| 84 | 84 | </div>{{end}} |
| 85 | 85 | <section class="setcard"> |
| 86 | 86 | {{if .SnippetRows}}<div class="tablewrap"><table class="keys"> |
internal/web/templates/queries.html +77 −14 · view
| @@ -1,28 +1,55 @@ | ||
| 1 | 1 | {{define "width"}}wide{{end}} |
| 2 | 2 | {{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"}} | |
| 15 | 4 | <ul class="issuelist rows"> |
| 16 | 5 | {{range .Items}}<li> |
| 17 | 6 | <div class="issuemain"> |
| 18 | 7 | <p class="title"><a href="/{{.Repo}}/{{if eq .Kind "mr"}}mrs{{else}}issues{{end}}/{{.Number}}">{{.Title}}</a></p> |
| 19 | 8 | <p class="meta"><span class="repo">{{.Ref}}</span> · <a href="/{{.Author}}">{{.Author}}</a>{{if .Milestone}} · in {{.Milestone}}{{end}} · {{when .CreatedAt}}</p> |
| 20 | 9 | </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> | |
| 22 | 11 | </li> |
| 23 | 12 | {{else}}<li class="empty">nothing matches</li>{{end}} |
| 24 | 13 | </ul> |
| 25 | 14 | {{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" .}} | |
| 26 | 53 | </div> |
| 27 | 54 | {{else}} |
| 28 | 55 | <div class="pagehead"> |
| @@ -30,13 +57,49 @@ | ||
| 30 | 57 | <span class="grow"></span> |
| 31 | 58 | {{if .Saved}}<input type="search" class="tablefilter" placeholder="Filter queries…" aria-label="Filter queries" data-filter-list="saved-queries">{{end}} |
| 32 | 59 | </div> |
| 33 | <p class="meta">Saved with <code>gitbay query save <name> <query></code>; <code>gitbay query pin <name></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}} | |
| 34 | 83 | <ul class="issuelist rows" id="saved-queries"> |
| 35 | 84 | {{range .Saved}}<li> |
| 36 | 85 | <div class="issuemain"> |
| 37 | 86 | <p class="title"><a href="/{{$.Viewer}}/-/queries/{{.Name}}">{{.Name}}</a>{{if .Pinned}} <span class="chip">pinned</span>{{end}}</p> |
| 38 | 87 | <p class="meta"><code>{{.Query}}</code></p> |
| 39 | 88 | </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> | |
| 40 | 103 | </li> |
| 41 | 104 | {{else}}<li class="empty">no saved queries</li>{{end}} |
| 42 | 105 | </ul> |
internal/web/templates/registered.html +14 −1 · view
| @@ -2,8 +2,21 @@ | ||
| 2 | 2 | {{define "title"}}welcome · {{.Site}}{{end}} |
| 3 | 3 | {{define "content"}} |
| 4 | 4 | <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}} | |
| 6 | 7 | <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 & sign in</button> | |
| 17 | </form> | |
| 18 | </section> | |
| 19 | {{end}} | |
| 7 | 20 | <section class="setcard"> |
| 8 | 21 | <h2>On the web</h2> |
| 9 | 22 | <ol> |
internal/web/templates/releases.html +1 −1 · view
| @@ -19,7 +19,7 @@ | ||
| 19 | 19 | </p> |
| 20 | 20 | <p><input type="text" name="title" aria-label="Title" placeholder="title (defaults to the tag)" value="{{.Draft.Or "release" "title" ""}}"></p> |
| 21 | 21 | <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> | |
| 23 | 23 | </form> |
| 24 | 24 | </details> |
| 25 | 25 | {{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 @@ | ||
| 22 | 22 | <li><a href="#tags">Protected tags</a></li> |
| 23 | 23 | <li><a href="#deps">Dependencies</a></li> |
| 24 | 24 | <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> | |
| 25 | 29 | <li><a href="#lifecycle">Lifecycle</a></li> |
| 26 | 30 | </ul></div> |
| 27 | 31 | </details> |
| @@ -56,7 +60,7 @@ | ||
| 56 | 60 | </section> |
| 57 | 61 | |
| 58 | 62 | <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"> | |
| 60 | 64 | <input type="hidden" name="field" value="visibility"> |
| 61 | 65 | <div><span class="fieldname">Visibility</span></div> |
| 62 | 66 | <div class="check"> |
| @@ -179,7 +183,7 @@ | ||
| 179 | 183 | </section> |
| 180 | 184 | |
| 181 | 185 | {{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"> | |
| 183 | 187 | <input type="hidden" name="field" value="security"> |
| 184 | 188 | <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> |
| 185 | 189 | <div class="check"><input type="checkbox" id="security-enabled" name="security" value="on"{{if .Security.Enabled}} checked{{end}}></div> |
| @@ -197,7 +201,7 @@ | ||
| 197 | 201 | {{if .Security.Findings}}<div class="tablewrap"><table class="keys"> |
| 198 | 202 | <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> |
| 199 | 203 | {{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> | |
| 201 | 205 | <td class="mono">{{.Rule}}</td> |
| 202 | 206 | <td>{{.Level}}</td> |
| 203 | 207 | <td><form method="post" action="{{$base}}" class="inline"> |
| @@ -214,7 +218,7 @@ | ||
| 214 | 218 | <div class="tablewrap"><table class="keys" id="sec-dismissed"> |
| 215 | 219 | <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> |
| 216 | 220 | <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> | |
| 218 | 222 | <td class="mono">{{.Rule}}</td> |
| 219 | 223 | <td>{{.Reason}}{{if .DismissedBy}} <span class="meta">by {{.DismissedBy}}</span>{{end}}</td> |
| 220 | 224 | <td><form method="post" action="{{$base}}" class="inline"> |
| @@ -302,7 +306,7 @@ | ||
| 302 | 306 | </section> |
| 303 | 307 | |
| 304 | 308 | <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"> | |
| 306 | 310 | <input type="hidden" name="field" value="deps"> |
| 307 | 311 | <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> |
| 308 | 312 | <div class="check"><input type="checkbox" id="deps-enabled" name="deps" value="on"{{if .DepsEnabled}} checked{{end}}></div> |
| @@ -382,6 +386,133 @@ | ||
| 382 | 386 | </details> |
| 383 | 387 | </section> |
| 384 | 388 | |
| 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 | ||
| 385 | 516 | <section id="lifecycle" class="setcard setcard-danger"><h2>Lifecycle</h2> |
| 386 | 517 | <form method="post" action="{{$base}}" class="setform"> |
| 387 | 518 | <input type="hidden" name="field" value="archive"> |
internal/web/templates/tree.html +2 −2 · view
| @@ -9,7 +9,7 @@ | ||
| 9 | 9 | {{template "refmenu" .}} |
| 10 | 10 | <span class="crumbs"><a href="/{{.Repo.OwnerName}}/{{.Repo.Name}}">{{.Repo.Name}}</a>/{{range .Crumbs}}<a href="{{.URL}}">{{.Name}}</a>/{{end}}</span> |
| 11 | 11 | <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}} | |
| 13 | 13 | <div class="acts"> |
| 14 | 14 | <a class="button btn" href="/{{.Repo.OwnerName}}/{{.Repo.Name}}/search">Search code</a> |
| 15 | 15 | <a class="button btn" href="/{{.Repo.OwnerName}}/{{.Repo.Name}}/log/{{.Ref}}">History</a> |
| @@ -51,7 +51,7 @@ | ||
| 51 | 51 | {{if .Facts.Bookmarks}}<span><b>{{.Facts.Bookmarks}}</b> bookmark{{if ne .Facts.Bookmarks 1}}s{{end}}</span>{{end}} |
| 52 | 52 | {{with .Facts.License}}<span class="fact">{{.}}</span>{{end}} |
| 53 | 53 | {{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}} | |
| 55 | 55 | </div> |
| 56 | 56 | {{with .Facts.Languages}}<p class="langbar" aria-hidden="true">{{range .}}<span class="lang lang-{{slug .Name}}" style="width:{{pct .Percent}}%"></span>{{end}}</p> |
| 57 | 57 | <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) { | ||
| 149 | 149 | } |
| 150 | 150 | } |
| 151 | 151 | } |
| 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. | |
| 156 | func 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 | } | |