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}}
12{{define "title"}}!{{.MR.Number}} · {{.Repo.OwnerName}}/{{.Repo.Name}}{{end}}
23{{define "content"}}
34{{$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) {
8686
8787// TestMainWidthClass checks each template's source for the width define
8888// 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.
9091func TestMainWidthClass(t *testing.T) {
9192 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}
9293 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}}`}
9395 for _, name := range Pages() {
9496 src, err := TemplateSource(name)
9597 if err != nil {
@@ -97,11 +99,13 @@ func TestMainWidthClass(t *testing.T) {
9799 }
98100 has := strings.Contains(src, `{{define "width"}}`)
99101 switch {
102 case perView[name] != "" && !strings.Contains(src, perView[name]):
103 t.Errorf("%s: want per-view width define %s", name, perView[name])
100104 case wide[name] && !strings.Contains(src, `{{define "width"}}wide{{end}}`):
101105 t.Errorf("%s: want width wide", name)
102106 case bounded[name] && !strings.Contains(src, `{{define "width"}}bounded{{end}}`):
103107 t.Errorf("%s: want width bounded", name)
104 case !wide[name] && !bounded[name] && has:
108 case !wide[name] && !bounded[name] && perView[name] == "" && has:
105109 t.Errorf("%s: defines a width but the spec calls it reading", name)
106110 }
107111 }