diff --git a/jobs/anime-characters/anime-characters.go b/jobs/anime-characters/anime-characters.go new file mode 100644 index 00000000..6f84a1f1 --- /dev/null +++ b/jobs/anime-characters/anime-characters.go @@ -0,0 +1,14 @@ +package main + +import ( + "github.com/animenotifier/arn" + "github.com/fatih/color" +) + +func main() { + anime, _ := arn.GetAnime("6887") + err := anime.RefreshAnimeCharacters() + arn.PanicOnError(err) + + color.Green("Finished.") +} diff --git a/jobs/sync-characters/sync-characters.go b/jobs/sync-characters/sync-characters.go new file mode 100644 index 00000000..11ed97ed --- /dev/null +++ b/jobs/sync-characters/sync-characters.go @@ -0,0 +1,30 @@ +package main + +import ( + "fmt" + + "github.com/animenotifier/arn" + "github.com/animenotifier/kitsu" + "github.com/fatih/color" +) + +func main() { + color.Yellow("Syncing characters with Kitsu DB") + + kitsuCharacters := kitsu.StreamCharacters() + + for kitsuCharacter := range kitsuCharacters { + character := &arn.Character{ + ID: kitsuCharacter.ID, + Name: kitsuCharacter.Attributes.Name, + Image: kitsu.FixImageURL(kitsuCharacter.Attributes.Image.Original), + Description: kitsuCharacter.Attributes.Description, + } + + fmt.Printf("%s %s\n", character.ID, character.Name) + + arn.PanicOnError(character.Save()) + } + + color.Green("Finished.") +} diff --git a/mixins/Character.pixy b/mixins/Character.pixy new file mode 100644 index 00000000..a697f00d --- /dev/null +++ b/mixins/Character.pixy @@ -0,0 +1,4 @@ +component Character(character *arn.Character) + a.character(href="#") + img.character-image.lazy(src="", data-src=character.Image, alt=character.Name, title=character.Name) + span.character-name= character.Name \ No newline at end of file diff --git a/pages/anime/anime.pixy b/pages/anime/anime.pixy index 10b31742..63f68651 100644 --- a/pages/anime/anime.pixy +++ b/pages/anime/anime.pixy @@ -147,6 +147,13 @@ component Anime(anime *arn.Anime, tracks []*arn.SoundTrack, user *arn.User, epis 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/character.scarlet b/pages/anime/character.scarlet new file mode 100644 index 00000000..a8b18d08 --- /dev/null +++ b/pages/anime/character.scarlet @@ -0,0 +1,25 @@ +.characters + horizontal-wrap + +.character + vertical + align-items center + margin 0.5rem + + :hover + .character-name + opacity 1 + +.character-image + border-radius 3px + object-fit cover + +.character-name + font-size 0.8rem + color text-color + opacity 0.5 + default-transition + +.character-image + width 112px + height 175px \ No newline at end of file diff --git a/pages/animelistitem/animelistitem.pixy b/pages/animelistitem/animelistitem.pixy index fd7653b9..3b9ced93 100644 --- a/pages/animelistitem/animelistitem.pixy +++ b/pages/animelistitem/animelistitem.pixy @@ -2,17 +2,19 @@ component AnimeListItem(viewUser *arn.User, item *arn.AnimeListItem, anime *arn. .widget-form.mountable .widget.anime-list-item-view(data-api="/api/animelist/" + viewUser.ID + "/update/" + anime.ID) h1= anime.Title.Canonical - - InputNumber("Episodes", float64(item.Episodes), "Episodes", "Number of episodes you watched", "0", arn.EpisodeCountMax(anime.EpisodeCount), "1") - .widget-input - label(for="Status") Status: - select.widget-element.action(id="Status", data-field="Status", value=item.Status, data-action="save", data-trigger="change") - option(value=arn.AnimeListStatusWatching) Watching - option(value=arn.AnimeListStatusCompleted) Completed - option(value=arn.AnimeListStatusPlanned) Plan to watch - option(value=arn.AnimeListStatusHold) On hold - option(value=arn.AnimeListStatusDropped) Dropped + .anime-list-item-progress-edit + .anime-list-item-episodes-edit + InputNumber("Episodes", float64(item.Episodes), "Episodes", "Number of episodes you watched", "0", arn.EpisodeCountMax(anime.EpisodeCount), "1") + + .widget-input.anime-list-item-status-edit + label(for="Status") Status: + select.widget-element.action(id="Status", data-field="Status", value=item.Status, data-action="save", data-trigger="change") + option(value=arn.AnimeListStatusWatching) Watching + option(value=arn.AnimeListStatusCompleted) Completed + option(value=arn.AnimeListStatusPlanned) Plan to watch + option(value=arn.AnimeListStatusHold) On hold + option(value=arn.AnimeListStatusDropped) Dropped .anime-list-item-rating-edit InputNumber("Rating.Overall", item.Rating.Overall, arn.OverallRatingName(item.Episodes), "Overall rating on a scale of 0 to 10", "0", "10", "0.1") diff --git a/pages/animelistitem/animelistitem.scarlet b/pages/animelistitem/animelistitem.scarlet index e1e7cc3e..a515568c 100644 --- a/pages/animelistitem/animelistitem.scarlet +++ b/pages/animelistitem/animelistitem.scarlet @@ -1,3 +1,15 @@ +// .anime-list-item-progress-edit +// horizontal-wrap +// justify-content space-between +// width 100% + +// .anime-list-item-episodes-edit +// flex 1 +// margin-right content-padding + +// .anime-list-item-status-edit +// flex-basis 50% + .anime-list-item-rating-edit horizontal-wrap justify-content space-between