- @ui.AnimeCard(ui.AnimeCardProps{
+ @components.AnimeCard(components.AnimeCardProps{
ID: anime.MalID,
Title: anime.DisplayTitle(),
ImageURL: anime.ImageURL(),
@@ -67,7 +71,7 @@ templ StudioLoadMore(studioID int, nextPage int) {
templ StudioAnimeItems(animes []jikan.Anime, hasNext bool, studioID int, nextPage int) {
for _, anime := range animes {
- @ui.AnimeCard(ui.AnimeCardProps{
+ @components.AnimeCard(components.AnimeCardProps{
ID: anime.MalID,
Title: anime.DisplayTitle(),
ImageURL: anime.ImageURL(),
@@ -98,19 +102,3 @@ templ StudioAnimeItems(animes []jikan.Anime, hasNext bool, studioID int, nextPag
})();
}
-
-func getProducerName(producer jikan.ProducerResponse) string {
- for _, title := range producer.Data.Titles {
- if title.Type == "Default" {
- return title.Title
- }
- }
- return "Studio"
-}
-
-func formatEstablishedDate(date string) string {
- if len(date) >= 10 {
- return date[:10]
- }
- return date
-}
diff --git a/web/templates/watch.templ b/web/templates/watch.templ
index 46767ec..7f03950 100644
--- a/web/templates/watch.templ
+++ b/web/templates/watch.templ
@@ -2,7 +2,6 @@ package templates
import (
"fmt"
- "net/url"
"mal/integrations/jikan"
"mal/web/components"
@@ -124,79 +123,3 @@ templ WatchPage(anime jikan.Anime, data shared.WatchPageData) {
}
}
-
-templ LoadingIndicatorSmall() {
-
-}
-
-templ EpisodeList(episodes []jikan.Episode, currentEpisode string, animeID int) {
- if len(episodes) == 0 {
-
No episodes available
- } else {
-
- for _, ep := range episodes {
- @EpisodeItem(ep, currentEpisode, animeID)
- }
-
- }
-}
-
-templ EpisodeItem(episode jikan.Episode, currentEpisode string, animeID int) {
- {{ isCurrent := fmt.Sprintf("%d", episode.MalID) == currentEpisode }}
-
-
- { fmt.Sprintf("%d", episode.MalID) }
-
-
- if episode.Title != "" {
- { episode.Title }
- } else {
- Episode { fmt.Sprintf("%d", episode.MalID) }
- }
-
-
- if episode.Filler {
-
- Filler
-
- }
- if episode.Recap {
-
- Recap
-
- }
- if isCurrent {
-
- }
-
-
-}
-
-func buildStreamURL(mode string, token string) string {
- if token == "" {
- return ""
- }
- return fmt.Sprintf("/watch/proxy/stream?mode=%s&token=%s", url.QueryEscape(mode), url.QueryEscape(token))
-}
diff --git a/web/templates/watchlist.templ b/web/templates/watchlist.templ
index a457110..3800b47 100644
--- a/web/templates/watchlist.templ
+++ b/web/templates/watchlist.templ
@@ -2,10 +2,11 @@ package templates
import (
"fmt"
+
"mal/internal/db"
"mal/web/components"
"mal/web/components/watchlist"
- "math"
+ "mal/web/shared"
)
templ Watchlist(
@@ -59,14 +60,14 @@ templ Watchlist(
class="flex flex-wrap gap-2 max-md:flex-nowrap max-md:overflow-x-auto max-md:pb-1"
>
Grid
Table
@@ -77,38 +78,38 @@ templ Watchlist(
class="mb-3 flex flex-wrap gap-2 max-md:flex-nowrap max-md:overflow-x-auto max-md:pb-1"
>
All
Watching
On hold
Plan to watch
Dropped
Completed
@@ -138,7 +139,7 @@ templ Watchlist(
id={ fmt.Sprintf("watchlist-entry-%d", entry.AnimeID) }
>
@@ -183,7 +184,7 @@ templ Watchlist(
id={ fmt.Sprintf("watchlist-entry-%d", entry.AnimeID) }
>
-
+
|
-
+
{ entry.DisplayTitle() }
@watchlist.Progress(entry)
@@ -216,41 +217,3 @@ templ Watchlist(
}
}
}
-
-templ ifHasProgress(entry db.GetUserWatchListRow) {
- if entry.CurrentEpisode.Valid && entry.CurrentEpisode.Int64 > 0 && entry.Status != "completed" {
-
- Continue ep { fmt.Sprintf("%d", entry.CurrentEpisode.Int64) }
- if entry.CurrentTimeSeconds > 0 {
- { fmt.Sprintf(" ยท %s", formatProgressTime(entry.CurrentTimeSeconds)) }
- }
-
- }
-}
-
-func watchURL(entry db.GetUserWatchListRow) string {
- return fmt.Sprintf("/anime/%d", entry.AnimeID)
-}
-
-func formatProgressTime(seconds float64) string {
- total := int(math.Round(seconds))
- if total < 0 {
- total = 0
- }
-
- minutes := total / 60
- remainingSeconds := total % 60
- return fmt.Sprintf("%02d:%02d", minutes, remainingSeconds)
-}
-
-func tabClass(active bool) string {
- base := "shrink-0 whitespace-nowrap bg-(--panel-soft) px-2 py-1 text-xs text-(--text-muted) no-underline hover:bg-(--surface-tab-hover) hover:text-(--text) hover:no-underline"
- if active {
- return "shrink-0 whitespace-nowrap bg-(--surface-tab-active) px-2 py-1 text-xs text-(--accent) no-underline hover:no-underline"
- }
- return base
-}
-
-func watchlistURL(view string, status string, sortBy string, sortOrder string) string {
- return fmt.Sprintf("/watchlist?view=%s&status=%s&sort=%s&order=%s", view, status, sortBy, sortOrder)
-}
|