commits.templ RawHistoryFolder
1// SPDX-License-Identifier: AGPL-3.0-or-later
2
3package web
4
5// Commits is the history of a ref, or of a path at a ref: the commits of the
6// page grouped by day, and the way to the older ones.
7templ Commits(l Layout, p CommitsPage) {
8 @Shell(l, commitsRail(p)) {
9 <div class="filter">
10 <label for="commit-filter" class="sr">filter</label>
11 <input
12 id="commit-filter"
13 type="search"
14 data-filter
15 placeholder="Filter by subject, sha or author…"
16 autocomplete="off"
17 hx-on:input="let t = this.value.toLowerCase(); q('.days tr').arr().forEach(r => r.hidden = !r.textContent.toLowerCase().includes(t));
18 q('.days section').arr().forEach(s => s.hidden = !s.querySelector('tr:not([hidden])'));
19 let first = q('.days tr:not([hidden])').arr()[0]; first && q(first).take('data-cursor', '.days tr')"
20 />
21 </div>
22 if p.Path != "" {
23 <p class="lede dim">history of <code>{ p.Path }</code> at { p.Ref }</p>
24 }
25 if p.Live {
26 <div id="commits-head"></div>
27 }
28 <div class="days">
29 for _, g := range p.Days {
30 <section aria-label={ g.Day }>
31 <h2 class="rule-h"><span>{ g.Day }</span></h2>
32 @CommitRows(g.Rows)
33 </section>
34 }
35 </div>
36 if len(p.Days) == 0 {
37 <p class="lede dim">no commits.</p>
38 }
39 if p.Older != "" || p.Newest != "" {
40 <nav class="pager" aria-label="Pages">
41 if p.Newest != "" {
42 <a class="btn" href={ templ.SafeURL(p.Newest) }>← Newest</a>
43 } else {
44 <span class="btn" aria-disabled="true">← Newest</span>
45 }
46 if p.Older != "" {
47 <a class="btn" href={ templ.SafeURL(p.Older) } rel="next">Older →</a>
48 } else {
49 <span class="btn" aria-disabled="true">Older →</span>
50 }
51 </nav>
52 }
53 }
54}
55
56templ commitsRail(p CommitsPage) {
57 <section aria-labelledby="r-hist">
58 <h2 id="r-hist">History</h2>
59 <dl class="kv">
60 <dt>ref</dt>
61 <dd>{ p.Ref }</dd>
62 <dt>on page</dt>
63 <dd>{ itoa(p.Count) }</dd>
64 if p.Path != "" {
65 <dt>path</dt>
66 <dd>{ p.Path }</dd>
67 }
68 if p.Open != nil {
69 <dt>file</dt>
70 <dd><a href={ templ.SafeURL(p.Open.Href) }>{ p.Open.Label }</a></dd>
71 }
72 </dl>
73 </section>
74 <section aria-labelledby="r-refs">
75 <h2 id="r-refs">Refs on this page</h2>
76 if len(p.Refs) > 0 {
77 <nav class="outline" aria-label="Refs on this page">
78 for _, r := range p.Refs {
79 <a href={ templ.SafeURL(r.Href) }>{ r.Label }</a>
80 }
81 </nav>
82 } else {
83 <p class="dim">no tag or branch head here</p>
84 }
85 </section>
86}