~gitpocket/gitpocket

6
d819768dc704b922aab16b17207fced6a6759537
mainfeed-discovery
gitpocket/templates/search.html -rw-r--r--3.4 KiB ViewLogBlameView rawPermalink d819768dc7 feat(web): site search over repositories and users with language facets and breakdowns yesterday
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
{{define "content"}}
{{$d := .Data}}
<div class="searchwrap">
<form class="bigsearch" method="get" action="/search"><input name="q" value="{{$d.Query}}" placeholder="Search repositories, people, languages" autofocus><input type="hidden" name="type" value="{{$d.Type}}">{{with $d.Lang}}<input type="hidden" name="lang" value="{{.}}">{{end}}<button class="btn primary">Search</button></form>
<div class="searchpage">
<aside class="facets">
<h4>Filter by</h4>
<nav class="facetlist">
<a href="?q={{$d.Query}}&type=repos{{with $d.Lang}}&lang={{.}}{{end}}"{{if eq $d.Type "repos"}} class="active"{{end}}><span>Repositories</span><span class="count">{{len $d.Repos}}</span></a>
<a href="?q={{$d.Query}}&type=users{{with $d.Lang}}&lang={{.}}{{end}}"{{if eq $d.Type "users"}} class="active"{{end}}><span>Users</span><span class="count">{{len $d.Users}}</span></a>
</nav>
{{if $d.Languages}}<h4>Languages</h4>
<nav class="facetlist">{{range $d.Languages}}<a href="?q={{$d.Query}}&type={{$d.Type}}&lang={{.Name}}"{{if eq .Name $d.Lang}} class="active"{{end}}><span><i class="dot" style="background:{{.Colour}}"></i>{{.Name}}</span><span class="count">{{.Count}}</span></a>{{end}}</nav>
{{with $d.Lang}}<p class="small"><a href="?q={{$d.Query}}&type={{$d.Type}}">Clear language</a></p>{{end}}{{end}}
</aside>
<div class="results">
{{if eq $d.Type "repos"}}
<div class="resulthead"><h3 class="plain">{{len $d.Repos}} repositor{{if eq (len $d.Repos) 1}}y{{else}}ies{{end}}{{with $d.Query}} matching <q>{{.}}</q>{{end}}{{with $d.Lang}} in {{.}}{{end}}</h3>
<nav class="sorts"><a href="?q={{$d.Query}}&type=repos{{with $d.Lang}}&lang={{.}}{{end}}"{{if not $d.Sort}} class="active"{{end}}>Best match</a><a href="?q={{$d.Query}}&type=repos&sort=updated{{with $d.Lang}}&lang={{.}}{{end}}"{{if eq $d.Sort "updated"}} class="active"{{end}}>Recently updated</a><a href="?q={{$d.Query}}&type=repos&sort=stars{{with $d.Lang}}&lang={{.}}{{end}}"{{if eq $d.Sort "stars"}} class="active"{{end}}>Most stars</a></nav></div>
{{range $d.Repos}}<div class="hit"><h4><a class="owner" href="/~{{.Owner.Name}}">~{{.Owner.Name}}</a>/<a href="/{{.Path}}">{{.Name}}</a></h4>{{with .Description}}<p>{{.}}</p>{{end}}{{if .Tags}}<p class="tags">{{range .Tags}}<a href="/projects?tag={{.}}">#{{.}}</a>{{end}}</p>{{end}}<p class="meta">{{with .Language}}<span><i class="dot" style="background:{{.Colour}}"></i>{{.Name}}</span>{{end}}{{if .Stars}}<span>☆ {{.Stars}}</span>{{end}}<span>Updated {{ago .Updated}}</span></p></div>{{else}}<p class="info">No repositories match. Try a shorter query or clear the language filter.</p>{{end}}
{{else}}
<div class="resulthead"><h3 class="plain">{{len $d.Users}} user{{if ne (len $d.Users) 1}}s{{end}}{{with $d.Query}} matching <q>{{.}}</q>{{end}}{{with $d.Lang}} writing {{.}}{{end}}</h3></div>
{{range $d.Users}}<div class="hit user"><a href="/~{{.Name}}" class="hitavatar">{{if .Profile.Avatar}}<img src="/~{{.Name}}/avatar?v={{.Profile.Avatar}}" alt="">{{else}}<span>{{slice .Name 0 1}}</span>{{end}}</a><div><h4><a href="/~{{.Name}}">{{with .Profile.Display}}{{.}}{{else}}~{{.Name}}{{end}}</a> <span class="muted">~{{.Name}}</span></h4>{{with .Profile.Bio}}<p class="bio">{{.}}</p>{{end}}<p class="meta">{{with .Profile.Location}}<span>{{.}}</span>{{end}}<span>{{.Repos}} public repositor{{if eq .Repos 1}}y{{else}}ies{{end}}</span><span>Joined {{.Created.Format "January 2006"}}</span></p></div></div>{{else}}<p class="info">No users match.</p>{{end}}
{{end}}
</div>
</div>
</div>
{{end}}