Parent directory

watched_videos_templ.go

13003 bytes
  1// Code generated by templ - DO NOT EDIT.
  2
  3// templ: version: v0.3.1020
  4package pages
  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 (
 12	"fmt"
 13
 14	"github.com/TheEdgeOfRage/ytrssil-api/models"
 15)
 16
 17func watchedVideoCard(video models.Video) templ.Component {
 18	return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
 19		templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
 20		if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
 21			return templ_7745c5c3_CtxErr
 22		}
 23		templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
 24		if !templ_7745c5c3_IsBuffer {
 25			defer func() {
 26				templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
 27				if templ_7745c5c3_Err == nil {
 28					templ_7745c5c3_Err = templ_7745c5c3_BufErr
 29				}
 30			}()
 31		}
 32		ctx = templ.InitializeContext(ctx)
 33		templ_7745c5c3_Var1 := templ.GetChildren(ctx)
 34		if templ_7745c5c3_Var1 == nil {
 35			templ_7745c5c3_Var1 = templ.NopComponent
 36		}
 37		ctx = templ.ClearChildren(ctx)
 38		templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<div class=\"card\">")
 39		if templ_7745c5c3_Err != nil {
 40			return templ_7745c5c3_Err
 41		}
 42		templ_7745c5c3_Err = thumbnail(video).Render(ctx, templ_7745c5c3_Buffer)
 43		if templ_7745c5c3_Err != nil {
 44			return templ_7745c5c3_Err
 45		}
 46		templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "<div class=\"card-body\"><p class=\"card-title text-truncate mb-0\">")
 47		if templ_7745c5c3_Err != nil {
 48			return templ_7745c5c3_Err
 49		}
 50		var templ_7745c5c3_Var2 string
 51		templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(video.Title)
 52		if templ_7745c5c3_Err != nil {
 53			return templ.Error{Err: templ_7745c5c3_Err, FileName: `pages/watched_videos.templ`, Line: 13, Col: 57}
 54		}
 55		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
 56		if templ_7745c5c3_Err != nil {
 57			return templ_7745c5c3_Err
 58		}
 59		templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "</p><p class=\"d-flex justify-content-between\"><a target=\"_blank\" rel=\"noopener\" data-open-in-safari href=\"")
 60		if templ_7745c5c3_Err != nil {
 61			return templ_7745c5c3_Err
 62		}
 63		var templ_7745c5c3_Var3 templ.SafeURL
 64		templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinURLErrs(fmt.Sprintf("https://www.youtube.com/channel/%s", video.ChannelID))
 65		if templ_7745c5c3_Err != nil {
 66			return templ.Error{Err: templ_7745c5c3_Err, FileName: `pages/watched_videos.templ`, Line: 19, Col: 78}
 67		}
 68		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
 69		if templ_7745c5c3_Err != nil {
 70			return templ_7745c5c3_Err
 71		}
 72		templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, "\" class=\"card-text fw-light link-light link-underline-opacity-0\">")
 73		if templ_7745c5c3_Err != nil {
 74			return templ_7745c5c3_Err
 75		}
 76		var templ_7745c5c3_Var4 string
 77		templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(video.ChannelName)
 78		if templ_7745c5c3_Err != nil {
 79			return templ.Error{Err: templ_7745c5c3_Err, FileName: `pages/watched_videos.templ`, Line: 21, Col: 24}
 80		}
 81		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
 82		if templ_7745c5c3_Err != nil {
 83			return templ_7745c5c3_Err
 84		}
 85		templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "</a> <span>")
 86		if templ_7745c5c3_Err != nil {
 87			return templ_7745c5c3_Err
 88		}
 89		var templ_7745c5c3_Var5 string
 90		templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(video.HumanizedPublishTime())
 91		if templ_7745c5c3_Err != nil {
 92			return templ.Error{Err: templ_7745c5c3_Err, FileName: `pages/watched_videos.templ`, Line: 23, Col: 35}
 93		}
 94		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
 95		if templ_7745c5c3_Err != nil {
 96			return templ_7745c5c3_Err
 97		}
 98		templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, "</span></p><div class=\"d-flex justify-content-end\"><button data-on:click=\"")
 99		if templ_7745c5c3_Err != nil {
100			return templ_7745c5c3_Err
101		}
102		var templ_7745c5c3_Var6 string
103		templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.ResolveAttributeValue(fmt.Sprintf("@patch('/videos/%s/unwatch')", video.ID))
104		if templ_7745c5c3_Err != nil {
105			return templ.Error{Err: templ_7745c5c3_Err, FileName: `pages/watched_videos.templ`, Line: 28, Col: 74}
106		}
107		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var6)
108		if templ_7745c5c3_Err != nil {
109			return templ_7745c5c3_Err
110		}
111		templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, "\" class=\"btn btn-secondary\"><i class=\"bi bi-arrow-counterclockwise\"></i></button></div></div></div>")
112		if templ_7745c5c3_Err != nil {
113			return templ_7745c5c3_Err
114		}
115		return nil
116	})
117}
118
119func WatchedVideosPage(videos []models.Video, currentPage int) templ.Component {
120	return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
121		templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
122		if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
123			return templ_7745c5c3_CtxErr
124		}
125		templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
126		if !templ_7745c5c3_IsBuffer {
127			defer func() {
128				templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
129				if templ_7745c5c3_Err == nil {
130					templ_7745c5c3_Err = templ_7745c5c3_BufErr
131				}
132			}()
133		}
134		ctx = templ.InitializeContext(ctx)
135		templ_7745c5c3_Var7 := templ.GetChildren(ctx)
136		if templ_7745c5c3_Var7 == nil {
137			templ_7745c5c3_Var7 = templ.NopComponent
138		}
139		ctx = templ.ClearChildren(ctx)
140		templ_7745c5c3_Var8 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
141			templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
142			templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
143			if !templ_7745c5c3_IsBuffer {
144				defer func() {
145					templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
146					if templ_7745c5c3_Err == nil {
147						templ_7745c5c3_Err = templ_7745c5c3_BufErr
148					}
149				}()
150			}
151			ctx = templ.InitializeContext(ctx)
152			templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, "<div class=\"row\">")
153			if templ_7745c5c3_Err != nil {
154				return templ_7745c5c3_Err
155			}
156			for _, video := range videos {
157				templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, "<div id=\"")
158				if templ_7745c5c3_Err != nil {
159					return templ_7745c5c3_Err
160				}
161				var templ_7745c5c3_Var9 string
162				templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.ResolveAttributeValue(fmt.Sprintf("video-card-%s", video.ID))
163				if templ_7745c5c3_Err != nil {
164					return templ.Error{Err: templ_7745c5c3_Err, FileName: `pages/watched_videos.templ`, Line: 42, Col: 52}
165				}
166				_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var9)
167				if templ_7745c5c3_Err != nil {
168					return templ_7745c5c3_Err
169				}
170				templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 10, "\" class=\"video-card col-md-3 p-2\" data-title=\"")
171				if templ_7745c5c3_Err != nil {
172					return templ_7745c5c3_Err
173				}
174				var templ_7745c5c3_Var10 string
175				templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.ResolveAttributeValue(video.Title)
176				if templ_7745c5c3_Err != nil {
177					return templ.Error{Err: templ_7745c5c3_Err, FileName: `pages/watched_videos.templ`, Line: 42, Col: 111}
178				}
179				_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var10)
180				if templ_7745c5c3_Err != nil {
181					return templ_7745c5c3_Err
182				}
183				templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, "\" data-channel-name=\"")
184				if templ_7745c5c3_Err != nil {
185					return templ_7745c5c3_Err
186				}
187				var templ_7745c5c3_Var11 string
188				templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.ResolveAttributeValue(video.ChannelName)
189				if templ_7745c5c3_Err != nil {
190					return templ.Error{Err: templ_7745c5c3_Err, FileName: `pages/watched_videos.templ`, Line: 42, Col: 151}
191				}
192				_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var11)
193				if templ_7745c5c3_Err != nil {
194					return templ_7745c5c3_Err
195				}
196				templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, "\">")
197				if templ_7745c5c3_Err != nil {
198					return templ_7745c5c3_Err
199				}
200				templ_7745c5c3_Err = watchedVideoCard(video).Render(ctx, templ_7745c5c3_Buffer)
201				if templ_7745c5c3_Err != nil {
202					return templ_7745c5c3_Err
203				}
204				templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, "</div>")
205				if templ_7745c5c3_Err != nil {
206					return templ_7745c5c3_Err
207				}
208			}
209			templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, "</div><div class=\"row mt-4 mb-4\"><div class=\"col-12 d-flex justify-content-center align-items-center gap-3\">")
210			if templ_7745c5c3_Err != nil {
211				return templ_7745c5c3_Err
212			}
213			if currentPage > 1 {
214				templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, "<a href=\"")
215				if templ_7745c5c3_Err != nil {
216					return templ_7745c5c3_Err
217				}
218				var templ_7745c5c3_Var12 templ.SafeURL
219				templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinURLErrs(templ.SafeURL(fmt.Sprintf("/watched?page=%d", currentPage-1)))
220				if templ_7745c5c3_Err != nil {
221					return templ.Error{Err: templ_7745c5c3_Err, FileName: `pages/watched_videos.templ`, Line: 50, Col: 76}
222				}
223				_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12))
224				if templ_7745c5c3_Err != nil {
225					return templ_7745c5c3_Err
226				}
227				templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, "\" class=\"btn btn-primary\"><i class=\"bi bi-arrow-left\"></i> Previous</a> ")
228				if templ_7745c5c3_Err != nil {
229					return templ_7745c5c3_Err
230				}
231			} else {
232				templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, "<button class=\"btn btn-primary\" disabled><i class=\"bi bi-arrow-left\"></i> Previous</button> ")
233				if templ_7745c5c3_Err != nil {
234					return templ_7745c5c3_Err
235				}
236			}
237			templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, "<span class=\"text-light\">Page ")
238			if templ_7745c5c3_Err != nil {
239				return templ_7745c5c3_Err
240			}
241			var templ_7745c5c3_Var13 string
242			templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%d", currentPage))
243			if templ_7745c5c3_Err != nil {
244				return templ.Error{Err: templ_7745c5c3_Err, FileName: `pages/watched_videos.templ`, Line: 58, Col: 66}
245			}
246			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13))
247			if templ_7745c5c3_Err != nil {
248				return templ_7745c5c3_Err
249			}
250			templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "</span> ")
251			if templ_7745c5c3_Err != nil {
252				return templ_7745c5c3_Err
253			}
254			if len(videos) == 100 {
255				templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, "<a href=\"")
256				if templ_7745c5c3_Err != nil {
257					return templ_7745c5c3_Err
258				}
259				var templ_7745c5c3_Var14 templ.SafeURL
260				templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinURLErrs(templ.SafeURL(fmt.Sprintf("/watched?page=%d", currentPage+1)))
261				if templ_7745c5c3_Err != nil {
262					return templ.Error{Err: templ_7745c5c3_Err, FileName: `pages/watched_videos.templ`, Line: 60, Col: 76}
263				}
264				_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14))
265				if templ_7745c5c3_Err != nil {
266					return templ_7745c5c3_Err
267				}
268				templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 21, "\" class=\"btn btn-primary\">Next <i class=\"bi bi-arrow-right\"></i></a>")
269				if templ_7745c5c3_Err != nil {
270					return templ_7745c5c3_Err
271				}
272			} else {
273				templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 22, "<button class=\"btn btn-primary\" disabled>Next <i class=\"bi bi-arrow-right\"></i></button>")
274				if templ_7745c5c3_Err != nil {
275					return templ_7745c5c3_Err
276				}
277			}
278			templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 23, "</div></div>")
279			if templ_7745c5c3_Err != nil {
280				return templ_7745c5c3_Err
281			}
282			return nil
283		})
284		templ_7745c5c3_Err = BaseLayout("ytrssil - Watched Videos", "watched").Render(templ.WithChildren(ctx, templ_7745c5c3_Var8), templ_7745c5c3_Buffer)
285		if templ_7745c5c3_Err != nil {
286			return templ_7745c5c3_Err
287		}
288		return nil
289	})
290}
291
292var _ = templruntime.GeneratedTemplate