mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-06-23 09:30:50 +00:00
feat: filepath filter for code search (#6143)
Added support for searching content in a specific directory or file. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/6143 Reviewed-by: Gusted <gusted@noreply.codeberg.org> Reviewed-by: 0ko <0ko@noreply.codeberg.org> Co-authored-by: Shiny Nematoda <snematoda.751k2@aleeas.com> Co-committed-by: Shiny Nematoda <snematoda.751k2@aleeas.com>
This commit is contained in:
parent
bb88e1daf8
commit
ee214cb886
19 changed files with 342 additions and 61 deletions
|
@ -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}}&mode={{$.CodeSearchMode}}">
|
||||
href="?q={{$.Keyword}}{{if ne $.Language $term.Language}}&l={{$term.Language}}{{end}}&mode={{$.CodeSearchMode}}&path={{$.CodeSearchPath}}">
|
||||
<i class="color-icon tw-mr-2" style="background-color: {{$term.Color}}"></i>
|
||||
{{$term.Language}}
|
||||
<div class="detail">{{$term.Count}}</div>
|
||||
|
@ -13,7 +13,7 @@
|
|||
{{$repo := or $.Repo (index $.RepoMaps .RepoID)}}
|
||||
<details class="tw-group diff-file-box diff-box file-content non-diff-file-content repo-search-result" open>
|
||||
<summary class="tw-list-none">
|
||||
<h4 class="ui top attached header tw-font-normal tw-flex tw-flex-wrap tw-transform-reset">
|
||||
<h4 class="ui top attached header tw-font-normal tw-flex tw-items-center tw-flex-wrap tw-transform-reset">
|
||||
<span class="tw-h-4 tw-transition -tw-rotate-90 group-open:tw-rotate-0">
|
||||
{{svg "octicon-chevron-down"}}
|
||||
</span>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<form class="ui form ignore-dirty">
|
||||
<input type="hidden" name="path" value="{{.CodeSearchPath}}">
|
||||
{{template "shared/search/combo_multi"
|
||||
dict
|
||||
"Value" .Keyword
|
||||
|
@ -14,6 +15,23 @@
|
|||
<p>{{ctx.Locale.Tr "search.code_search_unavailable"}}</p>
|
||||
</div>
|
||||
{{else}}
|
||||
{{if .CodeSearchPath}}
|
||||
<div class="tw-mb-4">
|
||||
<span class="breadcrumb">
|
||||
<a class="section" href="?q={{.Keyword}}&mode={{.CodeSearchMode}}">@</a>
|
||||
{{$href := ""}}
|
||||
{{- range $i, $path := StringUtils.Split .CodeSearchPath "/" -}}
|
||||
{{if eq $i 0}}
|
||||
{{$href = $path}}
|
||||
{{else}}
|
||||
{{$href = StringUtils.Join (StringUtils.Make $href $path) "/"}}
|
||||
{{end}}
|
||||
<span class="breadcrumb-divider">/</span>
|
||||
<span class="section"><a href="?q={{$.Keyword}}&mode={{$.CodeSearchMode}}&path={{$href}}">{{$path}}</a></span>
|
||||
{{- end -}}
|
||||
</span>
|
||||
</div>
|
||||
{{end}}
|
||||
{{if .CodeIndexerDisabled}}
|
||||
<div class="ui message" data-test-tag="grep">
|
||||
<p>{{ctx.Locale.Tr "search.code_search_by_git_grep"}}</p>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue