From 8ece017a82ab542227b23edc84d9b86abcbe5f0f Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Sun, 25 Jun 2017 14:58:27 +0200 Subject: [PATCH] Improved anime list --- pages/animelist/animelist.go | 4 ++- pages/animelist/animelist.pixy | 21 ++++++++---- pages/animelist/animelist.scarlet | 46 +++++++++++++++++++++++--- pages/animelistitem/animelistitem.pixy | 1 + pages/embed/embed.go | 2 +- styles/extension.scarlet | 28 +--------------- 6 files changed, 62 insertions(+), 40 deletions(-) diff --git a/pages/animelist/animelist.go b/pages/animelist/animelist.go index d06f7227..a7e259d9 100644 --- a/pages/animelist/animelist.go +++ b/pages/animelist/animelist.go @@ -7,11 +7,13 @@ import ( "github.com/aerogo/aero" "github.com/animenotifier/arn" "github.com/animenotifier/notify.moe/components" + "github.com/animenotifier/notify.moe/utils" ) // Get anime list. func Get(ctx *aero.Context) string { nick := ctx.Get("nick") + user := utils.GetUser(ctx) viewUser, err := arn.GetUserByNick(nick) if err != nil { @@ -28,5 +30,5 @@ func Get(ctx *aero.Context) string { return animeList.Items[i].FinalRating() < animeList.Items[j].FinalRating() }) - return ctx.HTML(components.AnimeList(animeList)) + return ctx.HTML(components.AnimeList(animeList, user)) } diff --git a/pages/animelist/animelist.pixy b/pages/animelist/animelist.pixy index 89092062..0b4ca14b 100644 --- a/pages/animelist/animelist.pixy +++ b/pages/animelist/animelist.pixy @@ -1,17 +1,26 @@ -component AnimeList(animeList *arn.AnimeList) +component AnimeList(animeList *arn.AnimeList, user *arn.User) table.anime-list thead tr th.anime-list-item-name Anime - th.anime-list-item-episodes Progress + th.anime-list-item-episodes Episodes th.anime-list-item-rating Rating + if user != nil + th.anime-list-item-actions Actions tbody each item in animeList.Items tr.anime-list-item.mountable(title=item.Notes) td.anime-list-item-name a.ajax(href=item.Anime().Link())= item.Anime().Title.Canonical td.anime-list-item-episodes - span.anime-list-item-episodes-watched= item.Episodes - span.anime-list-item-episodes-separator / - span.anime-list-item-episodes-max= item.Anime().EpisodeCountString() - td.anime-list-item-rating= item.FinalRating() \ No newline at end of file + .anime-list-item-episodes-watched= item.Episodes + .anime-list-item-episodes-separator / + .anime-list-item-episodes-max= item.Anime().EpisodeCountString() + .anime-list-item-episodes-edit + a.ajax(href=item.Link(animeList.User().Nick), title="Edit anime") + RawIcon("pencil") + td.anime-list-item-rating= item.FinalRating() + if user != nil + td.anime-list-item-actions + a(href=arn.Nyaa.GetLink(item.Anime()), title="Search on Nyaa", target="_blank", rel="noopener") + RawIcon("download") \ No newline at end of file diff --git a/pages/animelist/animelist.scarlet b/pages/animelist/animelist.scarlet index e943c080..847bcad0 100644 --- a/pages/animelist/animelist.scarlet +++ b/pages/animelist/animelist.scarlet @@ -4,17 +4,53 @@ tr horizontal + + thead + display none .anime-list-item-name - flex 0.8 + flex 1 white-space nowrap text-overflow ellipsis overflow hidden .anime-list-item-episodes - flex 0.1 - text-align center + horizontal + justify-content flex-end + text-align right + white-space nowrap + flex-basis 120px + +.anime-list-item-episodes-watched + flex 0.4 + +.anime-list-item-episodes-separator + flex 0.2 + opacity 0.5 + +.anime-list-item-episodes-max + flex 0.4 + opacity 0.5 + +.anime-list-item-episodes-edit + flex 0.5 + + // Beautify icon alignment + .raw-icon + margin-bottom -2px .anime-list-item-rating - flex 0.1 - text-align center \ No newline at end of file + flex-basis 100px + text-align center + +.anime-list-item-actions + flex-basis 40px + text-align right + + // Beautify icon alignment + .raw-icon + margin-bottom -4px + +< 1100px + .anime-list-item-rating + display none \ No newline at end of file diff --git a/pages/animelistitem/animelistitem.pixy b/pages/animelistitem/animelistitem.pixy index a03510f2..8cf7f1d8 100644 --- a/pages/animelistitem/animelistitem.pixy +++ b/pages/animelistitem/animelistitem.pixy @@ -4,6 +4,7 @@ component AnimeListItem(viewUser *arn.User, item *arn.AnimeListItem, anime *arn. h2= anime.Title.Canonical InputNumber("Episodes", item.Episodes, "Episodes", "Number of episodes you watched", "0", arn.EpisodeCountMax(anime.EpisodeCount)) + InputNumber("Rating.Overall", int(item.Rating.Overall + 0.5), "Overall rating", "Overall rating on a scale of 0 to 10", "0", "10") InputNumber("RewatchCount", item.RewatchCount, "Rewatched", "How often you rewatched this anime", "0", "100") InputTextArea("Notes", item.Notes, "Notes", "Your notes") diff --git a/pages/embed/embed.go b/pages/embed/embed.go index 8c486ce2..8f5b60fc 100644 --- a/pages/embed/embed.go +++ b/pages/embed/embed.go @@ -27,5 +27,5 @@ func Get(ctx *aero.Context) string { return animeList.Items[i].FinalRating() < animeList.Items[j].FinalRating() }) - return utils.AllowEmbed(ctx, ctx.HTML(components.AnimeList(animeList))) + return utils.AllowEmbed(ctx, ctx.HTML(components.AnimeList(animeList, user))) } diff --git a/styles/extension.scarlet b/styles/extension.scarlet index 50eb9d4e..8af16956 100644 --- a/styles/extension.scarlet +++ b/styles/extension.scarlet @@ -1,36 +1,10 @@ .embedded + // Put navigation to the bottom of the screen flex-direction column-reverse !important .anime-list max-width 500px margin -1.1rem - - thead - display none - - .anime-list-item - // ui-element - // margin-bottom 0.5rem - - .anime-list-item-episodes - horizontal - text-align right - white-space nowrap - flex 0.2 - - .anime-list-item-episodes-watched - flex 0.4 - - .anime-list-item-episodes-max - opacity 0.5 - flex 0.4 - - .anime-list-item-episodes-separator - opacity 0.5 - flex 0.2 - - .anime-list-item-rating - display none #navigation font-size 0.9rem \ No newline at end of file