1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2025-08-01 17:38:33 +00:00

Merge pull request 'feat: support regexp in git-grep search' (#4968) from yoctozepto/git-grep-regexp into forgejo

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4968
Reviewed-by: Shiny Nematoda <snematoda@noreply.codeberg.org>
This commit is contained in:
Otto 2024-10-04 17:10:14 +00:00
commit f7f7800460
14 changed files with 182 additions and 56 deletions

View file

@ -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" .}}

View file

@ -1,7 +1,7 @@
<div class="flex-text-block tw-flex-wrap">
{{range $term := .SearchResultLanguages}}
<a class="ui {{if eq $.Language $term.Language}}primary{{end}} basic label tw-m-0"
href="?q={{$.Keyword}}{{if ne $.Language $term.Language}}&l={{$term.Language}}{{end}}&fuzzy={{$.IsFuzzy}}">
href="?q={{$.Keyword}}{{if ne $.Language $term.Language}}&l={{$term.Language}}{{end}}&mode={{$.CodeSearchMode}}">
<i class="color-icon tw-mr-2" style="background-color: {{$term.Color}}"></i>
{{$term.Language}}
<div class="detail">{{$term.Count}}</div>

View file

@ -1,11 +1,11 @@
<form class="ui form ignore-dirty">
{{template "shared/search/combo_fuzzy"
{{template "shared/search/combo_multi"
dict
"Value" .Keyword
"Disabled" .CodeIndexerUnavailable
"IsFuzzy" .IsFuzzy
"Placeholder" (ctx.Locale.Tr "search.code_kind")
"CodeIndexerDisabled" $.CodeIndexerDisabled}}
"Selected" $.CodeSearchMode
"Options" $.CodeSearchOptions}}
</form>
<div class="divider"></div>
<div class="ui user list">

View file

@ -2,14 +2,12 @@
{{/* Disabled (optional) - if search field/button has to be disabled */}}
{{/* Placeholder (optional) - placeholder text to be used */}}
{{/* IsFuzzy - state of the fuzzy/union search toggle */}}
{{/* CodeIndexerDisabled (optional) - if the performed search is done using git-grep */}}
{{/* Tooltip (optional) - a tooltip to be displayed on button hover */}}
<div class="ui small fluid action input">
{{template "shared/search/input" dict "Value" .Value "Disabled" .Disabled "Placeholder" .Placeholder}}
{{template "shared/search/fuzzy"
dict
"Disabled" .Disabled
"IsFuzzy" .IsFuzzy
"CodeIndexerDisabled" .CodeIndexerDisabled}}
"IsFuzzy" .IsFuzzy}}
{{template "shared/search/button" dict "Disabled" .Disabled "Tooltip" .Tooltip}}
</div>

View file

@ -0,0 +1,24 @@
{{/* Value - value of the search field (for search results page) */}}
{{/* Disabled (optional) - if search field/button has to be disabled */}}
{{/* Placeholder (optional) - placeholder text to be used */}}
{{/* Selected - the currently selected option */}}
{{/* Options - options available to choose from */}}
{{/* Tooltip (optional) - a tooltip to be displayed on button hover */}}
<div class="ui small fluid action input">
{{template "shared/search/input" dict "Value" .Value "Disabled" .Disabled "Placeholder" .Placeholder}}
<div class="ui small dropdown selection {{if .Disabled}} disabled{{end}}" data-tooltip-content="{{ctx.Locale.Tr "search.type_tooltip"}}">
<div class="text">
{{ctx.Locale.Tr (printf "search.%s" .Selected)}}
</div>
<div class="menu" data-test-tag="fuzzy-dropdown">
{{range $opt := .Options}}
{{$isActive := eq $.Selected $opt}}
<label class="{{if $isActive}}active {{end}}item" data-value="{{$opt}}" data-tooltip-content="{{ctx.Locale.Tr (printf "search.%s_tooltip" $opt)}}">
<input hidden type="radio" name="mode" value="{{$opt}}"{{if $isActive}} checked{{end}}/>
{{ctx.Locale.Tr (printf "search.%s" $opt)}}
</label>
{{end}}
</div>
</div>
{{template "shared/search/button" dict "Disabled" .Disabled "Tooltip" .Tooltip}}
</div>

View file

@ -1,21 +1,15 @@
{{/* Disabled (optional) - if dropdown has to be disabled */}}
{{/* IsFuzzy - state of the fuzzy search toggle */}}
<div class="ui small dropdown selection {{if .Disabled}} disabled{{end}}" data-tooltip-content="{{ctx.Locale.Tr "search.type_tooltip"}}" data-test-tag="fuzzy-dropdown">
{{$fuzzyType := "fuzzy"}}
{{if .CodeIndexerDisabled}}
{{$fuzzyType = "union"}}
{{end}}
<div class="ui small dropdown selection {{if .Disabled}} disabled{{end}}" data-tooltip-content="{{ctx.Locale.Tr "search.type_tooltip"}}">
<input name="fuzzy" type="hidden"{{if .Disabled}} disabled{{end}} value="{{.IsFuzzy}}">{{svg "octicon-triangle-down" 14 "dropdown icon"}}
<div class="text">{{/*
if code indexer is disabled display fuzzy as union
*/}}{{if .IsFuzzy}}{{/*
*/}}{{ctx.Locale.Tr (printf "search.%s" $fuzzyType)}}{{/*
<div class="text">{{if .IsFuzzy}}{{/*
*/}}{{ctx.Locale.Tr "search.fuzzy"}}{{/*
*/}}{{else}}{{/*
*/}}{{ctx.Locale.Tr "search.exact"}}{{/*
*/}}{{end}}</div>
<div class="menu">
<div class="item" data-value="true" data-tooltip-content="{{ctx.Locale.Tr (printf "search.%s_tooltip" $fuzzyType)}}">{{/*
*/}}{{ctx.Locale.Tr (printf "search.%s" $fuzzyType)}}</div>
<div class="item" data-value="true" data-tooltip-content="{{ctx.Locale.Tr "search.fuzzy_tooltip"}}">{{/*
*/}}{{ctx.Locale.Tr "search.fuzzy"}}</div>
<div class="item" data-value="false" data-tooltip-content="{{ctx.Locale.Tr "search.exact_tooltip"}}">{{ctx.Locale.Tr "search.exact"}}</div>
</div>
</div>