Skip to content

Commit e0b002a

Browse files
denyskon6543silverwindGiteaBot
authored
Unify search boxes (#29530)
Unify all but a few search boxes to use uniform style, uniform translations and shared templates where possible. Remove a few duplicated search templates, e. g. code search. <details><summary>Example after screenshots:</summary> ![grafik](https://github.com/go-gitea/gitea/assets/47871822/e20e7d6b-c6be-4a47-b132-672766f41421) ![grafik](https://github.com/go-gitea/gitea/assets/47871822/d5b11b9c-c12f-4a29-8fb0-24e5aa511d18) ![grafik](https://github.com/go-gitea/gitea/assets/47871822/d86bb444-36c7-426d-9cf1-c634963dffb1) ![grafik](https://github.com/go-gitea/gitea/assets/47871822/a76c0319-0518-484a-a840-563d02b61198) </details> Also includes #29700 Co-authored-by: 6543 <[email protected]> --------- Co-authored-by: 6543 <[email protected]> Co-authored-by: 6543 <[email protected]> Co-authored-by: silverwind <[email protected]> Co-authored-by: Giteabot <[email protected]>
1 parent 607ed27 commit e0b002a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+347
-397
lines changed

options/locale/locale_en-US.ini

Lines changed: 22 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,27 @@ filter.not_template = Not Template
155155
filter.public = Public
156156
filter.private = Private
157157

158+
[search]
159+
search = Search...
160+
type_tooltip = Search type
161+
fuzzy = Fuzzy
162+
fuzzy_tooltip = Include results that also match the search term closely
163+
match = Match
164+
match_tooltip = Include only results that match the exact search term
165+
repo_kind = Search repos...
166+
user_kind = Search users...
167+
org_kind = Search orgs...
168+
team_kind = Search teams...
169+
code_kind = Search code...
170+
code_search_unavailable = Code search is currently not available. Please contact the site administrator.
171+
package_kind = Search packages...
172+
project_kind = Search projects...
173+
branch_kind = Search branches...
174+
commit_kind = Search commits...
175+
runner_kind = Search runners...
176+
no_results = No matching results found.
177+
keyword_search_unavailable = Searching by keyword is currently not available. Please contact the site administrator.
178+
158179
[aria]
159180
navbar = Navigation Bar
160181
footer = Footer
@@ -330,7 +351,6 @@ collaborative_repos = Collaborative Repositories
330351
my_orgs = My Organizations
331352
my_mirrors = My Mirrors
332353
view_home = View %s
333-
search_repos = Find a repository…
334354
filter = Other Filters
335355
filter_by_team_repositories = Filter by team repositories
336356
feed_of = Feed of "%s"
@@ -351,20 +371,8 @@ issues.in_your_repos = In your repositories
351371
repos = Repositories
352372
users = Users
353373
organizations = Organizations
354-
search = Search
355374
go_to = Go to
356375
code = Code
357-
search.type.tooltip = Search type
358-
search.fuzzy = Fuzzy
359-
search.fuzzy.tooltip = Include results that also matches the search term closely
360-
search.match = Match
361-
search.match.tooltip = Include only results that matches the exact search term
362-
code_search_unavailable = Currently code search is not available. Please contact your site administrator.
363-
repo_no_results = No matching repositories found.
364-
user_no_results = No matching users found.
365-
org_no_results = No matching organizations found.
366-
code_no_results = No source code matching your search term found.
367-
code_search_results = Search results for "%s"
368376
code_last_indexed_at = Last indexed %s
369377
relevant_repositories_tooltip = Repositories that are forks or that have no topic, no icon, and no description are hidden.
370378
relevant_repositories = Only relevant repositories are being shown, <a href="%s">show unfiltered results</a>.
@@ -1324,9 +1332,8 @@ commits.desc = Browse source code change history.
13241332
commits.commits = Commits
13251333
commits.no_commits = No commits in common. "%s" and "%s" have entirely different histories.
13261334
commits.nothing_to_compare = These branches are equal.
1327-
commits.search = Search commits…
13281335
commits.search.tooltip = You can prefix keywords with "author:", "committer:", "after:", or "before:", e.g. "revert author:Alice before:2019-01-13".
1329-
commits.find = Search
1336+
commits.search_branch = This Branch
13301337
commits.search_all = All Branches
13311338
commits.author = Author
13321339
commits.message = Message
@@ -1502,7 +1509,6 @@ issues.filter_sort.moststars = Most stars
15021509
issues.filter_sort.feweststars = Fewest stars
15031510
issues.filter_sort.mostforks = Most forks
15041511
issues.filter_sort.fewestforks = Fewest forks
1505-
issues.keyword_search_unavailable = Searching by keyword is currently not available. Please contact your site administrator.
15061512
issues.action_open = Open
15071513
issues.action_close = Close
15081514
issues.action_label = Label
@@ -2035,17 +2041,6 @@ contributors.contribution_type.commits = Commits
20352041
contributors.contribution_type.additions = Additions
20362042
contributors.contribution_type.deletions = Deletions
20372043

2038-
search = Search
2039-
search.search_repo = Search repository
2040-
search.type.tooltip = Search type
2041-
search.fuzzy = Fuzzy
2042-
search.fuzzy.tooltip = Include results that also matches the search term closely
2043-
search.match = Match
2044-
search.match.tooltip = Include only results that matches the exact search term
2045-
search.results = Search results for "%s" in <a href="%s">%s</a>
2046-
search.code_no_results = No source code matching your search term found.
2047-
search.code_search_unavailable = Currently code search is not available. Please contact your site administrator.
2048-
20492044
settings = Settings
20502045
settings.desc = Settings is where you can manage the settings for the repository
20512046
settings.options = Repository
@@ -2206,15 +2201,13 @@ settings.delete_collaborator = Remove
22062201
settings.collaborator_deletion = Remove Collaborator
22072202
settings.collaborator_deletion_desc = Removing a collaborator will revoke their access to this repository. Continue?
22082203
settings.remove_collaborator_success = The collaborator has been removed.
2209-
settings.search_user_placeholder = Search user…
22102204
settings.org_not_allowed_to_be_collaborator = Organizations cannot be added as a collaborator.
22112205
settings.change_team_access_not_allowed = Changing team access for repository has been restricted to organization owner
22122206
settings.team_not_in_organization = The team is not in the same organization as the repository
22132207
settings.teams = Teams
22142208
settings.add_team = Add Team
22152209
settings.add_team_duplicate = Team already has the repository
22162210
settings.add_team_success = The team now have access to the repository.
2217-
settings.search_team = Search Team…
22182211
settings.change_team_permission_tip = Team's permission is set on the team setting page and can't be changed per repository
22192212
settings.delete_team_tip = This team has access to all repositories and can't be removed
22202213
settings.remove_team_success = The team's access to the repository has been removed.
@@ -2367,9 +2360,7 @@ settings.protect_whitelist_committers = Whitelist Restricted Push
23672360
settings.protect_whitelist_committers_desc = Only whitelisted users or teams will be allowed to push to this branch (but not force push).
23682361
settings.protect_whitelist_deploy_keys = Whitelist deploy keys with write access to push.
23692362
settings.protect_whitelist_users = Whitelisted users for pushing:
2370-
settings.protect_whitelist_search_users = Search users…
23712363
settings.protect_whitelist_teams = Whitelisted teams for pushing:
2372-
settings.protect_whitelist_search_teams = Search teams…
23732364
settings.protect_merge_whitelist_committers = Enable Merge Whitelist
23742365
settings.protect_merge_whitelist_committers_desc = Allow only whitelisted users or teams to merge pull requests into this branch.
23752366
settings.protect_merge_whitelist_users = Whitelisted users for merging:
@@ -2614,7 +2605,6 @@ branch.default_deletion_failed = Branch "%s" is the default branch. It cannot be
26142605
branch.restore = Restore Branch "%s"
26152606
branch.download = Download Branch "%s"
26162607
branch.rename = Rename Branch "%s"
2617-
branch.search = Search Branch
26182608
branch.included_desc = This branch is part of the default branch
26192609
branch.included = Included
26202610
branch.create_new_branch = Create branch from branch:
@@ -2760,7 +2750,6 @@ teams.write_permission_desc = This team grants <strong>Write</strong> access: me
27602750
teams.admin_permission_desc = This team grants <strong>Admin</strong> access: members can read from, push to and add collaborators to team repositories.
27612751
teams.create_repo_permission_desc = Additionally, this team grants <strong>Create repository</strong> permission: members can create new repositories in organization.
27622752
teams.repositories = Team Repositories
2763-
teams.search_repo_placeholder = Search repository…
27642753
teams.remove_all_repos_title = Remove all team repositories
27652754
teams.remove_all_repos_desc = This will remove all repositories from the team.
27662755
teams.add_all_repos_title = Add all repositories

routers/web/explore/code.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,11 @@ func Code(ctx *context.Context) {
3434
language := ctx.FormTrim("l")
3535
keyword := ctx.FormTrim("q")
3636

37-
queryType := ctx.FormTrim("t")
38-
isFuzzy := queryType != "match"
37+
isFuzzy := ctx.FormOptionalBool("fuzzy").ValueOrDefault(true)
3938

4039
ctx.Data["Keyword"] = keyword
4140
ctx.Data["Language"] = language
42-
ctx.Data["queryType"] = queryType
41+
ctx.Data["IsFuzzy"] = isFuzzy
4342
ctx.Data["PageIsViewCode"] = true
4443

4544
if keyword == "" {

routers/web/repo/commit.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ func SearchCommits(ctx *context.Context) {
203203

204204
ctx.Data["Keyword"] = query
205205
if all {
206-
ctx.Data["All"] = "checked"
206+
ctx.Data["All"] = true
207207
}
208208
ctx.Data["Username"] = ctx.Repo.Owner.Name
209209
ctx.Data["Reponame"] = ctx.Repo.Repository.Name

routers/web/repo/search.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,11 @@ func Search(ctx *context.Context) {
2424
language := ctx.FormTrim("l")
2525
keyword := ctx.FormTrim("q")
2626

27-
queryType := ctx.FormTrim("t")
28-
isFuzzy := queryType != "match"
27+
isFuzzy := ctx.FormOptionalBool("fuzzy").ValueOrDefault(true)
2928

3029
ctx.Data["Keyword"] = keyword
3130
ctx.Data["Language"] = language
32-
ctx.Data["queryType"] = queryType
31+
ctx.Data["IsFuzzy"] = isFuzzy
3332
ctx.Data["PageIsViewCode"] = true
3433

3534
if keyword == "" {
@@ -54,7 +53,7 @@ func Search(ctx *context.Context) {
5453
ctx.Data["CodeIndexerUnavailable"] = !code_indexer.IsAvailable(ctx)
5554
}
5655

57-
ctx.Data["SourcePath"] = ctx.Repo.Repository.Link()
56+
ctx.Data["Repo"] = ctx.Repo.Repository
5857
ctx.Data["SearchResults"] = searchResults
5958
ctx.Data["SearchResultLanguages"] = searchResultLanguages
6059

routers/web/user/code.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,11 @@ func CodeSearch(ctx *context.Context) {
3939
language := ctx.FormTrim("l")
4040
keyword := ctx.FormTrim("q")
4141

42-
queryType := ctx.FormTrim("t")
43-
isFuzzy := queryType != "match"
42+
isFuzzy := ctx.FormOptionalBool("fuzzy").ValueOrDefault(true)
4443

4544
ctx.Data["Keyword"] = keyword
4645
ctx.Data["Language"] = language
47-
ctx.Data["queryType"] = queryType
46+
ctx.Data["IsFuzzy"] = isFuzzy
4847
ctx.Data["IsCodePage"] = true
4948

5049
if keyword == "" {

services/context/pagination.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,5 @@ func (p *Pagination) SetDefaultParams(ctx *Context) {
5353
p.AddParam(ctx, "sort", "SortType")
5454
p.AddParam(ctx, "q", "Keyword")
5555
// do not add any more uncommon params here!
56-
p.AddParam(ctx, "t", "queryType")
56+
p.AddParam(ctx, "fuzzy", "IsFuzzy")
5757
}

templates/admin/base/search.tmpl

Lines changed: 0 additions & 23 deletions
This file was deleted.

templates/admin/emails/list.tmpl

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@
66
<div class="ui attached segment">
77
<div class="ui secondary filter menu gt-ac gt-mx-0">
88
<form class="ui form ignore-dirty gt-f1">
9-
<div class="ui fluid action input">
10-
{{template "shared/searchinput" dict "Value" .Keyword}}
11-
<button class="ui primary button">{{ctx.Locale.Tr "explore.search"}}</button>
12-
</div>
9+
{{template "shared/search/combo" dict "Value" .Keyword}}
1310
</form>
1411
<!-- Sort -->
1512
<div class="ui dropdown type jump item gt-mr-0">

templates/admin/org/list.tmpl

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,26 @@
77
</div>
88
</h4>
99
<div class="ui attached segment">
10-
{{template "admin/base/search" .}}
10+
<div class="ui secondary filter menu gt-ac gt-mx-0">
11+
<form class="ui form ignore-dirty gt-f1">
12+
{{template "shared/search/combo" dict "Value" .Keyword "Placeholder" (ctx.Locale.Tr "search.org_kind")}}
13+
</form>
14+
<!-- Sort -->
15+
<div class="ui dropdown type jump item gt-mr-0">
16+
<span class="text">
17+
{{ctx.Locale.Tr "repo.issues.filter_sort"}}
18+
</span>
19+
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
20+
<div class="menu">
21+
<a class="{{if or (eq .SortType "oldest") (not .SortType)}}active {{end}}item" href="{{$.Link}}?sort=oldest&q={{$.Keyword}}">{{ctx.Locale.Tr "repo.issues.filter_sort.oldest"}}</a>
22+
<a class="{{if eq .SortType "newest"}}active {{end}}item" href="{{$.Link}}?sort=newest&q={{$.Keyword}}">{{ctx.Locale.Tr "repo.issues.filter_sort.latest"}}</a>
23+
<a class="{{if eq .SortType "alphabetically"}}active {{end}}item" href="{{$.Link}}?sort=alphabetically&q={{$.Keyword}}">{{ctx.Locale.Tr "repo.issues.label.filter_sort.alphabetically"}}</a>
24+
<a class="{{if eq .SortType "reversealphabetically"}}active {{end}}item" href="{{$.Link}}?sort=reversealphabetically&q={{$.Keyword}}">{{ctx.Locale.Tr "repo.issues.label.filter_sort.reverse_alphabetically"}}</a>
25+
<a class="{{if eq .SortType "recentupdate"}}active {{end}}item" href="{{$.Link}}?sort=recentupdate&q={{$.Keyword}}">{{ctx.Locale.Tr "repo.issues.filter_sort.recentupdate"}}</a>
26+
<a class="{{if eq .SortType "leastupdate"}}active {{end}}item" href="{{$.Link}}?sort=leastupdate&q={{$.Keyword}}">{{ctx.Locale.Tr "repo.issues.filter_sort.leastupdate"}}</a>
27+
</div>
28+
</div>
29+
</div>
1130
</div>
1231
<div class="ui attached table segment">
1332
<table class="ui very basic striped table unstackable">

templates/admin/packages/list.tmpl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@
1313
</h4>
1414
<div class="ui attached segment">
1515
<form class="ui form ignore-dirty">
16-
<div class="ui fluid action input">
17-
{{template "shared/searchinput" dict "Value" .Query}}
18-
<select class="ui dropdown" name="type">
16+
<div class="ui small fluid action input">
17+
{{template "shared/search/input" dict "Value" .Query}}
18+
<select class="ui small dropdown" name="type">
1919
<option value="">{{ctx.Locale.Tr "packages.filter.type"}}</option>
2020
<option value="all">{{ctx.Locale.Tr "packages.filter.type.all"}}</option>
2121
{{range $type := .AvailableTypes}}
2222
<option{{if eq $.PackageType $type}} selected="selected"{{end}} value="{{$type}}">{{$type.Name}}</option>
2323
{{end}}
2424
</select>
25-
<button class="ui primary button">{{ctx.Locale.Tr "explore.search"}}</button>
25+
{{template "shared/search/button"}}
2626
</div>
2727
</form>
2828
</div>

templates/admin/repo/unadopted.tmpl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
</h4>
99
<div class="ui attached segment">
1010
<form class="ui form ignore-dirty">
11-
<div class="ui fluid action input">
12-
<input name="search" value="true" type="hidden">
13-
<input name="q" value="{{.Keyword}}" placeholder="{{ctx.Locale.Tr "repo.adopt_search"}}" autofocus>
14-
<button class="ui primary button">{{ctx.Locale.Tr "explore.search"}}</button>
11+
<div class="ui small fluid action input">
12+
<input name="search" value="true" type="hidden">
13+
<input name="q" value="{{.Keyword}}" placeholder="{{ctx.Locale.Tr "repo.adopt_search"}}" autofocus>
14+
{{template "shared/search/button"}}
1515
</div>
1616
</form>
1717
</div>

templates/admin/user/list.tmpl

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,7 @@
5252
</div>
5353
</div>
5454

55-
<!-- Search Text -->
56-
<div class="ui fluid action input">
57-
{{template "shared/searchinput" dict "Value" .Keyword}}
58-
<button class="ui primary button">{{ctx.Locale.Tr "explore.search"}}</button>
59-
</div>
55+
{{template "shared/search/combo" dict "Value" .Keyword "Placeholder" (ctx.Locale.Tr "search.user_kind")}}
6056
</form>
6157
</div>
6258
<div class="ui attached table segment">

templates/code/searchcombo.tmpl

Lines changed: 0 additions & 17 deletions
This file was deleted.

templates/code/searchform.tmpl

Lines changed: 0 additions & 14 deletions
This file was deleted.

templates/explore/code.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div role="main" aria-label="{{.Title}}" class="page-content explore users">
33
{{template "explore/navbar" .}}
44
<div class="ui container">
5-
{{template "code/searchcombo" .}}
5+
{{template "shared/search/code/search" .}}
66
</div>
77
</div>
88
{{template "base/footer" .}}

templates/explore/repo_list.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
</div>
5959
{{else}}
6060
<div>
61-
{{ctx.Locale.Tr "explore.repo_no_results"}}
61+
{{ctx.Locale.Tr "search.no_results"}}
6262
</div>
6363
{{end}}
6464
</div>

templates/explore/search.tmpl

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
<div class="ui secondary filter menu gt-ac gt-mx-0">
1+
<div class="ui small secondary filter menu gt-ac gt-mx-0">
22
<form class="ui form ignore-dirty gt-f1">
3-
<div class="ui fluid action input">
4-
{{template "shared/searchinput" dict "Value" .Keyword}}
5-
<button class="ui primary button">{{ctx.Locale.Tr "explore.search"}}</button>
6-
</div>
3+
{{if .PageIsExploreUsers}}
4+
{{template "shared/search/combo" dict "Value" .Keyword "Placeholder" (ctx.Locale.Tr "search.user_kind")}}
5+
{{else}}
6+
{{template "shared/search/combo" dict "Value" .Keyword "Placeholder" (ctx.Locale.Tr "search.org_kind")}}
7+
{{end}}
78
</form>
89
<!-- Sort -->
9-
<div class="ui dropdown type jump item gt-mr-0">
10+
<div class="ui small dropdown type jump item gt-mr-0">
1011
<span class="text">
1112
{{ctx.Locale.Tr "repo.issues.filter_sort"}}
1213
</span>

templates/explore/user_list.tmpl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
</div>
2727
</div>
2828
{{else}}
29-
<div class="flex-item">{{ctx.Locale.Tr "explore.user_no_results"}}</div>
29+
<div class="flex-item">
30+
{{ctx.Locale.Tr "search.no_results"}}
31+
</div>
3032
{{end}}
3133
</div>

0 commit comments

Comments
 (0)