diff options
author | Lauris BH <lauris@nix.lv> | 2022-10-11 02:12:03 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-11 00:12:03 +0100 |
commit | b59b0cad0a550223f74add109ff13c0d2f4309f3 (patch) | |
tree | 4c4d0482ca8740390b5939c3979d1fef35cb9047 /templates/code | |
parent | 3ccebf7f4044b85eef975e4544785893da763bd2 (diff) | |
download | gitea-b59b0cad0a550223f74add109ff13c0d2f4309f3.tar.gz gitea-b59b0cad0a550223f74add109ff13c0d2f4309f3.zip |
Add user/organization code search (#19977)
Fixes #19925
Screenshots:
![attels](https://user-images.githubusercontent.com/165205/173864718-fe789429-55bc-4cad-808c-9f02f335cddf.png)
Diffstat (limited to 'templates/code')
-rw-r--r-- | templates/code/searchform.tmpl | 14 | ||||
-rw-r--r-- | templates/code/searchresults.tmpl | 43 |
2 files changed, 57 insertions, 0 deletions
diff --git a/templates/code/searchform.tmpl b/templates/code/searchform.tmpl new file mode 100644 index 0000000000..26611cf4b2 --- /dev/null +++ b/templates/code/searchform.tmpl @@ -0,0 +1,14 @@ +<form class="ui form ignore-dirty" style="max-width: 100%"> + <div class="ui fluid action input"> + <input name="q" value="{{.Keyword}}"{{if .CodeIndexerUnavailable }} disabled{{end}} placeholder="{{.locale.Tr "explore.search"}}…" autofocus> + <div class="ui dropdown selection tooltip{{if .CodeIndexerUnavailable }} disabled{{end}}" data-content="{{.locale.Tr "explore.search.type.tooltip"}}"> + <input name="t" type="hidden" value="{{.queryType}}"{{if .CodeIndexerUnavailable }} disabled{{end}}>{{svg "octicon-triangle-down" 14 "dropdown icon"}} + <div class="text">{{.locale.Tr (printf "explore.search.%s" (or .queryType "fuzzy"))}}</div> + <div class="menu transition hidden" tabindex="-1" style="display: block !important;"> + <div class="item tooltip" data-value="" data-content="{{.locale.Tr "explore.search.fuzzy.tooltip"}}">{{.locale.Tr "explore.search.fuzzy"}}</div> + <div class="item tooltip" data-value="match" data-content="{{.locale.Tr "explore.search.match.tooltip"}}">{{.locale.Tr "explore.search.match"}}</div> + </div> + </div> + <button class="ui primary button"{{if .CodeIndexerUnavailable }} disabled{{end}}>{{.locale.Tr "explore.search"}}</button> + </div> +</form> diff --git a/templates/code/searchresults.tmpl b/templates/code/searchresults.tmpl new file mode 100644 index 0000000000..e21a50e1f1 --- /dev/null +++ b/templates/code/searchresults.tmpl @@ -0,0 +1,43 @@ +<div class="df ac fw"> + {{range $term := .SearchResultLanguages}} + <a class="ui text-label df ac mr-1 my-1 {{if eq $.Language $term.Language}}primary {{end}}basic label" href="{{AppSubUrl}}{{if $.ContextUser}}/{{$.ContextUser.Name}}/-/code{{else}}/explore/code{{end}}?q={{$.Keyword}}{{if ne $.Language $term.Language}}&l={{$term.Language}}{{end}}{{if ne $.queryType ""}}&t={{$.queryType}}{{end}}"> + <i class="color-icon mr-3" style="background-color: {{$term.Color}}"></i> + {{$term.Language}} + <div class="detail">{{$term.Count}}</div> + </a> + {{end}} +</div> +<div class="repository search"> + {{range $result := .SearchResults}} + {{$repo := (index $.RepoMaps .RepoID)}} + <div class="diff-file-box diff-box file-content non-diff-file-content repo-search-result"> + <h4 class="ui top attached normal header"> + <span class="file"> + <a rel="nofollow" href="{{$repo.HTMLURL}}">{{$repo.FullName}}</a> + {{if $repo.IsArchived}} + <span class="ui basic label">{{$.locale.Tr "repo.desc.archived"}}</span> + {{end}} + - {{.Filename}} + </span> + <a class="ui basic tiny button" rel="nofollow" href="{{$repo.HTMLURL}}/src/commit/{{$result.CommitID | PathEscape}}/{{.Filename | PathEscapeSegments}}">{{$.locale.Tr "repo.diff.view_file"}}</a> + </h4> + <div class="ui attached table segment"> + <div class="file-body file-code code-view"> + <table> + <tbody> + <tr> + <td class="lines-num"> + {{range .LineNumbers}} + <a href="{{$repo.HTMLURL}}/src/commit/{{$result.CommitID | PathEscape}}/{{$result.Filename | PathEscapeSegments}}#L{{.}}"><span>{{.}}</span></a> + {{end}} + </td> + <td class="lines-code chroma"><code class="code-inner">{{.FormattedLines | Safe}}</code></td> + </tr> + </tbody> + </table> + </div> + </div> + {{template "shared/searchbottom" dict "root" $ "result" .}} + </div> + {{end}} +</div> |