diff --git a/routers/web/explore/code.go b/routers/web/explore/code.go index a6bc71ac9cde0..7ba5984002c82 100644 --- a/routers/web/explore/code.go +++ b/routers/web/explore/code.go @@ -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 == "" { diff --git a/routers/web/repo/search.go b/routers/web/repo/search.go index 766dd5726aa8d..e6201dde06caa 100644 --- a/routers/web/repo/search.go +++ b/routers/web/repo/search.go @@ -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 == "" { diff --git a/routers/web/user/code.go b/routers/web/user/code.go index 8613d38b65a66..92911edfe9325 100644 --- a/routers/web/user/code.go +++ b/routers/web/user/code.go @@ -39,12 +39,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 == "" { diff --git a/templates/code/searchform.tmpl b/templates/code/searchform.tmpl index fae1340046838..4052b445f6d46 100644 --- a/templates/code/searchform.tmpl +++ b/templates/code/searchform.tmpl @@ -1,14 +1,7 @@
{{template "shared/searchinput" dict "Value" .Keyword "Disabled" .CodeIndexerUnavailable}} - + {{template "shared/searchfuzzy" dict "Disabled" .CodeIndexerUnavailable "IsFuzzy" .IsFuzzy "Topic" "explore"}}
diff --git a/templates/repo/search.tmpl b/templates/repo/search.tmpl index 7513d444cc1c7..425a51259cafa 100644 --- a/templates/repo/search.tmpl +++ b/templates/repo/search.tmpl @@ -6,14 +6,7 @@
- + {{template "shared/searchfuzzy" dict "Disabled" .CodeIndexerUnavailable "IsFuzzy" .IsFuzzy "Topic" "repo"}}
diff --git a/templates/shared/searchfuzzy.tmpl b/templates/shared/searchfuzzy.tmpl new file mode 100644 index 0000000000000..a22ad0f74985e --- /dev/null +++ b/templates/shared/searchfuzzy.tmpl @@ -0,0 +1,13 @@ + +