diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-10-11 10:27:00 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-10-11 10:27:00 +0000 |
commit | 65aa53fc52ff15efe54df4147564828d535837f8 (patch) | |
tree | 31c51dad04fdcca80e6d3043c8bd49d2f1a51f83 /templates/shared/search | |
parent | Initial commit. (diff) | |
download | forgejo-65aa53fc52ff15efe54df4147564828d535837f8.tar.xz forgejo-65aa53fc52ff15efe54df4147564828d535837f8.zip |
Adding upstream version 8.0.3.HEADupstream/8.0.3upstreamdebian
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'templates/shared/search')
-rw-r--r-- | templates/shared/search/button.tmpl | 3 | ||||
-rw-r--r-- | templates/shared/search/code/results.tmpl | 41 | ||||
-rw-r--r-- | templates/shared/search/code/search.tmpl | 22 | ||||
-rw-r--r-- | templates/shared/search/combo.tmpl | 8 | ||||
-rw-r--r-- | templates/shared/search/combo_fuzzy.tmpl | 10 | ||||
-rw-r--r-- | templates/shared/search/fuzzy.tmpl | 10 | ||||
-rw-r--r-- | templates/shared/search/input.tmpl | 4 |
7 files changed, 98 insertions, 0 deletions
diff --git a/templates/shared/search/button.tmpl b/templates/shared/search/button.tmpl new file mode 100644 index 00000000..7bb1662e --- /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 00000000..50d4a35c --- /dev/null +++ b/templates/shared/search/code/results.tmpl @@ -0,0 +1,41 @@ +<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">{{.Filename}}</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 00000000..37a23dc3 --- /dev/null +++ b/templates/shared/search/code/search.tmpl @@ -0,0 +1,22 @@ +<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")}} +</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 00000000..788db95c --- /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 00000000..3540a89e --- /dev/null +++ b/templates/shared/search/combo_fuzzy.tmpl @@ -0,0 +1,10 @@ +{{/* 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 search toggle */}} +{{/* 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}} + {{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 00000000..5c09d3c1 --- /dev/null +++ b/templates/shared/search/fuzzy.tmpl @@ -0,0 +1,10 @@ +{{/* 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"}}"> + <input name="fuzzy" type="hidden"{{if .Disabled}} disabled{{end}} value="{{.IsFuzzy}}">{{svg "octicon-triangle-down" 14 "dropdown icon"}} + <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 "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> diff --git a/templates/shared/search/input.tmpl b/templates/shared/search/input.tmpl new file mode 100644 index 00000000..195cefc2 --- /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}}> |