mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-06-17 11:59:30 +00:00
Support repo code search without setting up an indexer (#29998)
By using git's ability, end users (especially small instance users) do not need to enable the indexer, they could also benefit from the code searching feature. Fix #29996   --------- Co-authored-by: silverwind <me@silverwind.io>
This commit is contained in:
parent
488a99fb56
commit
1e7a6483b8
12 changed files with 254 additions and 60 deletions
|
@ -5,29 +5,18 @@
|
|||
{{template "base/alert" .}}
|
||||
{{template "repo/code/recently_pushed_new_branches" .}}
|
||||
{{if and (not .HideRepoInfo) (not .IsBlame)}}
|
||||
<div class="ui repo-description gt-word-break">
|
||||
<div id="repo-desc" class="tw-text-16">
|
||||
<div class="repo-description">
|
||||
<div id="repo-desc" class="gt-word-break tw-text-16">
|
||||
{{$description := .Repository.DescriptionHTML $.Context}}
|
||||
{{if $description}}<span class="description">{{$description | RenderCodeBlock}}</span>{{else if .IsRepositoryAdmin}}<span class="no-description text-italic">{{ctx.Locale.Tr "repo.no_desc"}}</span>{{end}}
|
||||
<a class="link" href="{{.Repository.Website}}">{{.Repository.Website}}</a>
|
||||
</div>
|
||||
{{if .RepoSearchEnabled}}
|
||||
<div class="ui repo-search">
|
||||
<form class="ui form ignore-dirty" action="{{.RepoLink}}/search" method="get">
|
||||
<div class="field">
|
||||
<div class="ui small action input{{if .CodeIndexerUnavailable}} disabled left icon{{end}}"{{if .CodeIndexerUnavailable}} data-tooltip-content="{{ctx.Locale.Tr "search.code_search_unavailable"}}"{{end}}>
|
||||
<input name="q" value="{{.Keyword}}"{{if .CodeIndexerUnavailable}} disabled{{end}} placeholder="{{ctx.Locale.Tr "search.code_kind"}}">
|
||||
{{if .CodeIndexerUnavailable}}
|
||||
<i class="icon">{{svg "octicon-alert"}}</i>
|
||||
{{end}}
|
||||
<button class="ui small icon button"{{if .CodeIndexerUnavailable}} disabled{{end}} type="submit">
|
||||
{{svg "octicon-search"}}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<form class="ignore-dirty" action="{{.RepoLink}}/search" method="get">
|
||||
<div class="ui small action input">
|
||||
<input name="q" value="{{.Keyword}}" placeholder="{{ctx.Locale.Tr "search.code_kind"}}">
|
||||
{{template "shared/search/button"}}
|
||||
</div>
|
||||
{{end}}
|
||||
</form>
|
||||
</div>
|
||||
<div class="tw-flex tw-items-center tw-flex-wrap tw-gap-1" id="repo-topics">
|
||||
{{range .Topics}}<a class="ui repo-topic large label topic gt-m-0" href="{{AppSubUrl}}/explore/repos?q={{.Name}}&topic=1">{{.Name}}</a>{{end}}
|
||||
|
|
|
@ -11,9 +11,16 @@
|
|||
<div class="ui error message">
|
||||
<p>{{ctx.Locale.Tr "search.code_search_unavailable"}}</p>
|
||||
</div>
|
||||
{{else if .SearchResults}}
|
||||
{{template "shared/search/code/results" .}}
|
||||
{{else if .Keyword}}
|
||||
<div>{{ctx.Locale.Tr "search.no_results"}}</div>
|
||||
{{else}}
|
||||
{{if not .CodeIndexerEnabled}}
|
||||
<div class="ui message">
|
||||
<p>{{ctx.Locale.Tr "search.code_search_by_git_grep"}}</p>
|
||||
</div>
|
||||
{{end}}
|
||||
{{if .SearchResults}}
|
||||
{{template "shared/search/code/results" .}}
|
||||
{{else if .Keyword}}
|
||||
<div>{{ctx.Locale.Tr "search.no_results"}}</div>
|
||||
{{end}}
|
||||
{{end}}
|
||||
</div>
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
{{if or .result.Language (not .result.UpdatedUnix.IsZero)}}
|
||||
<div class="ui bottom attached table segment tw-flex tw-items-center tw-justify-between">
|
||||
<div class="tw-flex tw-items-center gt-ml-4">
|
||||
{{if .result.Language}}
|
||||
|
@ -10,3 +11,4 @@
|
|||
{{end}}
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue