summaryrefslogtreecommitdiff
path: root/web/templates/layout.tmpl
blob: 969cae6b9a2dc16fba9581a257c22027dda44aa3 (plain) (blame)
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<!doctype html>
<html lang="en"{{if .Live}} data-live="1"{{end}}>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{{.Title}}</title>
<link rel="icon" type="image/svg+xml" href="{{.Href "asset" "bemtevi.svg"}}">
<link rel="stylesheet" href="{{.Href "asset" "style.css"}}">
<script>
// the theme is worn before the first paint. A theme that is not one of the
// two the site was built with lives in themes.css, so pull that in too —
// from here, after style.css, so its :root block is the one that wins.
{const d = document.documentElement, t = localStorage.getItem("notevi-theme");
 if (t && t !== "system") d.dataset.theme = t;
 if (t && !/^(system|dark|light)$/.test(t)) {
   const l = document.createElement("link");
   l.rel = "stylesheet"; l.id = "themescss"; l.href = "{{.Href "asset" "themes.css"}}";
   document.head.append(l);
 }
 d.dataset.mode = localStorage.getItem("notevi-mode") || "trace";
 d.dataset.files = localStorage.getItem("notevi-files-hidden") === "1" ? "hidden" : "shown";}
</script>
{{if .Live}}<script src="{{.Href "asset" "htmx.min.js"}}"></script>{{end}}
<script src="{{.Href "asset" "app.js"}}" defer></script>
</head>
<body{{if eq .Kind "file"}} class="with-aside"{{end}} data-kind="{{.Kind}}">

<nav aria-label="repository files" id="nav" data-root="{{.Root}}" data-current="{{.Current}}" data-tree="{{.Href "tree"}}">
  <header>
    <a class="brand" href="{{.Href ""}}"><img class="mark" src="{{.Href "asset" "bemtevi.svg"}}" alt="" width="20" height="20">{{.Site.Title}}</a>
    <div class="modes" role="group" aria-label="focus">
      <button type="button" class="mode" data-mode="trace" title="reading coverage (t)">trace</button>
      <button type="button" class="mode" data-mode="notes" title="notes and comments (t)">notes</button>
    </div>
  </header>
  {{template "changebar" .}}
  {{if .Live}}
  <div id="activity" class="activity" hx-get="{{.Href "activity"}}?compact=1" hx-trigger="load, every 3s" hx-swap="innerHTML"></div>
  {{end}}
  <button type="button" id="filetoggle" aria-controls="filelist" aria-expanded="true">hide files</button>
  <div id="filelist">
    <input id="filefind" class="find" type="search" placeholder="find file…" aria-label="find file" autocomplete="off" spellcheck="false">
    <div id="tree"><p class="meta hint">loading tree…</p></div>
  </div>
  <footer>
    <span>
      {{if and .Live (ne .Root "/")}}<a href="/">projects</a> · {{end}}
      <a href="{{.Href "notes"}}">notes ({{len .Site.Notes}})</a> ·
      <a href="{{.Href "files"}}">files</a>{{if .Live}} ·
      <a href="{{.Href "jj"}}">jj</a>{{end}}
    </span>
    <div class="themepick" id="themepick"
         data-js="{{.Href "asset" "themes.js"}}" data-css="{{.Href "asset" "themes.css"}}"
         data-dark="{{.Site.Theme.Name}}" data-light="{{.Site.Light.Name}}"
         data-darkid="{{.Site.Theme.ID}}" data-lightid="{{.Site.Light.ID}}">
      <button type="button" id="themebtn" aria-haspopup="listbox" aria-expanded="false"
              title="theme — every one installed here (T)">theme</button>
      <div class="thememenu" id="thememenu" hidden>
        <input id="themefind" type="search" placeholder="filter themes…" aria-label="filter themes"
               role="combobox" aria-controls="themelist" aria-autocomplete="list"
               autocomplete="off" spellcheck="false">
        <ul id="themelist" role="listbox" aria-label="themes"></ul>
        <p class="meta hint">↑↓ preview · enter keeps · esc puts it back</p>
      </div>
    </div>
  </footer>
</nav>

<main>
{{if .Err}}<p class="err">{{.Err}}</p>{{end}}
{{if eq .Kind "file"}}{{template "page-file" .}}
{{else if eq .Kind "notes"}}{{template "page-notes" .}}
{{else if eq .Kind "note"}}{{template "page-note" .}}
{{else if eq .Kind "files"}}{{template "page-files" .}}
{{else if eq .Kind "jj"}}{{template "page-jj" .}}
{{else if eq .Kind "change"}}{{template "page-change" .}}
{{else if eq .Kind "session"}}{{template "page-session" .}}
{{else}}{{template "page-index" .}}{{end}}
</main>

{{if eq .Kind "file"}}
<aside aria-label="notes" class="notes-only">
  <header class="asidehead">
    <b>Notes (<span id="notecount">{{len .File.Notes}}</span>)</b>
    {{if .Live}}<span class="meta">click a line to attach</span>{{end}}
  </header>
  {{if .Live}}{{template "noteform" .}}{{end}}
  <div id="notelist">{{range .File.Notes}}{{template "note" (dict "N" . "P" $)}}{{end}}</div>
  {{if not .File.Notes}}<p class="meta hint">no notes on this file yet</p>{{end}}
</aside>
{{end}}

</body>
</html>