Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify search boxes #29530

Merged
merged 44 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
9fc1cee
deduplicate search translations
denyskon Mar 1, 2024
3420d76
Merge remote-tracking branch 'upstream/main' into locale-cleanup
denyskon Mar 8, 2024
cbf68b6
Merge remote-tracking branch 'upstream/main' into locale-cleanup
denyskon Mar 8, 2024
0827d70
WIP
denyskon Mar 9, 2024
68737d1
Merge branch 'main' into locale-cleanup
denyskon Mar 9, 2024
64d0b72
WIP
denyskon Mar 9, 2024
d647d6a
WIP
denyskon Mar 9, 2024
11dca6e
WIP
denyskon Mar 9, 2024
f57d864
Merge branch 'main' into locale-cleanup
denyskon Mar 9, 2024
74e70b7
Merge remote-tracking branch 'upstream/main' into locale-cleanup
denyskon Mar 10, 2024
d9b35e3
finish
denyskon Mar 10, 2024
142ff7c
document params for shared templates
denyskon Mar 10, 2024
732b74e
Merge branch 'main' into locale-cleanup
denyskon Mar 10, 2024
e04497d
make test pass
denyskon Mar 10, 2024
94208c1
Merge branch 'locale-cleanup' of ssh://github.com/denyskon/gitea into…
denyskon Mar 10, 2024
5774a2c
no autofocus if disabled
denyskon Mar 10, 2024
33f0bab
Merge branch 'main' into locale-cleanup
denyskon Mar 10, 2024
7525ce0
Merge branch 'main' into locale-cleanup
6543 Mar 10, 2024
f1d15fa
Merge branch 'main' into locale-cleanup
6543 Mar 11, 2024
788ac65
Merge branch 'main' into locale-cleanup
denyskon Mar 12, 2024
a7b955f
remove primary color from button
denyskon Mar 13, 2024
1dfadb6
Merge branch 'main' into locale-cleanup
denyskon Mar 13, 2024
dd14dc4
Merge branch 'main' into locale-cleanup
6543 Mar 13, 2024
c1dcf7f
Merge branch 'main' into locale-cleanup
6543 Mar 13, 2024
8c2d0e4
Merge branch 'main' into locale-cleanup
denyskon Mar 13, 2024
22124c4
Merge branch 'main' into locale-cleanup
denyskon Mar 13, 2024
0539de3
Merge branch 'main' into locale-cleanup
denyskon Mar 13, 2024
e222490
Update templates/package/shared/list.tmpl
denyskon Mar 13, 2024
40a58c6
Merge branch 'main' into locale-cleanup
denyskon Mar 13, 2024
b67c1f5
Merge branch 'main' into locale-cleanup
6543 Mar 13, 2024
655fcdd
Update templates/repo/home.tmpl
denyskon Mar 14, 2024
948a98d
apply requested changes
denyskon Mar 14, 2024
75afa66
Merge branch 'main' into locale-cleanup
denyskon Mar 14, 2024
f49e69d
Merge branch 'main' into locale-cleanup
denyskon Mar 14, 2024
3d2d213
Update web_src/css/form.css
denyskon Mar 14, 2024
ea418f3
css fixes
silverwind Mar 14, 2024
8aaa5ca
simplify code search template
denyskon Mar 14, 2024
2372dc3
Merge branch 'locale-cleanup' of ssh://github.com/denyskon/gitea into…
denyskon Mar 14, 2024
0601976
move commits search dropdown out
denyskon Mar 14, 2024
d5a1c84
Merge branch 'main' into locale-cleanup
GiteaBot Mar 14, 2024
329c2f4
fix button left border on focus
silverwind Mar 14, 2024
91f7e35
Merge branch 'main' into locale-cleanup
GiteaBot Mar 14, 2024
b64a6e9
Merge branch 'main' into locale-cleanup
GiteaBot Mar 14, 2024
d17d86e
Merge branch 'main' into locale-cleanup
GiteaBot Mar 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 25 additions & 33 deletions options/locale/locale_en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,30 @@ filter.not_template = Not Template
filter.public = Public
filter.private = Private

