main / internal/interface/web/templates/browse_tree_templ.go
9.1 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 BrowseTree(user *domain.User, repo *domain.Repository, ref, path string, branches []string, entries []domain.TreeEntry, readme string) 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 templ_7745c5c3_Var2 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
35 templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
36 templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
37 if !templ_7745c5c3_IsBuffer {
38 defer func() {
39 templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
40 if templ_7745c5c3_Err == nil {
41 templ_7745c5c3_Err = templ_7745c5c3_BufErr
42 }
43 }()
44 }
45 ctx = templ.InitializeContext(ctx)
46 templ_7745c5c3_Err = repoHeader(repo, "code").Render(ctx, templ_7745c5c3_Buffer)
47 if templ_7745c5c3_Err != nil {
48 return templ_7745c5c3_Err
49 }
50 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, " <div class=\"mb-3 flex items-center justify-between gap-3\"><div class=\"flex items-center gap-3\">")
51 if templ_7745c5c3_Err != nil {
52 return templ_7745c5c3_Err
53 }
54 templ_7745c5c3_Err = branchSwitcher(repo, ref, branches).Render(ctx, templ_7745c5c3_Buffer)
55 if templ_7745c5c3_Err != nil {
56 return templ_7745c5c3_Err
57 }
58 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "<div class=\"font-mono text-sm\">")
59 if templ_7745c5c3_Err != nil {
60 return templ_7745c5c3_Err
61 }
62 for i, c := range treeCrumbs(repo, ref, path) {
63 if i > 0 {
64 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "<span class=\"text-faint\">/ </span>")
65 if templ_7745c5c3_Err != nil {
66 return templ_7745c5c3_Err
67 }
68 }
69 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, " <a class=\"link\" href=\"")
70 if templ_7745c5c3_Err != nil {
71 return templ_7745c5c3_Err
72 }
73 var templ_7745c5c3_Var3 templ.SafeURL = templ.SafeURL(c.Href)
74 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(string(templ_7745c5c3_Var3)))
75 if templ_7745c5c3_Err != nil {
76 return templ_7745c5c3_Err
77 }
78 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "\">")
79 if templ_7745c5c3_Err != nil {
80 return templ_7745c5c3_Err
81 }
82 var templ_7745c5c3_Var4 string
83 templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(c.Name)
84 if templ_7745c5c3_Err != nil {
85 return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/interface/web/templates/browse_tree.templ`, Line: 16, Col: 61}
86 }
87 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
88 if templ_7745c5c3_Err != nil {
89 return templ_7745c5c3_Err
90 }
91 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, "</a>")
92 if templ_7745c5c3_Err != nil {
93 return templ_7745c5c3_Err
94 }
95 }
96 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, "</div></div><a class=\"meta hover:text-ink\" href=\"")
97 if templ_7745c5c3_Err != nil {
98 return templ_7745c5c3_Err
99 }
100 var templ_7745c5c3_Var5 templ.SafeURL = templ.SafeURL(repoPath(repo, "/commits/"+ref))
101 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(string(templ_7745c5c3_Var5)))
102 if templ_7745c5c3_Err != nil {
103 return templ_7745c5c3_Err
104 }
105 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, "\">Commits →</a></div><div class=\"card overflow-hidden\"><table class=\"w-full text-sm\"><tbody>")
106 if templ_7745c5c3_Err != nil {
107 return templ_7745c5c3_Err
108 }
109 for _, e := range entries {
110 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, "<tr class=\"row border-b border-line last:border-0\"><td class=\"px-4 py-2.5\"><a class=\"flex items-center gap-2.5\" href=\"")
111 if templ_7745c5c3_Err != nil {
112 return templ_7745c5c3_Err
113 }
114 var templ_7745c5c3_Var6 templ.SafeURL = templ.SafeURL(entryHref(repo, ref, e))
115 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(string(templ_7745c5c3_Var6)))
116 if templ_7745c5c3_Err != nil {
117 return templ_7745c5c3_Err
118 }
119 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 10, "\">")
120 if templ_7745c5c3_Err != nil {
121 return templ_7745c5c3_Err
122 }
123 if e.IsDir {
124 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, "<span class=\"text-accent\">▸</span> <span class=\"font-mono text-ink\">")
125 if templ_7745c5c3_Err != nil {
126 return templ_7745c5c3_Err
127 }
128 var templ_7745c5c3_Var7 string
129 templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(e.Name)
130 if templ_7745c5c3_Err != nil {
131 return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/interface/web/templates/browse_tree.templ`, Line: 31, Col: 51}
132 }
133 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
134 if templ_7745c5c3_Err != nil {
135 return templ_7745c5c3_Err
136 }
137 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, "</span>")
138 if templ_7745c5c3_Err != nil {
139 return templ_7745c5c3_Err
140 }
141 } else {
142 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, "<span class=\"text-faint\">·</span> <span class=\"font-mono text-muted\">")
143 if templ_7745c5c3_Err != nil {
144 return templ_7745c5c3_Err
145 }
146 var templ_7745c5c3_Var8 string
147 templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(e.Name)
148 if templ_7745c5c3_Err != nil {
149 return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/interface/web/templates/browse_tree.templ`, Line: 34, Col: 53}
150 }
151 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8))
152 if templ_7745c5c3_Err != nil {
153 return templ_7745c5c3_Err
154 }
155 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, "</span>")
156 if templ_7745c5c3_Err != nil {
157 return templ_7745c5c3_Err
158 }
159 }
160 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, "</a></td><td class=\"px-4 py-2.5 text-right font-mono text-xs text-faint\">")
161 if templ_7745c5c3_Err != nil {
162 return templ_7745c5c3_Err
163 }
164 if !e.IsDir {
165 var templ_7745c5c3_Var9 string
166 templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(humanSize(e.Size))
167 if templ_7745c5c3_Err != nil {
168 return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/interface/web/templates/browse_tree.templ`, Line: 40, Col: 28}
169 }
170 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9))
171 if templ_7745c5c3_Err != nil {
172 return templ_7745c5c3_Err
173 }
174 }
175 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, "</td></tr>")
176 if templ_7745c5c3_Err != nil {
177 return templ_7745c5c3_Err
178 }
179 }
180 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, "</tbody></table></div>")
181 if templ_7745c5c3_Err != nil {
182 return templ_7745c5c3_Err
183 }
184 if readme != "" {
185 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, "<div class=\"card mt-6 overflow-hidden\"><div class=\"border-b border-line px-5 py-2.5 font-mono text-xs text-muted\">README.md</div><div class=\"prose-dark px-5 py-4\">")
186 if templ_7745c5c3_Err != nil {
187 return templ_7745c5c3_Err
188 }
189 templ_7745c5c3_Err = templ.Raw(readme).Render(ctx, templ_7745c5c3_Buffer)
190 if templ_7745c5c3_Err != nil {
191 return templ_7745c5c3_Err
192 }
193 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "</div></div>")
194 if templ_7745c5c3_Err != nil {
195 return templ_7745c5c3_Err
196 }
197 }
198 return nil
199 })
200 templ_7745c5c3_Err = Layout(repo.OwnerName+"/"+repo.Name+" · gitgud", user).Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer)
201 if templ_7745c5c3_Err != nil {
202 return templ_7745c5c3_Err
203 }
204 return nil
205 })
206}
207
208var _ = templruntime.GeneratedTemplate