Skip to content

Commit 4412eee

Browse files
committed
Merge remote-tracking branch 'origin/main' into fontsize
* origin/main: Replace all simple inline styles with tailwind (#30032) Migrate font-weight helpers to tailwind (#30027) Remove jQuery from the issue "go to" button (#30028) Determine fuzziness of bleve indexer by keyword length (#29706) Escape paths for find file correctly (#30026)
2 parents f36433f + 0bef9a2 commit 4412eee

File tree

25 files changed

+75
-81
lines changed

25 files changed

+75
-81
lines changed

modules/indexer/code/bleve/bleve.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ import (
3939
const (
4040
unicodeNormalizeName = "unicodeNormalize"
4141
maxBatchSize = 16
42+
// fuzzyDenominator determines the levenshtein distance per each character of a keyword
43+
fuzzyDenominator = 4
4244
)
4345

4446
func addUnicodeNormalizeTokenFilter(m *mapping.IndexMappingImpl) error {
@@ -239,15 +241,12 @@ func (b *Indexer) Search(ctx context.Context, opts *internal.SearchOptions) (int
239241
keywordQuery query.Query
240242
)
241243

244+
phraseQuery := bleve.NewMatchPhraseQuery(opts.Keyword)
245+
phraseQuery.FieldVal = "Content"
246+
phraseQuery.Analyzer = repoIndexerAnalyzer
247+
keywordQuery = phraseQuery
242248
if opts.IsKeywordFuzzy {
243-
phraseQuery := bleve.NewMatchPhraseQuery(opts.Keyword)
244-
phraseQuery.FieldVal = "Content"
245-
phraseQuery.Analyzer = repoIndexerAnalyzer
246-
keywordQuery = phraseQuery
247-
} else {
248-
prefixQuery := bleve.NewPrefixQuery(opts.Keyword)
249-
prefixQuery.FieldVal = "Content"
250-
keywordQuery = prefixQuery
249+
phraseQuery.Fuzziness = len(opts.Keyword) / fuzzyDenominator
251250
}
252251

253252
if len(opts.RepoIDs) > 0 {

modules/indexer/internal/bleve/query.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,11 @@ func NumericEqualityQuery(value int64, field string) *query.NumericRangeQuery {
2020
}
2121

2222
// MatchPhraseQuery generates a match phrase query for the given phrase, field and analyzer
23-
func MatchPhraseQuery(matchPhrase, field, analyzer string) *query.MatchPhraseQuery {
23+
func MatchPhraseQuery(matchPhrase, field, analyzer string, fuzziness int) *query.MatchPhraseQuery {
2424
q := bleve.NewMatchPhraseQuery(matchPhrase)
2525
q.FieldVal = field
2626
q.Analyzer = analyzer
27-
return q
28-
}
29-
30-
// PrefixQuery generates a match prefix query for the given prefix and field
31-
func PrefixQuery(matchPrefix, field string) *query.PrefixQuery {
32-
q := bleve.NewPrefixQuery(matchPrefix)
33-
q.FieldVal = field
27+
q.Fuzziness = fuzziness
3428
return q
3529
}
3630

modules/indexer/issues/bleve/bleve.go

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ func addUnicodeNormalizeTokenFilter(m *mapping.IndexMappingImpl) error {
3535
})
3636
}
3737

38-
const maxBatchSize = 16
38+
const (
39+
maxBatchSize = 16
40+
// fuzzyDenominator determines the levenshtein distance per each character of a keyword
41+
fuzzyDenominator = 4
42+
)
3943

4044
// IndexerData an update to the issue indexer
4145
type IndexerData internal.IndexerData
@@ -156,19 +160,16 @@ func (b *Indexer) Search(ctx context.Context, options *internal.SearchOptions) (
156160
var queries []query.Query
157161

158162
if options.Keyword != "" {
163+
fuzziness := 0
159164
if options.IsFuzzyKeyword {
160-
queries = append(queries, bleve.NewDisjunctionQuery([]query.Query{
161-
inner_bleve.MatchPhraseQuery(options.Keyword, "title", issueIndexerAnalyzer),
162-
inner_bleve.MatchPhraseQuery(options.Keyword, "content", issueIndexerAnalyzer),
163-
inner_bleve.MatchPhraseQuery(options.Keyword, "comments", issueIndexerAnalyzer),
164-
}...))
165-
} else {
166-
queries = append(queries, bleve.NewDisjunctionQuery([]query.Query{
167-
inner_bleve.PrefixQuery(options.Keyword, "title"),
168-
inner_bleve.PrefixQuery(options.Keyword, "content"),
169-
inner_bleve.PrefixQuery(options.Keyword, "comments"),
170-
}...))
165+
fuzziness = len(options.Keyword) / fuzzyDenominator
171166
}
167+
168+
queries = append(queries, bleve.NewDisjunctionQuery([]query.Query{
169+
inner_bleve.MatchPhraseQuery(options.Keyword, "title", issueIndexerAnalyzer, fuzziness),
170+
inner_bleve.MatchPhraseQuery(options.Keyword, "content", issueIndexerAnalyzer, fuzziness),
171+
inner_bleve.MatchPhraseQuery(options.Keyword, "comments", issueIndexerAnalyzer, fuzziness),
172+
}...))
172173
}
173174

174175
if len(options.RepoIDs) > 0 || options.AllPublic {

tailwind.config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,13 @@ export default {
6666
'3xl': '24px',
6767
'full': 'var(--border-radius-circle)', // 50%
6868
},
69+
fontWeight: {
70+
light: 'var(--font-weight-light)',
71+
normal: 'var(--font-weight-normal)',
72+
medium: 'var(--font-weight-medium)',
73+
semibold: 'var(--font-weight-semibold)',
74+
bold: 'var(--font-weight-bold)',
75+
},
6976
fontSize: { // not using `rem` units because our root is currently 14px
7077
'xs': '12px',
7178
'sm': '14px',

templates/admin/notice.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<td><div class="ui checkbox tw-flex" data-id="{{.ID}}"><input type="checkbox"></div></td>
2121
<td>{{.ID}}</td>
2222
<td>{{ctx.Locale.Tr .TrStr}}</td>
23-
<td class="view-detail auto-ellipsis" style="width: 80%;"><span class="notice-description">{{.Description}}</span></td>
23+
<td class="view-detail auto-ellipsis tw-w-4/5"><span class="notice-description">{{.Description}}</span></td>
2424
<td nowrap>{{DateTime "short" .CreatedUnix}}</td>
2525
<td class="view-detail"><a href="#">{{svg "octicon-note" 16}}</a></td>
2626
</tr>

templates/devtest/flex-list.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
</div>
7474
<div class="flex-item-trailing">
7575
<a class="muted" href="{{$.Link}}">
76-
<span class="flex-text-inline"><i class="color-icon gt-mr-3" style="background-color: aqua"></i>Go</span>
76+
<span class="flex-text-inline"><i class="color-icon gt-mr-3 tw-bg-blue"></i>Go</span>
7777
</a>
7878
<a class="text grey flex-text-inline" href="{{$.Link}}">{{svg "octicon-star" 16}}45000</a>
7979
<a class="text grey flex-text-inline" href="{{$.Link}}">{{svg "octicon-git-branch" 16}}1234</a>

templates/devtest/tmplerr.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{{template "base/head" .}}
22
<div class="page-content devtest">
33
<div class="tw-flex">
4-
<div style="width: 80%; ">
4+
<div class="tw-w-4/5">
55
hello hello hello hello hello hello hello hello hello hello
66
</div>
7-
<div style="width: 20%;">
7+
<div class="tw-w-1/5">
88
{{template "devtest/tmplerr-sub" .}}
99
</div>
1010
</div>

templates/repo/diff/box.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@
119119
{{svg "octicon-chevron-down" 18}}
120120
{{end}}
121121
</button>
122-
<div class="gt-font-semibold tw-flex tw-items-center gt-mono">
122+
<div class="tw-font-semibold tw-flex tw-items-center gt-mono">
123123
{{if $file.IsBin}}
124124
<span class="gt-ml-1 gt-mr-3">
125125
{{ctx.Locale.Tr "repo.diff.bin"}}
@@ -178,7 +178,7 @@
178178
<div class="diff-file-body ui attached unstackable table segment" {{if and $file.IsViewed $.IsShowingAllCommits}}data-folded="true"{{end}}>
179179
<div id="diff-source-{{$file.NameHash}}" class="file-body file-code unicode-escaped code-diff{{if $.IsSplitStyle}} code-diff-split{{else}} code-diff-unified{{end}}{{if $showFileViewToggle}} gt-hidden{{end}}">
180180
{{if or $file.IsIncomplete $file.IsBin}}
181-
<div class="diff-file-body binary" style="padding: 5px 10px;">
181+
<div class="diff-file-body binary">
182182
{{if $file.IsIncomplete}}
183183
{{if $file.IsIncompleteLineTooLong}}
184184
{{ctx.Locale.Tr "repo.diff.file_suppressed_line_too_long"}}

templates/repo/diff/comments.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<div class="ui top attached header comment-header tw-flex tw-items-center tw-justify-between">
1212
<div class="comment-header-left tw-flex tw-items-center">
1313
{{if .OriginalAuthor}}
14-
<span class="text black gt-font-semibold gt-mr-2">
14+
<span class="text black tw-font-semibold gt-mr-2">
1515
{{svg (MigrationIcon $.root.Repository.GetOriginalURLHostname)}}
1616
{{.OriginalAuthor}}
1717
</span>

templates/repo/header.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</div>
99
<div class="flex-item-main">
1010
<div class="flex-item-title tw-text-18">
11-
<a class="muted gt-font-normal" href="{{.Owner.HomeLink}}">{{.Owner.Name}}</a>/<a class="muted" href="{{$.RepoLink}}">{{.Name}}</a>
11+
<a class="muted tw-font-normal" href="{{.Owner.HomeLink}}">{{.Owner.Name}}</a>/<a class="muted" href="{{$.RepoLink}}">{{.Name}}</a>
1212
</div>
1313
</div>
1414
<div class="flex-item-trailing">

0 commit comments

Comments
 (0)