[search]
search = Search
type_tooltip = Search type
fuzzy = Fuzzy
fuzzy_tooltip = Include results that also match the search term closely
match = Match
match_tooltip = Include only results that match the exact search term
repo_kind = Search repos...
repo_no_results = No matching repositories found.
user_kind = Search users...
user_no_results = No matching users found.
org_kind = Search orgs...
org_no_results = No matching organizations found.
team_kind = Search teams...
code_kind = Search code...
code_no_results = No matching source code found.
code_search_unavailable = Code search is currently not available. Please contact your site administrator.
denyskon marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
code_search_unavailable = Code search is currently not available. Please contact your site administrator.
code_search_unavailable = Code search is currently unavailable.

package_kind = Search packages...
project_kind = Search projects...
branch_kind = Search branches...
commit_kind = Search commits...
runner_kind = Search runners...
keyword_search_unavailable = Searching by keyword is currently not available. Please contact your site administrator.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
keyword_search_unavailable = Searching by keyword is currently not available. Please contact your site administrator.
keyword_search_unavailable = Keyword search is currently unavailable.


[aria]
navbar = Navigation Bar
footer = Footer
Expand Down Expand Up @@ -330,7 +354,6 @@ collaborative_repos = Collaborative Repositories
my_orgs = My Organizations
my_mirrors = My Mirrors
view_home = View %s
search_repos = Find a repository…
filter = Other Filters
filter_by_team_repositories = Filter by team repositories
feed_of = Feed of "%s"
Expand All @@ -351,20 +374,8 @@ issues.in_your_repos = In your repositories
repos = Repositories
users = Users
organizations = Organizations
search = Search
go_to = Go to
code = Code
search.type.tooltip = Search type
search.fuzzy = Fuzzy
search.fuzzy.tooltip = Include results that also matches the search term closely
search.match = Match
search.match.tooltip = Include only results that matches the exact search term
code_search_unavailable = Currently code search is not available. Please contact your site administrator.
repo_no_results = No matching repositories found.
user_no_results = No matching users found.
org_no_results = No matching organizations found.
code_no_results = No source code matching your search term found.
code_search_results = Search results for "%s"
code_last_indexed_at = Last indexed %s
relevant_repositories_tooltip = Repositories that are forks or that have no topic, no icon, and no description are hidden.
relevant_repositories = Only relevant repositories are being shown, <a href="%s">show unfiltered results</a>.
Expand Down Expand Up @@ -1324,9 +1335,8 @@ commits.desc = Browse source code change history.
commits.commits = Commits
commits.no_commits = No commits in common. "%s" and "%s" have entirely different histories.
commits.nothing_to_compare = These branches are equal.
commits.search = Search commits…
commits.search.tooltip = You can prefix keywords with "author:", "committer:", "after:", or "before:", e.g. "revert author:Alice before:2019-01-13".
commits.find = Search
commits.search_branch = This Branch
commits.search_all = All Branches
commits.author = Author
commits.message = Message
Expand Down Expand Up @@ -1502,7 +1512,6 @@ issues.filter_sort.moststars = Most stars
issues.filter_sort.feweststars = Fewest stars
issues.filter_sort.mostforks = Most forks
issues.filter_sort.fewestforks = Fewest forks
issues.keyword_search_unavailable = Searching by keyword is currently not available. Please contact your site administrator.
issues.action_open = Open
issues.action_close = Close
issues.action_label = Label
Expand Down Expand Up @@ -2035,17 +2044,6 @@ contributors.contribution_type.commits = Commits
contributors.contribution_type.additions = Additions
contributors.contribution_type.deletions = Deletions

