Commit e52efaeb3a
e52efaeb3aefdd2b8013bed14f7c31b71051c7d6
parent: 6f5a52ae63
Verified · cmc ci/build: success ci/test: success
cmc <hello@cleberg.net> · 2026-09-18 04:05 UTC
web: the merge request diff view is wide
Closes #219
internal/web/templates/mr.html
+1
| @@ -1,3 +1,4 @@ |
| 1 | {{define "width"}}{{if eq .View "diff"}}wide{{else}}reading{{end}}{{end}} |
| 1 | 2 | {{define "title"}}!{{.MR.Number}} · {{.Repo.OwnerName}}/{{.Repo.Name}}{{end}} |
| 2 | 3 | {{define "content"}} |
| 3 | 4 | {{$base := printf "/%s/%s/mrs/%d" .Repo.OwnerName .Repo.Name .MR.Number}} |
internal/web/web_test.go
+6 −2
| @@ -86,10 +86,12 @@ func TestWhenNamesTheZone(t *testing.T) { |
| 86 | 86 | |
| 87 | 87 | // TestMainWidthClass checks each template's source for the width define |
| 88 | 88 | // the spec assigns it (wide or bounded), and that a reading page defines |
| 89 | | // none. |
| 89 | // none. The merge request page picks wide for its diff view, so it gets |
| 90 | // a per-view define instead of a fixed one. |
| 90 | 91 | func TestMainWidthClass(t *testing.T) { |
| 91 | 92 | wide := map[string]bool{"tree.html": true, "blob.html": true, "blame.html": true, "log.html": true, "commit.html": true, "compare.html": true, "builds.html": true, "build.html": true, "search.html": true, "globalsearch.html": true} |
| 92 | 93 | bounded := map[string]bool{"landing.html": true, "login.html": true, "register.html": true, "registered.html": true, "new.html": true, "issuenew.html": true, "mrnew.html": true, "settings.html": true, "account.html": true, "admin.html": true, "edit.html": true, "snippetnew.html": true, "privacy.html": true, "404.html": true} |
| 94 | perView := map[string]string{"mr.html": `{{define "width"}}{{if eq .View "diff"}}wide{{else}}reading{{end}}{{end}}`} |
| 93 | 95 | for _, name := range Pages() { |
| 94 | 96 | src, err := TemplateSource(name) |
| 95 | 97 | if err != nil { |
| @@ -97,11 +99,13 @@ func TestMainWidthClass(t *testing.T) { |
| 97 | 99 | } |
| 98 | 100 | has := strings.Contains(src, `{{define "width"}}`) |
| 99 | 101 | switch { |
| 102 | case perView[name] != "" && !strings.Contains(src, perView[name]): |
| 103 | t.Errorf("%s: want per-view width define %s", name, perView[name]) |
| 100 | 104 | case wide[name] && !strings.Contains(src, `{{define "width"}}wide{{end}}`): |
| 101 | 105 | t.Errorf("%s: want width wide", name) |
| 102 | 106 | case bounded[name] && !strings.Contains(src, `{{define "width"}}bounded{{end}}`): |
| 103 | 107 | t.Errorf("%s: want width bounded", name) |
| 104 | | case !wide[name] && !bounded[name] && has: |
| 108 | case !wide[name] && !bounded[name] && perView[name] == "" && has: |
| 105 | 109 | t.Errorf("%s: defines a width but the spec calls it reading", name) |
| 106 | 110 | } |
| 107 | 111 | } |