diff options
author | Daniel Baumann <daniel@debian.org> | 2024-10-18 20:33:49 +0200 |
---|---|---|
committer | Daniel Baumann <daniel@debian.org> | 2024-12-12 23:57:56 +0100 |
commit | e68b9d00a6e05b3a941f63ffb696f91e554ac5ec (patch) | |
tree | 97775d6c13b0f416af55314eb6a89ef792474615 /templates/shared/search | |
parent | Initial commit. (diff) | |
download | forgejo-e68b9d00a6e05b3a941f63ffb696f91e554ac5ec.tar.xz forgejo-e68b9d00a6e05b3a941f63ffb696f91e554ac5ec.zip |
Adding upstream version 9.0.3.
Signed-off-by: Daniel Baumann <daniel@debian.org>
Diffstat (limited to '')
-rw-r--r-- | templates/shared/search/button.tmpl | 3 | ||||
-rw-r--r-- | templates/shared/search/code/results.tmpl | 44 | ||||
-rw-r--r-- | templates/shared/search/code/search.tmpl | 28 | ||||
-rw-r--r-- | templates/shared/search/combo.tmpl | 8 | ||||
-rw-r--r-- | templates/shared/search/combo_fuzzy.tmpl | 15 | ||||
-rw-r--r-- | templates/shared/search/fuzzy.tmpl | 21 | ||||
-rw-r--r-- | templates/shared/search/input.tmpl | 4 | ||||
-rw-r--r-- | templates/shared/searchbottom.tmpl | 14 | ||||
-rw-r--r-- | templates/shared/searchfile.tmpl | 25 |
9 files changed, 162 insertions, 0 deletions
diff --git a/templates/shared/search/button.tmpl b/templates/shared/search/button.tmpl new file mode 100644 index 0000000..7bb1662 --- /dev/null +++ b/templates/shared/search/button.tmpl @@ -0,0 +1,3 @@ +{{/* Disable (optional) - if search button has to be disabled */}} +{{/* Tooltip (optional) - a tooltip to be displayed on hover */}} +<button class="ui small icon button" aria-label="{{ctx.Locale.Tr "search.search"}}" {{with .Tooltip}}data-tooltip-content="{{.}}"{{end}}{{if .Disabled}} disabled{{end}}>{{svg "octicon-search"}}</button> diff --git a/templates/shared/search/code/results.tmpl b/templates/shared/search/code/results.tmpl new file mode 100644 index 0000000..fe37557 --- /dev/null +++ b/templates/shared/search/code/results.tmpl @@ -0,0 +1,44 @@ +<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}}"> + <i class="color-icon tw-mr-2" 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 := 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"> + <span class="tw-h-4 tw-transition -tw-rotate-90 group-open:tw-rotate-0"> + {{svg "octicon-chevron-down"}} + </span> + {{if not $.Repo}} + <span class="file tw-flex-1 tw-ml-2"> + <a rel="nofollow" href="{{$repo.Link}}">{{$repo.FullName}}</a> + {{if $repo.IsArchived}} + <span class="ui basic label">{{ctx.Locale.Tr "repo.desc.archived"}}</span> + {{end}} + - {{.Filename}} + </span> + {{else}} + <span class="file tw-flex-1 tw-ml-2"> + <a rel="nofollow" class="muted file-link" href="{{$repo.Link}}/src/commit/{{$result.CommitID | PathEscape}}/{{.Filename | PathEscapeSegments}}">{{/* + */}}{{.Filename}}</a> + </span> + {{end}} + <a role="button" class="ui basic tiny button" rel="nofollow" href="{{$repo.Link}}/src/commit/{{$result.CommitID | PathEscape}}/{{.Filename | PathEscapeSegments}}">{{ctx.Locale.Tr "repo.diff.view_file"}}</a> + </h4> + </summary> + <div class="ui attached table segment"> + {{template "shared/searchfile" dict "RepoLink" $repo.Link "SearchResult" .}} + </div> + {{template "shared/searchbottom" dict "root" $ "result" .}} + </details> + {{end}} +</div> +{{template "base/paginate" .}} diff --git a/templates/shared/search/code/search.tmpl b/templates/shared/search/code/search.tmpl new file mode 100644 index 0000000..6a52bb9 --- /dev/null +++ b/templates/shared/search/code/search.tmpl @@ -0,0 +1,28 @@ +<form class="ui form ignore-dirty"> + {{template "shared/search/combo_fuzzy" + dict + "Value" .Keyword + "Disabled" .CodeIndexerUnavailable + "IsFuzzy" .IsFuzzy + "Placeholder" (ctx.Locale.Tr "search.code_kind") + "CodeIndexerDisabled" $.CodeIndexerDisabled}} +</form> +<div class="divider"></div> +<div class="ui user list"> + {{if .CodeIndexerUnavailable}} + <div class="ui error message"> + <p>{{ctx.Locale.Tr "search.code_search_unavailable"}}</p> + </div> + {{else}} + {{if .CodeIndexerDisabled}} + <div class="ui message" data-test-tag="grep"> + <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> diff --git a/templates/shared/search/combo.tmpl b/templates/shared/search/combo.tmpl new file mode 100644 index 0000000..788db95 --- /dev/null +++ b/templates/shared/search/combo.tmpl @@ -0,0 +1,8 @@ +{{/* 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 */}} +{{/* 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/button" dict "Disabled" .Disabled "Tooltip" .Tooltip}} +</div> diff --git a/templates/shared/search/combo_fuzzy.tmpl b/templates/shared/search/combo_fuzzy.tmpl new file mode 100644 index 0000000..38189b0 --- /dev/null +++ b/templates/shared/search/combo_fuzzy.tmpl @@ -0,0 +1,15 @@ +{{/* 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 */}} +{{/* 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}} + {{template "shared/search/button" dict "Disabled" .Disabled "Tooltip" .Tooltip}} +</div> diff --git a/templates/shared/search/fuzzy.tmpl b/templates/shared/search/fuzzy.tmpl new file mode 100644 index 0000000..25cfc57 --- /dev/null +++ b/templates/shared/search/fuzzy.tmpl @@ -0,0 +1,21 @@ +{{/* 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}} + <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)}}{{/* + */}}{{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="false" data-tooltip-content="{{ctx.Locale.Tr "search.exact_tooltip"}}">{{ctx.Locale.Tr "search.exact"}}</div> + </div> +</div> diff --git a/templates/shared/search/input.tmpl b/templates/shared/search/input.tmpl new file mode 100644 index 0000000..195cefc --- /dev/null +++ b/templates/shared/search/input.tmpl @@ -0,0 +1,4 @@ +{{/* Value - value of the search field (for search results page) */}} +{{/* Disabled (optional) - if search field has to be disabled */}} +{{/* Placeholder (optional) - placeholder text to be used */}} +<input type="search" spellcheck="false" name="q" maxlength="255" placeholder="{{with .Placeholder}}{{.}}{{else}}{{ctx.Locale.Tr "search.search"}}{{end}}"{{with .Value}} value="{{.}}"{{end}}{{if .Disabled}} disabled{{end}}> diff --git a/templates/shared/searchbottom.tmpl b/templates/shared/searchbottom.tmpl new file mode 100644 index 0000000..bee0397 --- /dev/null +++ b/templates/shared/searchbottom.tmpl @@ -0,0 +1,14 @@ +{{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 tw-ml-4"> + {{if .result.Language}} + <i class="color-icon tw-mr-2" style="background-color: {{.result.Color}}"></i>{{.result.Language}} + {{end}} + </div> + <div class="tw-mr-4"> + {{if not .result.UpdatedUnix.IsZero}} + <span class="ui grey text">{{ctx.Locale.Tr "explore.code_last_indexed_at" (TimeSinceUnix .result.UpdatedUnix ctx.Locale)}}</span> + {{end}} + </div> +</div> +{{end}} diff --git a/templates/shared/searchfile.tmpl b/templates/shared/searchfile.tmpl new file mode 100644 index 0000000..a051742 --- /dev/null +++ b/templates/shared/searchfile.tmpl @@ -0,0 +1,25 @@ +<div class="file-body file-code code-view"> + <div> + <ol class="tw-p-0 tw-m-0"> + {{/* if the expected line number does not match + the actual line number end the ordered list + and begin a new one */}} + {{$expNum := 0}} + {{range .SearchResult.Lines}} + {{if and (gt $expNum 0) (ne .Num $expNum)}} + </ol> + <ol class="tw-p-0 tw-m-0 tw-pt-2 tw-mt-2 tw-border-t-4 tw-border-secondary"> + {{end}} + <li value="{{.Num}}" class="tw-grid tw-grid-cols-[minmax(50px,_1%)_auto] tw-list-none"> + <div class="lines-num"> + <a href="{{$.RepoLink}}/src/commit/{{PathEscape $.SearchResult.CommitID}}/{{PathEscapeSegments $.SearchResult.Filename}}#L{{.Num}}"> + {{.Num}} + </a> + </div> + <div class="lines-code chroma"><code class="code-inner">{{.FormattedContent}}</code></div> + </li> + {{$expNum = Eval .Num "+" 1}} + {{end}} + </ol> + </div> +</div> |