Implemented anime characters

This commit is contained in:
Eduard Urbach 2017-07-13 07:53:36 +02:00
parent 84e246d31f
commit a539fa0f83
7 changed files with 104 additions and 10 deletions

View File

@ -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.")
}

View File

@ -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.")
}

4
mixins/Character.pixy Normal file
View File

@ -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

View File

@ -147,6 +147,13 @@ component Anime(anime *arn.Anime, tracks []*arn.SoundTrack, user *arn.User, epis
each track in tracks each track in tracks
SoundTrack(track) 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 len(anime.Episodes().Items) > 0
if episodesReversed if episodesReversed
h3.anime-section-name Latest episodes h3.anime-section-name Latest episodes

View File

@ -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

View File

@ -2,17 +2,19 @@ component AnimeListItem(viewUser *arn.User, item *arn.AnimeListItem, anime *arn.
.widget-form.mountable .widget-form.mountable
.widget.anime-list-item-view(data-api="/api/animelist/" + viewUser.ID + "/update/" + anime.ID) .widget.anime-list-item-view(data-api="/api/animelist/" + viewUser.ID + "/update/" + anime.ID)
h1= anime.Title.Canonical h1= anime.Title.Canonical
InputNumber("Episodes", float64(item.Episodes), "Episodes", "Number of episodes you watched", "0", arn.EpisodeCountMax(anime.EpisodeCount), "1")
.widget-input .anime-list-item-progress-edit
label(for="Status") Status: .anime-list-item-episodes-edit
select.widget-element.action(id="Status", data-field="Status", value=item.Status, data-action="save", data-trigger="change") InputNumber("Episodes", float64(item.Episodes), "Episodes", "Number of episodes you watched", "0", arn.EpisodeCountMax(anime.EpisodeCount), "1")
option(value=arn.AnimeListStatusWatching) Watching
option(value=arn.AnimeListStatusCompleted) Completed .widget-input.anime-list-item-status-edit
option(value=arn.AnimeListStatusPlanned) Plan to watch label(for="Status") Status:
option(value=arn.AnimeListStatusHold) On hold select.widget-element.action(id="Status", data-field="Status", value=item.Status, data-action="save", data-trigger="change")
option(value=arn.AnimeListStatusDropped) Dropped 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 .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") InputNumber("Rating.Overall", item.Rating.Overall, arn.OverallRatingName(item.Episodes), "Overall rating on a scale of 0 to 10", "0", "10", "0.1")

View File

@ -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 .anime-list-item-rating-edit
horizontal-wrap horizontal-wrap
justify-content space-between justify-content space-between