{{ define "title" }}{{ if eq .FilterType "code" }}Code Search{{ else }}Search{{ end }} · Tangled{{ end }} {{ define "content" }}

{{ if eq .FilterType "code" }}Code Search{{ else }}Search{{ end }}

{{ template "searchBar" . }} {{ template "searchResults" . }}
{{ end }} {{ define "searchBar" }}

Filters

{{ template "searchTypeSwitcher" . }} {{ if eq .FilterType "repo" }}

Sort by

{{ template "sortOptionsList" . }}
{{ end }}

Languages

{{ template "languageFilters" . }}
{{ end }} {{ define "searchResults" }} {{ if .ErrorMsg }}
{{ i "circle-alert" "size-4" }} {{ .ErrorMsg }}
{{ else if eq .FilterType "code" }} {{ template "codeSearchResults" . }} {{ else }} {{ template "repoSearchResults" . }} {{ end }} {{ end }} {{ define "repoSearchResults" }}
{{ range .Repos }} {{ template "search/fragments/resultCard" . }} {{ else }}
No repositories found.
{{ end }}
{{ template "searchStatistics" . }}
{{if gt .ResultCount .Page.Limit }} {{ template "fragments/pagination" (dict "Page" .Page "TotalCount" .ResultCount "BasePath" "search" "QueryParams" (queryParams "q" .FilterQuery "sort" .SortParam "type" .FilterType) ) }} {{ end }} {{ end }} {{ define "codeSearchResults" }}
{{ range .Results }} {{ template "search/fragments/resultCard" . }} {{ else }}
No results found.
{{ end }}
{{ template "searchStatistics" . }}
{{ if or (gt .Page.Offset 0) .HasMore }} {{ template "fragments/pagination" (dict "Page" .Page "BasePath" "search" "QueryParams" (queryParams "q" .FilterQuery "type" .FilterType) "HasMore" .HasMore ) }} {{ end }} {{ end }} {{ define "searchOptionsPanel" }}
{{ template "searchTypeSwitcher" . }} {{ if eq .FilterType "repo" }}

Sort by

{{ template "sortOptionsList" . }}
{{ end }}

Languages

{{ template "languageFilters" . }}
{{ template "searchStatistics" . }}
{{ end }} {{ define "searchTypeSwitcher" }}

Filter by

{{ $options := list (dict "value" "repo" "name" "Repositories") (dict "value" "code" "name" "Code") }} {{ range $options }} {{ end }}
{{ end }} {{ define "sortOptionsList" }} {{ if eq .FilterType "repo" }} {{ end }} {{ end }} {{ define "languageFilters" }} {{ $commonLanguages := list "Go" "JavaScript" "TypeScript" "Python" "Rust" "OCaml" "Haskell" "C" "C++" "Ruby" "Swift" }}
{{ range $commonLanguages }} {{ $lang := . }} {{ template "languageFilterChip" (dict "Language" $lang "CurrentQuery" $.FilterQuery "FilterType" $.FilterType) }} {{ end }}
{{ end }} {{ define "languageFilterChip" }} {{ $lang := .Language }} {{ $currentQuery := .CurrentQuery }} {{ $filterType := .FilterType }} {{ $langColor := langColor $lang }} {{ $newQuery := queryParams "q" (printf "lang:%s %s" $lang $currentQuery) "type" $filterType }} {{ template "repo/fragments/colorBall" (dict "color" $langColor) }} {{ $lang }} {{ end }} {{ define "searchStatistics" }} {{ if eq .FilterType "code" }} {{ if gt .MatchCount 0 }}
Found {{ .MatchCount }} results in {{ .FileCount }} files in {{ .TimeTaken }}
{{ end }} {{ else }} {{ if gt .ResultCount 0 }}
Returned {{ .ResultCount }} of {{ .DocCount }} repos in {{ .TimeTaken }}
{{ end }} {{ end }} {{ end }}