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 row of a repository in the home list: what it is, its
36// latest run, and its newest commits. Its id is the target of SSE swaps; the
37// name link comes first, `enter` follows it.
38templ HomeRowView(r HomeRow) {
39 <li id={ r.ID } class="repo" data-cursor?={ r.Cursor }>
40 <div class="repo-main">
41 <h2 class="repo-name">
42 <a href={ templ.SafeURL(r.Href) }>{ r.Name }</a>
43 if r.Private {
44 <span class="pill">private</span>
45 }
46 if r.Fresh {
47 <span class="pill new">new push</span>
48 }
49 </h2>
50 if r.Desc != "" {
51 <p class="repo-desc">{ r.Desc }</p>
52 } else {
53 <p class="repo-desc mute">no description</p>
54 }
55 <p class="repo-meta">
56 if r.Branch != "" {
57 <span class="repo-branch"><span class="ico i-branch" aria-hidden="true"></span>{ r.Branch }</span>
58 }
59 if r.PushedAt != "" {
60 <span>pushed <time datetime={ r.PushedAt } title={ r.PushedAt }>{ r.Pushed }</time></span>
61 } else {
62 <span>never pushed</span>
63 }
64 </p>
65 </div>
66 if r.CI != nil {
67 <a class="repo-ci" href={ templ.SafeURL(r.CI.Href) } title={ r.CI.Title }>
68 <span class={ "ck", "ck-" + r.CI.Kind } aria-hidden="true"></span>
69 <span class="sr">CI: </span>{ r.CI.Label }
70 </a>
71 }
72 if len(r.Commits) > 0 {
73 <ul class="repo-commits" aria-label={ "Recent commits of " + r.Name }>
74 for _, c := range r.Commits {
75 <li>
76 <a class="rc-sha" href={ templ.SafeURL(c.CHref) }>{ c.Short }</a>
77 <span class="rc-subject" title={ c.Subject }>{ c.Subject }</span>
78 if c.WhenAt != "" {
79 <time class="dim" datetime={ c.WhenAt } title={ c.WhenAt }>{ c.When }</time>
80 }
81 </li>
82 }
83 </ul>
84 } else if r.NoCommits {
85 <p class="repo-commits mute">no commits yet</p>
86 }
87 </li>
88}
89
90// Outline is the README outline; levels indent by 2ch, the h1 is bold.
91templ Outline(headings []Heading) {
92 <nav class="outline" aria-label="Outline">
93 for _, h := range headings {
94 <a class={ "l" + itoa(h.Level) } href={ templ.SafeURL("#" + h.ID) }>{ h.Text }</a>
95 }
96 </nav>
97}
98
99// ReadmeCard is a README in a card whose header names the file.
100templ ReadmeCard(r Readme) {
101 <section class="card readme" aria-labelledby="readme-h">
102 <h2 class="card-h" id="readme-h">
103 <span class="ico i-file" aria-hidden="true"></span>
104 { r.Name }
105 </h2>
106 @ReadmeView(r)
107 </section>
108}
109
110// ReadmeView is a rendered README. Its HTML comes from the Markdown
111// renderer, which drops raw HTML and filters URLs.
112templ ReadmeView(r Readme) {
113 <article class="prose" aria-label={ r.Name } hx-ignore>
114 if r.Note != "" {
115 <p class="dim">{ r.Note }</p>
116 } else {
117 @templ.Raw(r.HTML)
118 }
119 </article>
120}
121
122// CommitRows is a cursor table of commits: sha, subject with inline refs,
123// author, relative date (absolute in the title).
124templ CommitRows(rows []CommitRow) {
125 <table class="list commits" aria-label="Commits">
126 <tbody data-rows>
127 for _, c := range rows {
128 <tr
129 if c.ID != "" {
130 id={ c.ID }
131 }
132 data-cursor?={ c.Cursor }
133 >
134 <td class="cur" aria-hidden="true"></td>
135 <td class="c-sha mute">{ c.Short }</td>
136 <td class="c-subject">
137 <a href={ templ.SafeURL(c.CHref) }>{ c.Subject }</a>
138 if c.Merge {
139 <span class="pill">merge</span>
140 }
141 for _, b := range c.Branches {
142 <span class="pill">{ b }</span>
143 }
144 for _, t := range c.Tags {
145 <span class="pill tag"><span class="sr">tag </span>{ t }</span>
146 }
147 </td>
148 <td class="c-ck">@CommitChecks(c.Checks)</td>
149 <td class="c-who dim">{ c.Author }</td>
150 <td class="c-when nowrap dim"><time datetime={ c.WhenAt } title={ c.WhenAt }>{ c.When }</time></td>
151 </tr>
152 }
153 </tbody>
154 </table>
155}