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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
{{define "visibilityBadge" -}}
{{if eq (printf "%s" .) "PUBLIC" -}}
<span class="badge badge-success">public</span>
{{- else if eq (printf "%s" .) "UNLISTED" -}}
<span class="badge badge-warning">unlisted</span>
{{- else -}}
<span class="badge badge-secondary">private</span>
{{- end}}
{{- end}}
{{/*
viewtabs renders the alternative-view tab bar for a repo: one tab per
applicable View plus a "Tables" tab for the always-available generic browser.
Invoke it with a dict context:
{{template "viewtabs" (dict "Repo" .Repo "Views" .Views "Current" "" "Ref" .DefaultBranch)}}
.Current is the active view's slug ("" selects the Tables tab); .Ref is the
branch/ref the Tables tab links to (falls back to the overview when empty).
*/}}
{{define "viewtabs" -}}
{{$repo := .Repo}}{{$current := .Current}}{{$ref := .Ref}}
<ul class="nav nav-tabs mb-3">
{{range .Views}}
<li class="nav-item">
<a class="nav-link{{if eq .Name $current}} active{{end}}"
href="/~{{$repo.OwnerName}}/{{$repo.Name}}/view/{{.Name}}">{{.Label}}</a>
</li>
{{end}}
<li class="nav-item">
<a class="nav-link{{if eq $current ""}} active{{end}}"
href="{{if $ref}}/~{{$repo.OwnerName}}/{{$repo.Name}}/tree/{{$ref}}{{else}}/~{{$repo.OwnerName}}/{{$repo.Name}}{{end}}">Tables</a>
</li>
</ul>
{{- end}}
{{define "repoList" -}}
{{if .}}
<div class="repo-list">
{{range .}}
<span>
<a href="/~{{.OwnerName}}/{{.Name}}">~{{.OwnerName}}/{{.Name}}</a>
{{template "visibilityBadge" .Visibility}}
</span>
<span class="text-muted">{{.Description}}</span>
{{end}}
</div>
{{else}}
<p class="text-muted">No databases yet.</p>
{{end}}
{{- end}}