search = Search
search.search_repo = Search repository
search.type.tooltip = Search type
search.fuzzy = Fuzzy
search.fuzzy.tooltip = Include results that also matches the search term closely
search.match = Match
search.match.tooltip = Include only results that matches the exact search term
search.results = Search results for "%s" in <a href="%s">%s</a>
search.code_no_results = No source code matching your search term found.
search.code_search_unavailable = Currently code search is not available. Please contact your site administrator.
denyskon marked this conversation as resolved.
Show resolved Hide resolved

settings = Settings
settings.desc = Settings is where you can manage the settings for the repository
settings.options = Repository
Expand Down Expand Up @@ -2206,15 +2204,13 @@ settings.delete_collaborator = Remove
settings.collaborator_deletion = Remove Collaborator
settings.collaborator_deletion_desc = Removing a collaborator will revoke their access to this repository. Continue?
settings.remove_collaborator_success = The collaborator has been removed.
settings.search_user_placeholder = Search user…
settings.org_not_allowed_to_be_collaborator = Organizations cannot be added as a collaborator.
settings.change_team_access_not_allowed = Changing team access for repository has been restricted to organization owner
settings.team_not_in_organization = The team is not in the same organization as the repository
settings.teams = Teams
settings.add_team = Add Team
settings.add_team_duplicate = Team already has the repository
settings.add_team_success = The team now have access to the repository.
settings.search_team = Search Team…
settings.change_team_permission_tip = Team's permission is set on the team setting page and can't be changed per repository
settings.delete_team_tip = This team has access to all repositories and can't be removed
settings.remove_team_success = The team's access to the repository has been removed.
Expand Down Expand Up @@ -2367,9 +2363,7 @@ settings.protect_whitelist_committers = Whitelist Restricted Push
settings.protect_whitelist_committers_desc = Only whitelisted users or teams will be allowed to push to this branch (but not force push).
settings.protect_whitelist_deploy_keys = Whitelist deploy keys with write access to push.
settings.protect_whitelist_users = Whitelisted users for pushing:
settings.protect_whitelist_search_users = Search users…
settings.protect_whitelist_teams = Whitelisted teams for pushing:
settings.protect_whitelist_search_teams = Search teams…
settings.protect_merge_whitelist_committers = Enable Merge Whitelist
settings.protect_merge_whitelist_committers_desc = Allow only whitelisted users or teams to merge pull requests into this branch.
settings.protect_merge_whitelist_users = Whitelisted users for merging:
Expand Down Expand Up @@ -2614,7 +2608,6 @@ branch.default_deletion_failed = Branch "%s" is the default branch. It cannot be
branch.restore = Restore Branch "%s"
branch.download = Download Branch "%s"
branch.rename = Rename Branch "%s"
branch.search = Search Branch
branch.included_desc = This branch is part of the default branch
branch.included = Included
branch.create_new_branch = Create branch from branch:
Expand Down Expand Up @@ -2760,7 +2753,6 @@ teams.write_permission_desc = This team grants <strong>Write</strong> access: me
teams.admin_permission_desc = This team grants <strong>Admin</strong> access: members can read from, push to and add collaborators to team repositories.
teams.create_repo_permission_desc = Additionally, this team grants <strong>Create repository</strong> permission: members can create new repositories in organization.
teams.repositories = Team Repositories
teams.search_repo_placeholder = Search repository…
teams.remove_all_repos_title = Remove all team repositories
teams.remove_all_repos_desc = This will remove all repositories from the team.
teams.add_all_repos_title = Add all repositories
Expand Down
5 changes: 2 additions & 3 deletions routers/web/explore/code.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,11 @@ func Code(ctx *context.Context) {
language := ctx.FormTrim("l")
keyword := ctx.FormTrim("q")

queryType := ctx.FormTrim("t")
isFuzzy := queryType != "match"
isFuzzy := ctx.FormOptionalBool("fuzzy").ValueOrDefault(true)

ctx.Data["Keyword"] = keyword
ctx.Data["Language"] = language
ctx.Data["queryType"] = queryType
ctx.Data["IsFuzzy"] = isFuzzy
ctx.Data["PageIsViewCode"] = true

if keyword == "" {
Expand Down
2 changes: 1 addition & 1 deletion routers/web/repo/commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ func SearchCommits(ctx *context.Context) {

ctx.Data["Keyword"] = query
if all {
ctx.Data["All"] = "checked"
ctx.Data["All"] = true
}
ctx.Data["Username"] = ctx.Repo.Owner.Name
ctx.Data["Reponame"] = ctx.Repo.Repository.Name
Expand Down
5 changes: 2 additions & 3 deletions routers/web/repo/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@ func Search(ctx *context.Context) {
language := ctx.FormTrim("l")
keyword := ctx.FormTrim("q")

queryType := ctx.FormTrim("t")
isFuzzy := queryType != "match"
isFuzzy := ctx.FormOptionalBool("fuzzy").ValueOrDefault(true)

ctx.Data["Keyword"] = keyword
ctx.Data["Language"] = language
ctx.Data["queryType"] = queryType
ctx.Data["IsFuzzy"] = isFuzzy
ctx.Data["PageIsViewCode"] = true

if keyword == "" {
Expand Down
6 changes: 3 additions & 3 deletions routers/web/user/code.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@ func CodeSearch(ctx *context.Context) {
ctx.Data["IsPackageEnabled"] = setting.Packages.Enabled
ctx.Data["IsRepoIndexerEnabled"] = setting.Indexer.RepoIndexerEnabled
ctx.Data["Title"] = ctx.Tr("explore.code")
ctx.Data["PageIsExploreCode"] = true

language := ctx.FormTrim("l")
keyword := ctx.FormTrim("q")

queryType := ctx.FormTrim("t")
isFuzzy := queryType != "match"
isFuzzy := ctx.FormOptionalBool("fuzzy").ValueOrDefault(true)

ctx.Data["Keyword"] = keyword
ctx.Data["Language"] = language
ctx.Data["queryType"] = queryType
ctx.Data["IsFuzzy"] = isFuzzy
ctx.Data["IsCodePage"] = true

if keyword == "" {
Expand Down
2 changes: 1 addition & 1 deletion services/context/pagination.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,5 @@ func (p *Pagination) SetDefaultParams(ctx *Context) {
p.AddParam(ctx, "sort", "SortType")
p.AddParam(ctx, "q", "Keyword")
// do not add any more uncommon params here!
p.AddParam(ctx, "t", "queryType")
p.AddParam(ctx, "fuzzy", "IsFuzzy")
}
23 changes: 0 additions & 23 deletions templates/admin/base/search.tmpl

This file was deleted.

5 changes: 1 addition & 4 deletions templates/admin/emails/list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
<div class="ui attached segment">
<div class="ui secondary filter menu gt-ac gt-mx-0">
<form class="ui form ignore-dirty gt-f1">
<div class="ui fluid action input">
{{template "shared/searchinput" dict "Value" .Keyword}}
<button class="ui primary button">{{ctx.Locale.Tr "explore.search"}}</button>
</div>
{{template "shared/search/combo" dict "Value" .Keyword}}
</form>
<!-- Sort -->
<div class="ui dropdown type jump item gt-mr-0">
Expand Down
21 changes: 20 additions & 1 deletion templates/admin/org/list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,26 @@
</div>
</h4>
<div class="ui attached segment">
{{template "admin/base/search" .}}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you delete that template?
Why not simply leave it in?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can answer your question. That's caused by an over-abstraction in old days.

At that time, admin/base/search was designed to be a "shared template" and was expected to be used everywhere. But over time, that design didn't fit more and more cases, so the "shared template" usages were replaced by dedicated code block one by one, then, here is the only last one place which uses the "shared template" nowadays.

<div class="ui secondary filter menu gt-ac gt-mx-0">
<form class="ui form ignore-dirty gt-f1">
{{template "shared/search/combo" dict "Value" .Keyword "Placeholder" (ctx.Locale.Tr "search.org_kind")}}
</form>
<!-- Sort -->
<div class="ui dropdown type jump item gt-mr-0">
<span class="text">
{{ctx.Locale.Tr "repo.issues.filter_sort"}}
</span>
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
<div class="menu">
<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>
<a class="{{if eq .SortType "newest"}}active {{end}}item" href="{{$.Link}}?sort=newest&q={{$.Keyword}}">{{ctx.Locale.Tr "repo.issues.filter_sort.latest"}}</a>
<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>
<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>
<a class="{{if eq .SortType "recentupdate"}}active {{end}}item" href="{{$.Link}}?sort=recentupdate&q={{$.Keyword}}">{{ctx.Locale.Tr "repo.issues.filter_sort.recentupdate"}}</a>
<a class="{{if eq .SortType "leastupdate"}}active {{end}}item" href="{{$.Link}}?sort=leastupdate&q={{$.Keyword}}">{{ctx.Locale.Tr "repo.issues.filter_sort.leastupdate"}}</a>
</div>
</div>
</div>
</div>
<div class="ui attached table segment">
<table class="ui very basic striped table unstackable">
Expand Down
6 changes: 3 additions & 3 deletions templates/admin/packages/list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
<div class="ui attached segment">
<form class="ui form ignore-dirty">
<div class="ui fluid action input">
{{template "shared/searchinput" dict "Value" .Query}}
<select class="ui dropdown" name="type">
{{template "shared/search/input" dict "Value" .Query}}
<select class="ui small dropdown" name="type">
<option value="">{{ctx.Locale.Tr "packages.filter.type"}}</option>
<option value="all">{{ctx.Locale.Tr "packages.filter.type.all"}}</option>
{{range $type := .AvailableTypes}}
<option{{if eq $.PackageType $type}} selected="selected"{{end}} value="{{$type}}">{{$type.Name}}</option>
{{end}}
</select>
<button class="ui primary button">{{ctx.Locale.Tr "explore.search"}}</button>
{{template "shared/search/button"}}
</div>
</form>
</div>
Expand Down
2 changes: 1 addition & 1 deletion templates/admin/repo/unadopted.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<div class="ui fluid action input">
<input name="search" value="true" type="hidden">
<input name="q" value="{{.Keyword}}" placeholder="{{ctx.Locale.Tr "repo.adopt_search"}}" autofocus>
<button class="ui primary button">{{ctx.Locale.Tr "explore.search"}}</button>
{{template "shared/search/button"}}
</div>
</form>
</div>
Expand Down
6 changes: 1 addition & 5 deletions templates/admin/user/list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,7 @@
</div>
</div>

<!-- Search Text -->
<div class="ui fluid action input">
{{template "shared/searchinput" dict "Value" .Keyword}}
<button class="ui primary button">{{ctx.Locale.Tr "explore.search"}}</button>
</div>
{{template "shared/search/combo" dict "Value" .Keyword "Placeholder" (ctx.Locale.Tr "search.user_kind")}}
</form>
</div>
<div class="ui attached table segment">
Expand Down
17 changes: 0 additions & 17 deletions templates/code/searchcombo.tmpl

This file was deleted.

14 changes: 0 additions & 14 deletions templates/code/searchform.tmpl

This file was deleted.

30 changes: 0 additions & 30 deletions templates/code/searchresults.tmpl

This file was deleted.

2 changes: 1 addition & 1 deletion templates/explore/code.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div role="main" aria-label="{{.Title}}" class="page-content explore users">
{{template "explore/navbar" .}}
<div class="ui container">
{{template "code/searchcombo" .}}
{{template "shared/search/code/search" .}}
</div>
</div>
{{template "base/footer" .}}
2 changes: 1 addition & 1 deletion templates/explore/repo_list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
</div>
{{else}}
<div>
{{ctx.Locale.Tr "explore.repo_no_results"}}
{{ctx.Locale.Tr "search.repo_no_results"}}
</div>
{{end}}
</div>
Loading