components.templ RawHistoryFolder
1// SPDX-License-Identifier: AGPL-3.0-or-later
2
3package web
4
5// Facts is a key/value block on an 11ch key column.
6templ Facts(facts []Fact) {
7 <dl class="kv">
8 for _, f := range facts {
9 <dt>{ f.Key }</dt>
10 @FactValue(f)
11 }
12 </dl>
13}
14
15// CloneBlock is a block of copyable shell lines; each has its own [copy]
16// button, whose label says "copied" for 1.5 s.
17templ CloneBlock(c Clone) {
18 <div class="clone" id={ c.ID }>
19 for _, line := range c.Lines {
20 <div class="clone-line">
21 <span class="mute" aria-hidden="true">$ </span><code>{ line }</code>
22 <button
23 type="button"
24 class="btn copy"
25 data-js
26 data-label="Copy"
27 aria-label={ "copy: " + line }
28 hx-on:click="ermite.copy(this)"
29 >Copy</button>
30 </div>
31 }
32 </div>
33}
34
35// HomeRowView is the card of a repository in the home list. Its id is the
36// target of SSE swaps; the name link comes first, `enter` follows it.
37templ HomeRowView(r HomeRow) {
38 <li id={ r.ID } class="repo" data-cursor?={ r.Cursor }>
39 <h2 class="repo-name">
40 <a href={ templ.SafeURL(r.Href) }>{ r.Name }</a>
41 if r.Private {
42 <span class="pill">private</span>
43 }
44 if r.Fresh {
45 <span class="pill new">new push</span>
46 }
47 </h2>
48 if r.Desc != "" {
49 <p class="repo-desc">{ r.Desc }</p>
50 } else {
51 <p class="repo-desc mute">no description</p>
52 }
53 <p class="repo-meta">
54 if r.Branch != "" {
55 <span class="repo-branch"><span class="ico i-branch" aria-hidden="true"></span>{ r.Branch }</span>
56 }
57 if r.PushedAt != "" {
58 <span>pushed <time datetime={ r.PushedAt } title={ r.PushedAt }>{ r.Pushed }</time></span>
59 } else {
60 <span>never pushed</span>
61 }
62 </p>
63 </li>
64}
65
66// Outline is the README outline; levels indent by 2ch, the h1 is bold.
67templ Outline(headings []Heading) {
68 <nav class="outline" aria-label="Outline">
69 for _, h := range headings {
70 <a class={ "l" + itoa(h.Level) } href={ templ.SafeURL("#" + h.ID) }>{ h.Text }</a>
71 }
72 </nav>
73}
74
75// ReadmeCard is a README in a card whose header names the file.
76templ ReadmeCard(r Readme) {
77 <section class="card readme" aria-labelledby="readme-h">
78 <h2 class="card-h" id="readme-h">
79 <span class="ico i-file" aria-hidden="true"></span>
80 { r.Name }
81 </h2>
82 @ReadmeView(r)
83 </section>
84}
85
86// ReadmeView is a rendered README. Its HTML comes from the Markdown
87// renderer, which drops raw HTML and filters URLs.
88templ ReadmeView(r Readme) {
89 <article class="prose" aria-label={ r.Name } hx-ignore>
90 if r.Note != "" {
91 <p class="dim">{ r.Note }</p>
92 } else {
93 @templ.Raw(r.HTML)
94 }
95 </article>
96}
97
98// CommitRows is a cursor table of commits: sha, subject with inline refs,
99// author, relative date (absolute in the title).
100templ CommitRows(rows []CommitRow) {
101 <table class="list commits" aria-label="Commits">
102 <tbody data-rows>
103 for _, c := range rows {
104 <tr
105 if c.ID != "" {
106 id={ c.ID }
107 }
108 data-cursor?={ c.Cursor }
109 >
110 <td class="cur" aria-hidden="true"></td>
111 <td class="c-sha mute">{ c.Short }</td>
112 <td class="c-subject">
113 <a href={ templ.SafeURL(c.CHref) }>{ c.Subject }</a>
114 if c.Merge {
115 <span class="pill">merge</span>
116 }
117 for _, b := range c.Branches {
118 <span class="pill">{ b }</span>
119 }
120 for _, t := range c.Tags {
121 <span class="pill tag"><span class="sr">tag </span>{ t }</span>
122 }
123 </td>
124 <td class="c-ck">@CommitChecks(c.Checks)</td>
125 <td class="c-who dim">{ c.Author }</td>
126 <td class="c-when nowrap dim"><time datetime={ c.WhenAt } title={ c.WhenAt }>{ c.When }</time></td>
127 </tr>
128 }
129 </tbody>
130 </table>
131}