Skip to content

Commit 6ecff4e

Browse files
committed
use "fuzzy" instead of "t" in query
1 parent 0d4b0dd commit 6ecff4e

File tree

6 files changed

+16
-15
lines changed

6 files changed

+16
-15
lines changed

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.FormBool("fuzzy")
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/search.go

Lines changed: 2 additions & 3 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.FormBool("fuzzy")
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 == "" {

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.FormBool("fuzzy")
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 == "" {

templates/code/searchform.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<form class="ui form ignore-dirty">
22
<div class="ui fluid action input">
33
{{template "shared/searchinput" dict "Value" .Keyword "Disabled" .CodeIndexerUnavailable}}
4-
{{template "shared/searchfuzzy" dict "Disabled" .CodeIndexerUnavailable "QueryType" .queryType "Topic" "explore"}}
4+
{{template "shared/searchfuzzy" dict "Disabled" .CodeIndexerUnavailable "IsFuzzy" .IsFuzzy "Topic" "explore"}}
55
<button class="ui primary button"{{if .CodeIndexerUnavailable}} disabled{{end}}>{{ctx.Locale.Tr "explore.search"}}</button>
66
</div>
77
</form>

templates/repo/search.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<form class="ui form ignore-dirty" method="get">
77
<div class="ui fluid action input">
88
<input name="q" value="{{.Keyword}}"{{if .CodeIndexerUnavailable}} disabled{{end}} placeholder="{{ctx.Locale.Tr "repo.search.search_repo"}}">
9-
{{template "shared/searchfuzzy" dict "Disabled" .CodeIndexerUnavailable "QueryType" .queryType "Topic" "repo"}}
9+
{{template "shared/searchfuzzy" dict "Disabled" .CodeIndexerUnavailable "IsFuzzy" .IsFuzzy "Topic" "repo"}}
1010
<button class="ui icon button"{{if .CodeIndexerUnavailable}} disabled{{end}} type="submit">{{svg "octicon-search" 16}}</button>
1111
</div>
1212
</form>

templates/shared/searchfuzzy.tmpl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
<!-- Topic can be "repo" or "explore" -->
22
<div class="ui dropdown selection {{if .Disabled}} disabled{{end}}" data-tooltip-content="{{ctx.Locale.Tr (printf "%s.search.type.tooltip" .Topic)}}">
3-
<input name="t" type="hidden"{{if .Disabled}} disabled{{end}} value="{{.QueryType}}">{{svg "octicon-triangle-down" 14 "dropdown icon"}}
4-
<div class="text">{{ctx.Locale.Tr (printf "%s.search.%s" .Topic (or .QueryType "fuzzy"))}}</div>
3+
<input name="fuzzy" type="hidden"{{if .Disabled}} disabled{{end}} value="{{.IsFuzzy}}">{{svg "octicon-triangle-down" 14 "dropdown icon"}}
4+
{{if .IsFuzzy}}
5+
<div class="text">{{ctx.Locale.Tr (printf "%s.search.fuzzy" .Topic)}}</div>
6+
{{else}}
7+
<div class="text">{{ctx.Locale.Tr (printf "%s.search.match" .Topic)}}</div>
8+
{{end}}
59
<div class="menu">
6-
<div class="item" data-value="fuzzy" data-tooltip-content="{{ctx.Locale.Tr (printf "%s.search.fuzzy.tooltip" .Topic)}}">{{ctx.Locale.Tr (printf "%s.search.fuzzy" .Topic)}}</div>
7-
<div class="item" data-value="match" data-tooltip-content="{{ctx.Locale.Tr (printf "%s.search.match.tooltip" .Topic)}}">{{ctx.Locale.Tr (printf "%s.search.match" .Topic)}}</div>
10+
<div class="item" data-value="true" data-tooltip-content="{{ctx.Locale.Tr (printf "%s.search.fuzzy.tooltip" .Topic)}}">{{ctx.Locale.Tr (printf "%s.search.fuzzy" .Topic)}}</div>
11+
<div class="item" data-value="false" data-tooltip-content="{{ctx.Locale.Tr (printf "%s.search.match.tooltip" .Topic)}}">{{ctx.Locale.Tr (printf "%s.search.match" .Topic)}}</div>
812
</div>
913
</div>

0 commit comments

Comments
 (0)