From d2efdda9119d22e919b65d52c7ac2c35a0b9eee0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Piliszek?= Date: Tue, 27 Aug 2024 17:11:48 +0200 Subject: [PATCH] ui(code-search): fix to use CodeSearchMode Drop unused IsFuzzy and IsRegExp --- routers/web/explore/code.go | 1 - routers/web/repo/search.go | 2 -- routers/web/user/code.go | 1 - templates/repo/search.tmpl | 2 +- templates/shared/search/code/results.tmpl | 2 +- 5 files changed, 2 insertions(+), 6 deletions(-) diff --git a/routers/web/explore/code.go b/routers/web/explore/code.go index 4db41fd726..7a3f6a5a86 100644 --- a/routers/web/explore/code.go +++ b/routers/web/explore/code.go @@ -45,7 +45,6 @@ func Code(ctx *context.Context) { ctx.Data["Keyword"] = keyword ctx.Data["Language"] = language ctx.Data["CodeSearchOptions"] = []string{"exact", "fuzzy"} - ctx.Data["IsFuzzy"] = isFuzzy if isFuzzy { ctx.Data["CodeSearchMode"] = "fuzzy" } else { diff --git a/routers/web/repo/search.go b/routers/web/repo/search.go index 724bb82612..863a279af0 100644 --- a/routers/web/repo/search.go +++ b/routers/web/repo/search.go @@ -63,8 +63,6 @@ func Search(ctx *context.Context) { ctx.Data["Keyword"] = keyword ctx.Data["Language"] = language - ctx.Data["IsFuzzy"] = mode == FuzzySearchMode - ctx.Data["IsRegExp"] = mode == RegExpSearchMode ctx.Data["CodeSearchMode"] = mode.String() ctx.Data["PageIsViewCode"] = true diff --git a/routers/web/user/code.go b/routers/web/user/code.go index 9e8614cb04..bf4cbb8920 100644 --- a/routers/web/user/code.go +++ b/routers/web/user/code.go @@ -50,7 +50,6 @@ func CodeSearch(ctx *context.Context) { ctx.Data["Keyword"] = keyword ctx.Data["Language"] = language ctx.Data["CodeSearchOptions"] = []string{"exact", "fuzzy"} - ctx.Data["IsFuzzy"] = isFuzzy if isFuzzy { ctx.Data["CodeSearchMode"] = "fuzzy" } else { diff --git a/templates/repo/search.tmpl b/templates/repo/search.tmpl index 6d114c81e4..34707bc8da 100644 --- a/templates/repo/search.tmpl +++ b/templates/repo/search.tmpl @@ -5,7 +5,7 @@ {{if $.CodeIndexerDisabled}} {{$branchURLPrefix := printf "%s/search/branch/" $.RepoLink}} {{$tagURLPrefix := printf "%s/search/tag/" $.RepoLink}} - {{$suffix := printf "?q=%s&fuzzy=%t" (.Keyword|QueryEscape) .IsFuzzy}} + {{$suffix := printf "?q=%s&mode=%s" (.Keyword|QueryEscape) .CodeSearchMode}} {{template "repo/branch_dropdown" dict "root" . "ContainerClasses" "tw-mb-3" "branchURLPrefix" $branchURLPrefix "branchURLSuffix" $suffix "tagURLPrefix" $tagURLPrefix "tagURLSuffix" $suffix}} {{end}} {{template "shared/search/code/search" .}} diff --git a/templates/shared/search/code/results.tmpl b/templates/shared/search/code/results.tmpl index fe375579bd..98c5430502 100644 --- a/templates/shared/search/code/results.tmpl +++ b/templates/shared/search/code/results.tmpl @@ -1,7 +1,7 @@
{{range $term := .SearchResultLanguages}} + href="?q={{$.Keyword}}{{if ne $.Language $term.Language}}&l={{$term.Language}}{{end}}&mode={{$.CodeSearchMode}}"> {{$term.Language}}
{{$term.Count}}