summaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorEarl Warren <earl-warren@noreply.codeberg.org>2024-03-24 06:33:13 +0100
committerEarl Warren <earl-warren@noreply.codeberg.org>2024-03-24 06:33:13 +0100
commit33ede091354e3d10c15d28bebe64df8a6f2cdb44 (patch)
treea3c3eb4efe14cdbddf25b622ff4f17f742a76030 /routers
parentMerge pull request '[port] gitea#29833: Refactor markdown attention render' (... (diff)
parentsimplify template (diff)
downloadforgejo-33ede091354e3d10c15d28bebe64df8a6f2cdb44.tar.xz
forgejo-33ede091354e3d10c15d28bebe64df8a6f2cdb44.zip
Merge pull request '[PORT] Unify search boxes (gitea#29530)' (#2688) from snematoda/port-29530 into forgejo
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/2688 Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
Diffstat (limited to 'routers')
-rw-r--r--routers/web/explore/code.go5
-rw-r--r--routers/web/repo/commit.go2
-rw-r--r--routers/web/repo/search.go11
-rw-r--r--routers/web/user/code.go5
4 files changed, 10 insertions, 13 deletions
diff --git a/routers/web/explore/code.go b/routers/web/explore/code.go
index 75bd0f3d24..f61b832572 100644
--- a/routers/web/explore/code.go
+++ b/routers/web/explore/code.go
@@ -35,12 +35,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 == "" {
diff --git a/routers/web/repo/commit.go b/routers/web/repo/commit.go
index 7c89ce5a38..0c585a93b8 100644
--- a/routers/web/repo/commit.go
+++ b/routers/web/repo/commit.go
@@ -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
diff --git a/routers/web/repo/search.go b/routers/web/repo/search.go
index d22a691a70..460378ce05 100644
--- a/routers/web/repo/search.go
+++ b/routers/web/repo/search.go
@@ -21,12 +21,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 == "" {
@@ -34,7 +33,7 @@ func Search(ctx *context.Context) {
return
}
- ctx.Data["SourcePath"] = ctx.Repo.Repository.Link()
+ ctx.Data["Repo"] = ctx.Repo.Repository
page := ctx.FormInt("page")
if page <= 0 {
@@ -42,7 +41,7 @@ func Search(ctx *context.Context) {
}
if setting.Indexer.RepoIndexerEnabled {
- ctx.Data["CodeIndexerEnabled"] = true
+ ctx.Data["CodeIndexerDisabled"] = false
total, searchResults, searchResultLanguages, err := code_indexer.PerformSearch(ctx, &code_indexer.SearchOptions{
RepoIDs: []int64{ctx.Repo.Repository.ID},
@@ -78,7 +77,7 @@ func Search(ctx *context.Context) {
return
}
- ctx.Data["CodeIndexerEnabled"] = false
+ ctx.Data["CodeIndexerDisabled"] = true
ctx.Data["SearchResults"] = data
pager := context.NewPagination(len(data), setting.UI.RepoSearchPagingNum, page, 5)
diff --git a/routers/web/user/code.go b/routers/web/user/code.go
index d2afdd8905..e2e8f25661 100644
--- a/routers/web/user/code.go
+++ b/routers/web/user/code.go
@@ -40,12 +40,11 @@ func CodeSearch(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["IsCodePage"] = true
if keyword == "" {