main / internal/interface/web/templates/diff_templ.go
10.8 KB · Go Raw
1// Code generated by templ - DO NOT EDIT.
2
3// templ: version: v0.3.865
4package templates
5
6//lint:file-ignore SA4006 This context is only used if a nested component is present.
7
8import "github.com/a-h/templ"
9import templruntime "github.com/a-h/templ/runtime"
10
11import "gitgud/internal/domain"
12
13func diffFiles(files []domain.FileDiff) templ.Component {
14 return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
15 templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
16 if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
17 return templ_7745c5c3_CtxErr
18 }
19 templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
20 if !templ_7745c5c3_IsBuffer {
21 defer func() {
22 templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
23 if templ_7745c5c3_Err == nil {
24 templ_7745c5c3_Err = templ_7745c5c3_BufErr
25 }
26 }()
27 }
28 ctx = templ.InitializeContext(ctx)
29 templ_7745c5c3_Var1 := templ.GetChildren(ctx)
30 if templ_7745c5c3_Var1 == nil {
31 templ_7745c5c3_Var1 = templ.NopComponent
32 }
33 ctx = templ.ClearChildren(ctx)
34 for _, d := range files {
35 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<div class=\"card mb-4 overflow-hidden\"><div class=\"flex items-center gap-3 border-b border-line bg-[#0e1410] px-4 py-2.5\"><span class=\"font-mono text-sm text-ink\">")
36 if templ_7745c5c3_Err != nil {
37 return templ_7745c5c3_Err
38 }
39 var templ_7745c5c3_Var2 string
40 templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(d.Path)
41 if templ_7745c5c3_Err != nil {
42 return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/interface/web/templates/diff.templ`, Line: 9, Col: 53}
43 }
44 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
45 if templ_7745c5c3_Err != nil {
46 return templ_7745c5c3_Err
47 }
48 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "</span> <span class=\"ml-auto flex items-center gap-2 font-mono text-xs\"><span class=\"text-open\">+")
49 if templ_7745c5c3_Err != nil {
50 return templ_7745c5c3_Err
51 }
52 var templ_7745c5c3_Var3 string
53 templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(itoa(d.Added))
54 if templ_7745c5c3_Err != nil {
55 return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/interface/web/templates/diff.templ`, Line: 11, Col: 45}
56 }
57 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
58 if templ_7745c5c3_Err != nil {
59 return templ_7745c5c3_Err
60 }
61 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "</span> <span class=\"text-closed\">−")
62 if templ_7745c5c3_Err != nil {
63 return templ_7745c5c3_Err
64 }
65 var templ_7745c5c3_Var4 string
66 templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(itoa(d.Deleted))
67 if templ_7745c5c3_Err != nil {
68 return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/interface/web/templates/diff.templ`, Line: 12, Col: 51}
69 }
70 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
71 if templ_7745c5c3_Err != nil {
72 return templ_7745c5c3_Err
73 }
74 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, "</span></span>")
75 if templ_7745c5c3_Err != nil {
76 return templ_7745c5c3_Err
77 }
78 templ_7745c5c3_Err = statSquares(d.Added, d.Deleted).Render(ctx, templ_7745c5c3_Buffer)
79 if templ_7745c5c3_Err != nil {
80 return templ_7745c5c3_Err
81 }
82 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "</div><div class=\"overflow-x-auto bg-panel2 font-mono text-xs leading-relaxed\">")
83 if templ_7745c5c3_Err != nil {
84 return templ_7745c5c3_Err
85 }
86 for _, line := range diffLines(d.Patch) {
87 var templ_7745c5c3_Var5 = []any{"whitespace-pre px-4 " + diffLineClass(line)}
88 templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var5...)
89 if templ_7745c5c3_Err != nil {
90 return templ_7745c5c3_Err
91 }
92 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, "<div class=\"")
93 if templ_7745c5c3_Err != nil {
94 return templ_7745c5c3_Err
95 }
96 var templ_7745c5c3_Var6 string
97 templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(templ.CSSClasses(templ_7745c5c3_Var5).String())
98 if templ_7745c5c3_Err != nil {
99 return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/interface/web/templates/diff.templ`, Line: 1, Col: 0}
100 }
101 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
102 if templ_7745c5c3_Err != nil {
103 return templ_7745c5c3_Err
104 }
105 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, "\">")
106 if templ_7745c5c3_Err != nil {
107 return templ_7745c5c3_Err
108 }
109 var templ_7745c5c3_Var7 string
110 templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(line)
111 if templ_7745c5c3_Err != nil {
112 return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/interface/web/templates/diff.templ`, Line: 18, Col: 71}
113 }
114 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
115 if templ_7745c5c3_Err != nil {
116 return templ_7745c5c3_Err
117 }
118 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, "</div>")
119 if templ_7745c5c3_Err != nil {
120 return templ_7745c5c3_Err
121 }
122 }
123 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, "</div></div>")
124 if templ_7745c5c3_Err != nil {
125 return templ_7745c5c3_Err
126 }
127 }
128 return nil
129 })
130}
131
132func statSquares(added, deleted int) templ.Component {
133 return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
134 templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
135 if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
136 return templ_7745c5c3_CtxErr
137 }
138 templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
139 if !templ_7745c5c3_IsBuffer {
140 defer func() {
141 templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
142 if templ_7745c5c3_Err == nil {
143 templ_7745c5c3_Err = templ_7745c5c3_BufErr
144 }
145 }()
146 }
147 ctx = templ.InitializeContext(ctx)
148 templ_7745c5c3_Var8 := templ.GetChildren(ctx)
149 if templ_7745c5c3_Var8 == nil {
150 templ_7745c5c3_Var8 = templ.NopComponent
151 }
152 ctx = templ.ClearChildren(ctx)
153 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 10, "<span class=\"flex gap-px\">")
154 if templ_7745c5c3_Err != nil {
155 return templ_7745c5c3_Err
156 }
157 for _, kind := range statBlocks(added, deleted) {
158 switch kind {
159 case "add":
160 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, "<span class=\"size-2.5 bg-open\"></span>")
161 if templ_7745c5c3_Err != nil {
162 return templ_7745c5c3_Err
163 }
164 case "del":
165 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, "<span class=\"size-2.5 bg-closed\"></span>")
166 if templ_7745c5c3_Err != nil {
167 return templ_7745c5c3_Err
168 }
169 default:
170 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, "<span class=\"size-2.5 bg-line2\"></span>")
171 if templ_7745c5c3_Err != nil {
172 return templ_7745c5c3_Err
173 }
174 }
175 }
176 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, "</span>")
177 if templ_7745c5c3_Err != nil {
178 return templ_7745c5c3_Err
179 }
180 return nil
181 })
182}
183
184func commitsList(repo *domain.Repository, commits []domain.Commit) templ.Component {
185 return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
186 templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
187 if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
188 return templ_7745c5c3_CtxErr
189 }
190 templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
191 if !templ_7745c5c3_IsBuffer {
192 defer func() {
193 templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
194 if templ_7745c5c3_Err == nil {
195 templ_7745c5c3_Err = templ_7745c5c3_BufErr
196 }
197 }()
198 }
199 ctx = templ.InitializeContext(ctx)
200 templ_7745c5c3_Var9 := templ.GetChildren(ctx)
201 if templ_7745c5c3_Var9 == nil {
202 templ_7745c5c3_Var9 = templ.NopComponent
203 }
204 ctx = templ.ClearChildren(ctx)
205 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, "<div class=\"card mb-4 overflow-hidden\">")
206 if templ_7745c5c3_Err != nil {
207 return templ_7745c5c3_Err
208 }
209 for _, c := range commits {
210 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, "<div class=\"row flex items-center justify-between border-b border-line px-4 py-2.5 last:border-0\"><a class=\"truncate text-sm text-ink hover:text-accent\" href=\"")
211 if templ_7745c5c3_Err != nil {
212 return templ_7745c5c3_Err
213 }
214 var templ_7745c5c3_Var10 templ.SafeURL = templ.SafeURL(repoPath(repo, "/commit/"+c.Hash))
215 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(string(templ_7745c5c3_Var10)))
216 if templ_7745c5c3_Err != nil {
217 return templ_7745c5c3_Err
218 }
219 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, "\">")
220 if templ_7745c5c3_Err != nil {
221 return templ_7745c5c3_Err
222 }
223 var templ_7745c5c3_Var11 string
224 templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(firstLine(c.Message))
225 if templ_7745c5c3_Err != nil {
226 return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/interface/web/templates/diff.templ`, Line: 44, Col: 139}
227 }
228 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11))
229 if templ_7745c5c3_Err != nil {
230 return templ_7745c5c3_Err
231 }
232 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, "</a> <code class=\"ml-4 shrink-0 text-xs text-faint\">")
233 if templ_7745c5c3_Err != nil {
234 return templ_7745c5c3_Err
235 }
236 var templ_7745c5c3_Var12 string
237 templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(c.ShortHash)
238 if templ_7745c5c3_Err != nil {
239 return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/interface/web/templates/diff.templ`, Line: 45, Col: 64}
240 }
241 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12))
242 if templ_7745c5c3_Err != nil {
243 return templ_7745c5c3_Err
244 }
245 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "</code></div>")
246 if templ_7745c5c3_Err != nil {
247 return templ_7745c5c3_Err
248 }
249 }
250 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, "</div>")
251 if templ_7745c5c3_Err != nil {
252 return templ_7745c5c3_Err
253 }
254 return nil
255 })
256}
257
258var _ = templruntime.GeneratedTemplate