diff --git a/jobs/sync-media-relations/sync-media-relations.go b/jobs/sync-media-relations/sync-media-relations.go index bd7a5ecd..71206674 100644 --- a/jobs/sync-media-relations/sync-media-relations.go +++ b/jobs/sync-media-relations/sync-media-relations.go @@ -26,6 +26,19 @@ func main() { animeID := mediaRelation.Relationships.Source.Data.ID destinationAnimeID := mediaRelation.Relationships.Destination.Data.ID + // Confirm that the anime IDs are valid + exists, _ := arn.DB.Exists("Anime", animeID) + + if !exists { + continue + } + + exists, _ = arn.DB.Exists("Anime", destinationAnimeID) + + if !exists { + continue + } + fmt.Printf( "%s %s has %s which is %s %s\n", mediaRelation.Relationships.Source.Data.Type, @@ -35,6 +48,7 @@ func main() { destinationAnimeID, ) + // Add anime to the global map relationsList, found := relations[animeID] if !found { diff --git a/pages/anime/anime.go b/pages/anime/anime.go index d256057e..308a09c0 100644 --- a/pages/anime/anime.go +++ b/pages/anime/anime.go @@ -2,6 +2,7 @@ package anime import ( "net/http" + "sort" "github.com/aerogo/aero" "github.com/animenotifier/arn" @@ -66,6 +67,17 @@ func Get(ctx *aero.Context) string { arn.SortUsersLastSeen(friends) } + // Sort relations by start date + relations := anime.Relations() + + if relations != nil { + items := relations.Items + + sort.Slice(items, func(i, j int) bool { + return items[i].Anime().StartDate < items[j].Anime().StartDate + }) + } + // Open Graph description := anime.Summary diff --git a/pages/anime/anime.pixy b/pages/anime/anime.pixy index 647087c8..15d77ac2 100644 --- a/pages/anime/anime.pixy +++ b/pages/anime/anime.pixy @@ -3,6 +3,9 @@ component Anime(anime *arn.Anime, friends []*arn.User, listItems map[*arn.User]* if anime.Image.Small != "" .anime-image-container img.anime-cover-image(src=anime.Image.Small, alt=anime.Title.Canonical) + + if anime.StartDate != "" + .anime-start-date(title="Start date: " + anime.StartDate)= anime.StartDate[:4] .space @@ -35,21 +38,6 @@ component Anime(anime *arn.Anime, friends []*arn.User, listItems map[*arn.User]* Icon("plus") span Add to collection - if len(friends) > 0 - h3.anime-section-name Friends - - .anime-friends - .user-avatars - each friend in friends - if friend.Nick != "" - if friend.IsActive() - .mountable - FriendEntry(friend, listItems) - else - .mountable - .inactive-user - FriendEntry(friend, listItems) - h3.anime-section-name Ratings .anime-rating-categories .anime-rating-category(title=toString(anime.Rating.Overall)) @@ -68,6 +56,32 @@ component Anime(anime *arn.Anime, friends []*arn.User, listItems map[*arn.User]* .anime-rating-category-name Soundtrack Rating(anime.Rating.Soundtrack) + if len(friends) > 0 + h3.anime-section-name Friends + + .anime-friends + .user-avatars + each friend in friends + if friend.Nick != "" + if friend.IsActive() + .mountable + FriendEntry(friend, listItems) + else + .mountable + .inactive-user + FriendEntry(friend, listItems) + + if anime.Relations() != nil && len(anime.Relations().Items) > 0 + h3.anime-section-name Relations + .anime-relations + each relation in anime.Relations().Items + a.anime-relation.ajax(href=relation.Anime().Link(), title=relation.Anime().Title.Canonical) + img.anime-relation-image.lazy(data-src=relation.Anime().Image.Tiny, alt=relation.Anime().Title.Canonical) + .anime-relation-type= relation.HumanReadableType() + .anime-relation-year + if relation.Anime().StartDate != "" + span= relation.Anime().StartDate[:4] + if len(anime.Trailers) > 0 && anime.Trailers[0].Service == "Youtube" && anime.Trailers[0].ServiceID != "" h3.anime-section-name Video .anime-trailer.video-container @@ -156,19 +170,6 @@ component Anime(anime *arn.Anime, friends []*arn.User, listItems map[*arn.User]* //- if providers.Nyaa && providers.Nyaa.episodes !== undefined //- span(class=providers.Nyaa.episodes === 0 ? "entry-error" : "entry-ok")= providers.Nyaa.episodes + " eps" - if len(tracks) > 0 - h3.anime-section-name Tracks - .sound-tracks - each track in tracks - SoundTrack(track) - - if anime.Characters() != nil && len(anime.Characters().Items) > 0 - h3.anime-section-name Characters - .characters - each character in anime.Characters().Items - if character.Character() != nil - Character(character.Character()) - h3.anime-section-name Popularity .anime-rating-categories .anime-rating-category @@ -187,6 +188,19 @@ component Anime(anime *arn.Anime, friends []*arn.User, listItems map[*arn.User]* .anime-rating-category-name Dropped .anime-rating= anime.Popularity.Dropped + if len(tracks) > 0 + h3.anime-section-name Tracks + .sound-tracks + each track in tracks + SoundTrack(track) + + if anime.Characters() != nil && len(anime.Characters().Items) > 0 + h3.anime-section-name Characters + .characters + each character in anime.Characters().Items + if character.Character() != nil + Character(character.Character()) + if len(anime.Episodes().Items) > 0 if episodesReversed h3.anime-section-name Latest episodes diff --git a/pages/anime/anime.scarlet b/pages/anime/anime.scarlet index 117b3536..a7635f19 100644 --- a/pages/anime/anime.scarlet +++ b/pages/anime/anime.scarlet @@ -9,9 +9,15 @@ font-weight bold .anime-image-container - horizontal - justify-content center - align-items flex-start + vertical + justify-content flex-start + align-items center + +.anime-start-date + font-size 0.7rem + line-height 1.7em + opacity 0.65 + margin-top 0.5rem .anime-cover-image width 142px diff --git a/pages/anime/relation.scarlet b/pages/anime/relation.scarlet new file mode 100644 index 00000000..aab9872c --- /dev/null +++ b/pages/anime/relation.scarlet @@ -0,0 +1,24 @@ +.anime-relations + horizontal-wrap + +.anime-relation + anime-mini-item + vertical + +.anime-relation-image + anime-mini-item-image + +.anime-relation-type, +.anime-relation-year + font-size 0.7rem + line-height 1.7em + text-align center + color text-color + opacity 0.8 + +.anime-relation-type + margin-top 0.2rem + +.anime-relation-year + font-size 0.6rem + opacity 0.65 \ No newline at end of file diff --git a/pages/profile/watching.scarlet b/pages/profile/watching.scarlet index 3cd77f89..82b2bcd3 100644 --- a/pages/profile/watching.scarlet +++ b/pages/profile/watching.scarlet @@ -3,7 +3,7 @@ justify-content center .profile-watching-list-item - margin 0.25rem + anime-mini-item .profile-watching-list-item-image - anime-cover-image-mini \ No newline at end of file + anime-mini-item-image \ No newline at end of file diff --git a/pages/soundtrack/soundtrack.scarlet b/pages/soundtrack/soundtrack.scarlet index 692df7bc..a1ad6dc2 100644 --- a/pages/soundtrack/soundtrack.scarlet +++ b/pages/soundtrack/soundtrack.scarlet @@ -9,7 +9,7 @@ horizontal-wrap .sound-track-anime-list-item - // + anime-mini-item .sound-track-anime-list-item-image - anime-cover-image-mini \ No newline at end of file + anime-mini-item-image \ No newline at end of file diff --git a/styles/include/mixins.scarlet b/styles/include/mixins.scarlet index 417c1f49..1249b597 100644 --- a/styles/include/mixins.scarlet +++ b/styles/include/mixins.scarlet @@ -42,7 +42,10 @@ mixin clip-long-text white-space nowrap text-overflow ellipsis -mixin anime-cover-image-mini +mixin anime-mini-item + margin 0.25rem + +mixin anime-mini-item-image width 55px !important height 78px !important border-radius 2px