shell.templ RawHistoryFolder
1// SPDX-License-Identifier: AGPL-3.0-or-later
2
3package web
4
5// Shell is the page: head, the header, the work area (content and rail), the
6// footer, the hint badge, the overlays and the key map. The content is the
7// children.
8templ Shell(l Layout, rail templ.Component) {
9 <!DOCTYPE html>
10 <html lang="en">
11 <head>
12 <meta charset="utf-8"/>
13 <meta name="viewport" content="width=device-width, initial-scale=1"/>
14 <meta name="color-scheme" content="light dark"/>
15 <title>{ l.Title }</title>
16 <meta name="theme-color" media="(prefers-color-scheme: light)" content="#ffffff"/>
17 <meta name="theme-color" media="(prefers-color-scheme: dark)" content="#0c0c0c"/>
18 <meta name="apple-mobile-web-app-title" content="ermite"/>
19 <link rel="icon" type="image/svg+xml" href={ templ.SafeURL(l.Assets.Icon) }/>
20 <link rel="apple-touch-icon" href={ templ.SafeURL(l.Assets.AppleIcon) }/>
21 <link rel="manifest" href={ templ.SafeURL(l.Assets.Manifest) }/>
22 <link rel="preload" href={ templ.SafeURL(l.Assets.Font) } as="font" type="font/woff2" crossorigin/>
23 <link rel="stylesheet" href={ templ.SafeURL(l.Assets.CSS) }/>
24 <meta name="htmx-config" content='{"history":false,"includeIndicatorCSS":false,"extensions":"sse, hx-live"}'/>
25 <script src={ l.Assets.HTMX } defer></script>
26 <script src={ l.Assets.Live } defer></script>
27 <script src={ l.Assets.SSE } defer></script>
28 <script src={ l.Assets.App } defer></script>
29 <script src={ l.Assets.Files } defer></script>
30 <script src={ l.Assets.Passkey } defer></script>
31 <script src={ l.Assets.Log } defer></script>
32 </head>
33 <body
34 data-ref={ l.RefPath }
35 data-sha={ l.SHA }
36 data-sel=""
37 data-nav=""
38 if l.PathsURL != "" {
39 data-paths={ l.PathsURL }
40 data-blob={ l.BlobBase }
41 }
42 >
43 <a class="skip" href="#main">skip to content</a>
44 @Header(l)
45 <div class={ "work", templ.KV("has-rail", l.HasRail && rail != nil) }>
46 if l.Lede != "" {
47 <section class="work-lede" aria-label="Description"><p class="lede">{ l.Lede }</p></section>
48 }
49 <main id="main" tabindex="-1">
50 { children... }
51 </main>
52 if l.HasRail && rail != nil {
53 <aside class="rail" aria-label="Context">
54 @rail
55 </aside>
56 }
57 </div>
58 @Footer(l)
59 @Hint(l)
60 @OverlayHelp()
61 @OverlayRefs(l)
62 @OverlayCmd(l.Cmd)
63 @Keys()
64 </body>
65 </html>
66}
67
68// Header is the page header: the logo (home), the path, the ref switcher,
69// the "go to" palette and the owner; inside a repository, the tabs below.
70templ Header(l Layout) {
71 <header class="hdr">
72 <div class="hdr-top">
73 <a class="brand" href="/" data-g="h" aria-label="home" title="home (g h)">
74 <span class="brand-mark" aria-hidden="true"></span>
75 </a>
76 if len(l.Crumbs) > 0 {
77 <nav class="crumbs" aria-label="Path">
78 <ol>
79 for _, c := range l.Crumbs {
80 <li>
81 if c.Href != "" {
82 <a
83 href={ templ.SafeURL(c.Href) }
84 if c.Current {
85 aria-current="page"
86 }
87 >{ c.Label }</a>
88 } else {
89 <span
90 if c.Current {
91 aria-current="page"
92 }
93 >{ c.Label }</span>
94 }
95 </li>
96 }
97 </ol>
98 </nav>
99 }
100 <div class="hdr-acts">
101 if l.Ref != "" {
102 <a
103 class="btn ref"
104 href={ templ.SafeURL(repoHref(l.Repo, "refs")) }
105 data-fire="refs"
106 aria-keyshortcuts="b"
107 title="switch branch or tag (b)"
108 >
109 <span class="ico i-branch" aria-hidden="true"></span>
110 <span class="ref-name">{ l.Ref }</span>
111 <span class="sha">{ l.Short }</span>
112 </a>
113 }
114 <button
115 type="button"
116 class="btn search"
117 data-js
118 aria-haspopup="dialog"
119 aria-controls="panel-cmd"
120 aria-keyshortcuts="Control+K :"
121 title="go to a section, ref, file or repo (ctrl k or :)"
122 data-fire="cmd"
123 >
124 <span class="ico i-search" aria-hidden="true"></span>
125 <span class="search-label">Go to…</span>
126 <kbd aria-hidden="true">ctrl k</kbd>
127 </button>
128 if SignedIn(ctx) {
129 <form class="owner" method="post" action="/-/logout">
130 <span class="owner-badge" title="signed in as the owner"><span class="ico i-user" aria-hidden="true"></span>{ l.Owner }</span>
131 if l.Passkeys {
132 <a class="btn icon" href="/-/passkeys" aria-label="Passkeys" title="passkeys: add or remove the passkeys that sign you in"><span class="ico i-key" aria-hidden="true"></span></a>
133 }
134 <button type="submit" class="btn icon" aria-label="Sign out" title="sign out of this browser"><span class="ico i-log-out" aria-hidden="true"></span></button>
135 </form>
136 } else if l.Passkeys {
137 <a class="btn icon" href="/-/login" aria-label="Sign in" title="sign in with a passkey"><span class="ico i-log-in" aria-hidden="true"></span></a>
138 }
139 </div>
140 </div>
141 if len(l.Sections) > 0 {
142 <nav class="tabs" aria-label="Sections">
143 <ul>
144 for _, s := range l.Sections {
145 <li>
146 <a
147 href={ templ.SafeURL(s.Href) }
148 data-key={ s.Key }
149 aria-keyshortcuts={ s.Key }
150 if s.Current {
151 aria-current="page"
152 }
153 >{ s.Label }<kbd aria-hidden="true">{ s.Key }</kbd></a>
154 </li>
155 }
156 </ul>
157 </nav>
158 }
159 </header>
160}
161
162// Footer is the version and the link to the source of the running version,
163// which the AGPL §13 asks every user of the service to be offered.
164templ Footer(l Layout) {
165 <footer class="foot">
166 <span>ermite { l.Version }</span>
167 <a href={ templ.SafeURL(l.SourceURL) } rel="noopener" title="source of this version (AGPL-3.0-or-later)">source</a>
168 <button type="button" class="foot-keys" data-js data-fire="help" aria-haspopup="dialog" aria-controls="panel-help" aria-keyshortcuts="?"><kbd aria-hidden="true">?</kbd> keyboard shortcuts</button>
169 </footer>
170}
171
172// Hint is the floating badge at the bottom right. It shows only what the
173// keyboard just did or what needs attention: the row position while j/k
174// move, the selected lines of a file, a flash message (permalink copied) and
175// a lost event stream. Empty, it takes no room.
176templ Hint(l Layout) {
177 <div class="hint" role="status" aria-live="polite">
178 <span class="hint-nav" :text="document.body.dataset.nav || ''"></span>
179 <span class="hint-sel" :text="document.body.dataset.sel ? document.body.dataset.sel + ' · y permalink' : ''"></span>
180 <span class="hint-flash" :text="document.body.dataset.flash || ''"></span>
181 @Live(l)
182 </div>
183}