Commit ff759b5394
ff759b53942049b2043e132f5482b442a7265b98
parent: a8ca19c99f
Verified · cmc ci/build: success ci/test: failure
cmc <hello@cleberg.net> · 2026-09-28 22:05 UTC
web: search scope caption is permanent; document the tab zero-count rule
Closes #270
Layout: unified · split
CHANGELOG.org
+6
| @@ -6,6 +6,12 @@ anything beyond "replace the binary and restart" is needed. |
| 6 | 6 | |
| 7 | 7 | * Unreleased |
| 8 | 8 | |
| 9 | - Empty states on the web state the fact instead of a CLI command, and |
| 10 | drop "yet" on a finished item; the merge request list offers a New |
| 11 | merge request link, a fork link, or a sign-in prompt depending on |
| 12 | what the visitor can do; and the search page's scope caption is |
| 13 | always visible, not only before a first search (#270). |
| 14 | |
| 9 | 15 | Credentials and sessions: revocation, delegation, expiry and an idle |
| 10 | 16 | timeout (#256, #257, #276, #277). |
| 11 | 17 | |
internal/httpd/searchweb_test.go
added
+28
| @@ -0,0 +1,28 @@ |
| 1 | package httpd |
| 2 | |
| 3 | import ( |
| 4 | "strings" |
| 5 | "testing" |
| 6 | |
| 7 | "gitbay.org/gitbay/internal/web" |
| 8 | ) |
| 9 | |
| 10 | // The scope sentence is a permanent caption, not a first-visit-only |
| 11 | // hint: a visitor who has already searched still needs to know what a |
| 12 | // search here does and does not cover (#270). |
| 13 | func TestGlobalSearchScopeCaptionAlwaysShown(t *testing.T) { |
| 14 | var sb strings.Builder |
| 15 | if err := web.Render(&sb, "globalsearch.html", struct { |
| 16 | basePage |
| 17 | Tab string |
| 18 | Query string |
| 19 | Kind string |
| 20 | QueryErr string |
| 21 | Results []searchResult |
| 22 | }{basePage{Site: "gitbay"}, "sitesearch", "gitbay", "", "", nil}); err != nil { |
| 23 | t.Fatalf("render: %v", err) |
| 24 | } |
| 25 | if !strings.Contains(sb.String(), "File contents are searched per repository") { |
| 26 | t.Error("scope caption missing once a query is present") |
| 27 | } |
| 28 | } |
internal/web/templates/globalsearch.html
+1 −2
| @@ -43,9 +43,8 @@ |
| 43 | 43 | {{/* The count line above already says nothing matched, so this one |
| 44 | 44 | carries the way out instead of repeating it. */}} |
| 45 | 45 | {{else}}<p class="empty-note">Try fewer words{{if .Kind}}, <a href="?q={{.Query}}">search everything</a>,{{end}} or <a href="/explore">browse the repositories</a>.</p>{{end}} |
| 46 | | {{else}} |
| 47 | | <p class="empty-note">Repository names, descriptions and topics, and the title and body of every issue and merge request you can read. File contents are searched per repository, from a repository's Code tab.</p> |
| 48 | 46 | {{end}} |
| 47 | <p class="meta">Repository names, descriptions and topics, and the title and body of every issue and merge request you can read. File contents are searched per repository, from a repository's Code tab.</p> |
| 49 | 48 | </div> |
| 50 | 49 | </div> |
| 51 | 50 | {{end}} |
internal/web/templates/layout.html
+5
| @@ -66,6 +66,11 @@ |
| 66 | 66 | <a class="button btn" href="/{{.OwnerName}}/{{.Name}}/fork">Fork</a>{{end}} |
| 67 | 67 | </div> |
| 68 | 68 | {{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}} |
| 69 | {{/* A tab's own count badge is omitted at zero (an empty <i> reads as |
| 70 | stray punctuation next to the tab word); the dashboard pin row's |
| 71 | count chip always shows its number, zero included, the same as |
| 72 | every other count chip in the app. Two elements, two rules, |
| 73 | decided once here (#270). */}} |
| 69 | 74 | <nav class="tabs" aria-label="Repository"> |
| 70 | 75 | <a {{if eq $top "code"}}aria-current="page" {{end}}href="/{{.OwnerName}}/{{.Name}}">Code</a> |
| 71 | 76 | <a {{if eq $top "issues"}}aria-current="page" {{end}}href="/{{.OwnerName}}/{{.Name}}/issues">Issues{{with field $ "OpenIssues"}}{{if .}} <i>{{.}}</i>{{end}}{{end}}</a> |