~bigbes/sr-ht-dolt

ref: c82f106f9e36a8ce14539fdc64d0083b98a90773 sr-ht-dolt/web/templates/_partials.html -rw-r--r-- 2.7 KiB
c82f106f — Eugene Blikh beads: stop flattening a stored NULL string 5 days ago
                                                                                
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
{{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 repo's tab bar: a fixed "Overview" tab, a "Tables" tab for
  the always-available generic browser, then one tab per applicable View.
  Invoke it with a dict context:
    {{template "viewtabs" (dict "Repo" .Repo "Views" .Views "Current" "overview" "Ref" .DefaultBranch)}}
  .Current selects the active tab: "overview", "tables", or a view's slug. .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">
  <li class="nav-item">
    <a class="nav-link{{if eq $current "overview"}} active{{end}}"
       href="/~{{$repo.OwnerName}}/{{$repo.Name}}">Overview</a>
  </li>
  <li class="nav-item">
    <a class="nav-link{{if eq $current "tables"}} active{{end}}"
       href="{{if $ref}}/~{{$repo.OwnerName}}/{{$repo.Name}}/tree/{{$ref}}{{else}}/~{{$repo.OwnerName}}/{{$repo.Name}}{{end}}">Tables</a>
  </li>
  {{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}}
</ul>
{{- end}}

{{/*
  beadsHead renders the freshness line the beads-family views carry under their
  title: "<branch> · last commit <relative> · <short hash>", the hash linking to
  the commit page and the exact stamp one hover away in the title attribute.
  Invoke it with a dict context, as viewtabs above:
    {{template "beadsHead" (dict "Repo" .Repo "Ref" .Ref "Head" .Head)}}
  .Head is the envelope's *browse.CommitInfo (handleView fills it for every
  view). It is nil for a database with no commits, or when reading the log
  failed, and then this renders nothing at all: the line says how fresh the page
  is, and a line that cannot answer that must not draw a shape that looks like
  an answer. The class is styled by each page's own scoped stylesheet.
*/}}
{{define "beadsHead" -}}
{{with .Head}}
<p class="beads-freshness">{{$.Ref}} &middot; last commit
  <span title="{{.Date | abstime}}">{{.Date | ago}}</span> &middot;
  <a href="/~{{$.Repo.OwnerName}}/{{$.Repo.Name}}/commit/{{.Hash}}"><code>{{.Hash | shortsha}}</code></a></p>
{{end}}
{{- end}}

{{/*
  The database listing used to live here as "repoList". It is now sr-ht-ecore's
  "srht-repo-list", whose markup this copy already matched line for line;
  handlers build its chrome.RepoList dot (repoList in handlers_repo.go).
*/}}