fix: resolve templ compile errors
This commit is contained in:
@@ -12,6 +12,8 @@ import (
|
|||||||
"mal/integrations/jikan"
|
"mal/integrations/jikan"
|
||||||
"mal/internal/db"
|
"mal/internal/db"
|
||||||
"mal/internal/middleware"
|
"mal/internal/middleware"
|
||||||
|
animecomponents "mal/web/components/anime"
|
||||||
|
watchcomponents "mal/web/components/watch"
|
||||||
"mal/web/templates"
|
"mal/web/templates"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -164,7 +166,7 @@ func (h *Handler) HandleAnimeDetails(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
h.jikanClient.EnqueueAnimeFetchRetry(r.Context(), id, err)
|
h.jikanClient.EnqueueAnimeFetchRetry(r.Context(), id, err)
|
||||||
if jikan.IsRetryableError(err) {
|
if jikan.IsRetryableError(err) {
|
||||||
templates.AnimePending(id).Render(r.Context(), w)
|
animecomponents.Pending(id).Render(r.Context(), w)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -220,7 +222,7 @@ func (h *Handler) HandleAPIAnime(w http.ResponseWriter, r *http.Request) {
|
|||||||
writeInlineLoadError(w, "Failed to load relations.")
|
writeInlineLoadError(w, "Failed to load relations.")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
templates.AnimeRelationsList(relations).Render(r.Context(), w)
|
animecomponents.RelationsList(relations).Render(r.Context(), w)
|
||||||
case "recommendations":
|
case "recommendations":
|
||||||
recs, err := h.jikanClient.GetRecommendations(r.Context(), id, 12)
|
recs, err := h.jikanClient.GetRecommendations(r.Context(), id, 12)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -228,7 +230,7 @@ func (h *Handler) HandleAPIAnime(w http.ResponseWriter, r *http.Request) {
|
|||||||
writeInlineLoadError(w, "Failed to load recommendations.")
|
writeInlineLoadError(w, "Failed to load recommendations.")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
templates.AnimeRecommendations(recs).Render(r.Context(), w)
|
animecomponents.Recommendations(recs).Render(r.Context(), w)
|
||||||
case "episodes":
|
case "episodes":
|
||||||
currentEpisode := r.URL.Query().Get("current")
|
currentEpisode := r.URL.Query().Get("current")
|
||||||
episodes, err := h.getEpisodes(r.Context(), id)
|
episodes, err := h.getEpisodes(r.Context(), id)
|
||||||
@@ -237,7 +239,7 @@ func (h *Handler) HandleAPIAnime(w http.ResponseWriter, r *http.Request) {
|
|||||||
writeInlineLoadError(w, "Failed to load episodes.")
|
writeInlineLoadError(w, "Failed to load episodes.")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
templates.EpisodeList(episodes, currentEpisode, id).Render(r.Context(), w)
|
watchcomponents.EpisodeList(episodes, currentEpisode, id).Render(r.Context(), w)
|
||||||
default:
|
default:
|
||||||
renderNotFoundPage(r, w)
|
renderNotFoundPage(r, w)
|
||||||
}
|
}
|
||||||
@@ -261,7 +263,7 @@ func (h *Handler) HandleAPIEpisodes(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
templates.EpisodeList(episodes, currentEpisode, id).Render(r.Context(), w)
|
watchcomponents.EpisodeList(episodes, currentEpisode, id).Render(r.Context(), w)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Handler) getEpisodes(ctx context.Context, animeID int) ([]jikan.Episode, error) {
|
func (h *Handler) getEpisodes(ctx context.Context, animeID int) ([]jikan.Episode, error) {
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import (
|
|||||||
"mal/integrations/jikan"
|
"mal/integrations/jikan"
|
||||||
"mal/internal/db"
|
"mal/internal/db"
|
||||||
"mal/internal/middleware"
|
"mal/internal/middleware"
|
||||||
|
"mal/web/shared"
|
||||||
"mal/web/templates"
|
"mal/web/templates"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -96,8 +97,8 @@ func (h *Handler) HandleWatchPage(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert playback.WatchPageData to templates.WatchPageData
|
// Convert playback.WatchPageData to shared.WatchPageData
|
||||||
pageData := templates.WatchPageData{
|
pageData := shared.WatchPageData{
|
||||||
MalID: data.MalID,
|
MalID: data.MalID,
|
||||||
Title: data.Title,
|
Title: data.Title,
|
||||||
TitleEnglish: anime.TitleEnglish,
|
TitleEnglish: anime.TitleEnglish,
|
||||||
@@ -155,17 +156,17 @@ func playbackTitleCandidates(anime jikan.Anime) []string {
|
|||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
|
|
||||||
func convertModeSources(sources map[string]ModeSource) map[string]templates.ModeSource {
|
func convertModeSources(sources map[string]ModeSource) map[string]shared.ModeSource {
|
||||||
result := make(map[string]templates.ModeSource, len(sources))
|
result := make(map[string]shared.ModeSource, len(sources))
|
||||||
for k, v := range sources {
|
for k, v := range sources {
|
||||||
subtitles := make([]templates.SubtitleItem, len(v.Subtitles))
|
subtitles := make([]shared.SubtitleItem, len(v.Subtitles))
|
||||||
for i, s := range v.Subtitles {
|
for i, s := range v.Subtitles {
|
||||||
subtitles[i] = templates.SubtitleItem{
|
subtitles[i] = shared.SubtitleItem{
|
||||||
Lang: s.Lang,
|
Lang: s.Lang,
|
||||||
Token: s.Token,
|
Token: s.Token,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
result[k] = templates.ModeSource{
|
result[k] = shared.ModeSource{
|
||||||
Token: v.Token,
|
Token: v.Token,
|
||||||
Subtitles: subtitles,
|
Subtitles: subtitles,
|
||||||
}
|
}
|
||||||
@@ -173,10 +174,10 @@ func convertModeSources(sources map[string]ModeSource) map[string]templates.Mode
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
func convertSegments(segments []SkipSegment) []templates.SkipSegment {
|
func convertSegments(segments []SkipSegment) []shared.SkipSegment {
|
||||||
result := make([]templates.SkipSegment, len(segments))
|
result := make([]shared.SkipSegment, len(segments))
|
||||||
for i, s := range segments {
|
for i, s := range segments {
|
||||||
result[i] = templates.SkipSegment{
|
result[i] = shared.SkipSegment{
|
||||||
Type: s.Type,
|
Type: s.Type,
|
||||||
Start: s.Start,
|
Start: s.Start,
|
||||||
End: s.End,
|
End: s.End,
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import (
|
|||||||
|
|
||||||
"mal/internal/db"
|
"mal/internal/db"
|
||||||
"mal/internal/middleware"
|
"mal/internal/middleware"
|
||||||
|
"mal/web/components/watchlist"
|
||||||
"mal/web/templates"
|
"mal/web/templates"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -84,7 +85,7 @@ func (h *Handler) HandleUpdateWatchlist(w http.ResponseWriter, r *http.Request)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
templates.WatchlistDropdown(int(animeID), animeTitle, animeTitleEnglish, animeTitleJapanese, animeImage, status, airing).Render(r.Context(), w)
|
watchlist.WatchlistDropdown(int(animeID), animeTitle, animeTitleEnglish, animeTitleJapanese, animeImage, status, airing).Render(r.Context(), w)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Handler) HandleDeleteWatchlist(w http.ResponseWriter, r *http.Request) {
|
func (h *Handler) HandleDeleteWatchlist(w http.ResponseWriter, r *http.Request) {
|
||||||
@@ -128,7 +129,7 @@ func (h *Handler) HandleDeleteWatchlist(w http.ResponseWriter, r *http.Request)
|
|||||||
airing = anime.Airing.Bool
|
airing = anime.Airing.Bool
|
||||||
}
|
}
|
||||||
|
|
||||||
templates.WatchlistDropdown(int(animeID), anime.TitleOriginal, title, "", anime.ImageUrl, "", airing).Render(r.Context(), w)
|
watchlist.WatchlistDropdown(int(animeID), anime.TitleOriginal, title, "", anime.ImageUrl, "", airing).Render(r.Context(), w)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Handler) HandleGetWatchlist(w http.ResponseWriter, r *http.Request) {
|
func (h *Handler) HandleGetWatchlist(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|||||||
@@ -2,14 +2,14 @@ package anime
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"mal/integrations/jikan"
|
"mal/integrations/jikan"
|
||||||
"mal/web/components"
|
ui "mal/web/components"
|
||||||
)
|
)
|
||||||
|
|
||||||
templ Recommendations(recs []jikan.Anime) {
|
templ Recommendations(recs []jikan.Anime) {
|
||||||
if len(recs) > 0 {
|
if len(recs) > 0 {
|
||||||
<div class="grid grid-cols-2 gap-3 sm:grid-cols-3 md:gap-4 lg:grid-cols-4 xl:grid-cols-5">
|
<div class="grid grid-cols-2 gap-3 sm:grid-cols-3 md:gap-4 lg:grid-cols-4 xl:grid-cols-5">
|
||||||
for _, anime := range recs {
|
for _, anime := range recs {
|
||||||
@components.AnimeCard(components.AnimeCardProps{
|
@ui.AnimeCard(ui.AnimeCardProps{
|
||||||
ID: anime.MalID,
|
ID: anime.MalID,
|
||||||
Title: anime.DisplayTitle(),
|
Title: anime.DisplayTitle(),
|
||||||
ImageURL: anime.ImageURL(),
|
ImageURL: anime.ImageURL(),
|
||||||
|
|||||||
@@ -1,16 +1,15 @@
|
|||||||
package anime
|
package anime
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"mal/integrations/jikan"
|
"mal/integrations/jikan"
|
||||||
"mal/web/components"
|
ui "mal/web/components"
|
||||||
)
|
)
|
||||||
|
|
||||||
templ RelationsList(relations []jikan.RelationEntry) {
|
templ RelationsList(relations []jikan.RelationEntry) {
|
||||||
if len(relations) > 1 {
|
if len(relations) > 1 {
|
||||||
<div class="grid grid-cols-2 gap-3 sm:grid-cols-3 md:gap-4 lg:grid-cols-4 xl:grid-cols-5" id="relations-grid">
|
<div class="grid grid-cols-2 gap-3 sm:grid-cols-3 md:gap-4 lg:grid-cols-4 xl:grid-cols-5" id="relations-grid">
|
||||||
for _, rel := range relations {
|
for _, rel := range relations {
|
||||||
@components.AnimeCard(components.AnimeCardProps{
|
@ui.AnimeCard(ui.AnimeCardProps{
|
||||||
ID: rel.Anime.MalID,
|
ID: rel.Anime.MalID,
|
||||||
Title: rel.Anime.DisplayTitle(),
|
Title: rel.Anime.DisplayTitle(),
|
||||||
ImageURL: rel.Anime.ImageURL(),
|
ImageURL: rel.Anime.ImageURL(),
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package watch
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"mal/web/components"
|
|
||||||
"mal/web/shared"
|
"mal/web/shared"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -35,7 +34,7 @@ templ VideoPlayer(data shared.WatchPageData) {
|
|||||||
preload="metadata"
|
preload="metadata"
|
||||||
crossorigin="anonymous"
|
crossorigin="anonymous"
|
||||||
playsinline
|
playsinline
|
||||||
src={ buildStreamURL(data.InitialMode, streamToken) }
|
src={ shared.BuildStreamURL(data.InitialMode, streamToken) }
|
||||||
></video>
|
></video>
|
||||||
<div
|
<div
|
||||||
data-loading
|
data-loading
|
||||||
|
|||||||
@@ -2,7 +2,8 @@ package watchlist
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"mal/internal/db"
|
db "mal/internal/db"
|
||||||
|
"mal/web/shared"
|
||||||
)
|
)
|
||||||
|
|
||||||
templ Progress(entry db.GetUserWatchListRow) {
|
templ Progress(entry db.GetUserWatchListRow) {
|
||||||
@@ -10,7 +11,7 @@ templ Progress(entry db.GetUserWatchListRow) {
|
|||||||
<p class="m-0 mt-1 text-xs text-(--text-faint)">
|
<p class="m-0 mt-1 text-xs text-(--text-faint)">
|
||||||
Continue ep { fmt.Sprintf("%d", entry.CurrentEpisode.Int64) }
|
Continue ep { fmt.Sprintf("%d", entry.CurrentEpisode.Int64) }
|
||||||
if entry.CurrentTimeSeconds > 0 {
|
if entry.CurrentTimeSeconds > 0 {
|
||||||
{ fmt.Sprintf(" · %s", formatProgressTime(entry.CurrentTimeSeconds)) }
|
{ fmt.Sprintf(" · %s", shared.FormatProgressTime(entry.CurrentTimeSeconds)) }
|
||||||
}
|
}
|
||||||
</p>
|
</p>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,9 @@ package templates
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"mal/internal/db"
|
db "mal/internal/db"
|
||||||
"mal/web/components"
|
ui "mal/web/components"
|
||||||
|
"mal/web/shared"
|
||||||
"mal/web/shared/layout"
|
"mal/web/shared/layout"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -34,11 +35,11 @@ templ ContinueWatching(entries []db.GetContinueWatchingEntriesRow) {
|
|||||||
if entry.CurrentEpisode.Valid && entry.CurrentEpisode.Int64 > 0 {
|
if entry.CurrentEpisode.Valid && entry.CurrentEpisode.Int64 > 0 {
|
||||||
<span class="text-xs text-(--text-faint)">Continue ep { fmt.Sprintf("%d", entry.CurrentEpisode.Int64) }</span>
|
<span class="text-xs text-(--text-faint)">Continue ep { fmt.Sprintf("%d", entry.CurrentEpisode.Int64) }</span>
|
||||||
}
|
}
|
||||||
if entry.CurrentTimeSeconds > 0 {
|
if entry.CurrentTimeSeconds > 0 {
|
||||||
<span class="text-xs text-(--text-faint)">{ formatProgressTime(entry.CurrentTimeSeconds) }</span>
|
<span class="text-xs text-(--text-faint)">{ shared.FormatProgressTime(entry.CurrentTimeSeconds) }</span>
|
||||||
}
|
}
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
}
|
}
|
||||||
<button
|
<button
|
||||||
class="absolute right-2 top-2 h-6 w-6 cursor-pointer border-0 bg-(--overlay-subtle) text-(--text-muted) opacity-0 transition-opacity duration-150 group-hover:opacity-100 hover:text-(--danger)"
|
class="absolute right-2 top-2 h-6 w-6 cursor-pointer border-0 bg-(--overlay-subtle) text-(--text-muted) opacity-0 transition-opacity duration-150 group-hover:opacity-100 hover:text-(--danger)"
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ package templates
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"mal/internal/db"
|
db "mal/internal/db"
|
||||||
"mal/web/components"
|
components "mal/web/components"
|
||||||
"mal/web/components/watchlist"
|
"mal/web/components/watchlist"
|
||||||
"mal/web/shared"
|
"mal/web/shared"
|
||||||
"mal/web/shared/layout"
|
"mal/web/shared/layout"
|
||||||
@@ -140,7 +140,7 @@ templ Watchlist(
|
|||||||
id={ fmt.Sprintf("watchlist-entry-%d", entry.AnimeID) }
|
id={ fmt.Sprintf("watchlist-entry-%d", entry.AnimeID) }
|
||||||
>
|
>
|
||||||
<a
|
<a
|
||||||
href={ templ.URL(shared.AnimeURL(entry.AnimeID)) }
|
href={ templ.URL(shared.AnimeURL(int(entry.AnimeID))) }
|
||||||
class="flex flex-col bg-transparent text-inherit no-underline"
|
class="flex flex-col bg-transparent text-inherit no-underline"
|
||||||
>
|
>
|
||||||
<div class="flex w-full aspect-2/3 justify-center overflow-hidden">
|
<div class="flex w-full aspect-2/3 justify-center overflow-hidden">
|
||||||
@@ -185,7 +185,7 @@ templ Watchlist(
|
|||||||
id={ fmt.Sprintf("watchlist-entry-%d", entry.AnimeID) }
|
id={ fmt.Sprintf("watchlist-entry-%d", entry.AnimeID) }
|
||||||
>
|
>
|
||||||
<td class="p-2.5">
|
<td class="p-2.5">
|
||||||
<a href={ templ.URL(shared.AnimeURL(entry.AnimeID)) }>
|
<a href={ templ.URL(shared.AnimeURL(int(entry.AnimeID))) }>
|
||||||
<img
|
<img
|
||||||
src={ entry.ImageUrl }
|
src={ entry.ImageUrl }
|
||||||
alt={ entry.DisplayTitle() }
|
alt={ entry.DisplayTitle() }
|
||||||
@@ -195,7 +195,7 @@ templ Watchlist(
|
|||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
<td class="p-2.5 font-medium">
|
<td class="p-2.5 font-medium">
|
||||||
<a href={ templ.URL(shared.AnimeURL(entry.AnimeID)) }>
|
<a href={ templ.URL(shared.AnimeURL(int(entry.AnimeID))) }>
|
||||||
{ entry.DisplayTitle() }
|
{ entry.DisplayTitle() }
|
||||||
</a>
|
</a>
|
||||||
@watchlist.Progress(entry)
|
@watchlist.Progress(entry)
|
||||||
|
|||||||
Reference in New Issue
Block a user