From 4a6e4378ce101f1a85572b80827fe3ede0aa56aa Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Thu, 8 Jun 2017 11:51:34 +0200 Subject: [PATCH] Implemented ratings UI --- deploy.sh | 2 +- jobs/airing-anime/airing-anime.go | 2 +- jobs/sync-anime/sync-anime.go | 14 +++++++++ main.go | 2 ++ mixins/Rating.pixy | 2 ++ pages/anime/anime.pixy | 36 +++++++++++++++------- pages/anime/anime.scarlet | 24 +++++++++++++++ pages/awards/awards.go | 9 ++++++ pages/awards/awards.pixy | 8 +++++ pages/dashboard/dashboard.go | 3 +- patches/user-references/user-references.go | 6 ++-- styles/grid.scarlet | 2 +- 12 files changed, 92 insertions(+), 18 deletions(-) create mode 100644 mixins/Rating.pixy create mode 100644 pages/awards/awards.go create mode 100644 pages/awards/awards.pixy diff --git a/deploy.sh b/deploy.sh index 4e65a3b6..3609ca74 100755 --- a/deploy.sh +++ b/deploy.sh @@ -2,4 +2,4 @@ #pack #go build scp notify.moe eduard@arn:~/beta/notify.moe.new -ssh eduard@arn 'cd beta; killall notify.moe; rm notify.moe; mv notify.moe.new notify.moe; ./notify.moe > log.txt &' +ssh eduard@arn 'cd beta; killall notify.moe; rm notify.moe; mv notify.moe.new notify.moe; nohup ./notify.moe &' diff --git a/jobs/airing-anime/airing-anime.go b/jobs/airing-anime/airing-anime.go index e12e680e..350a10a1 100644 --- a/jobs/airing-anime/airing-anime.go +++ b/jobs/airing-anime/airing-anime.go @@ -19,7 +19,7 @@ func main() { } sort.Slice(animeList, func(i, j int) bool { - return animeList[i].StartDate > animeList[j].StartDate + return animeList[i].Rating.Overall > animeList[j].Rating.Overall }) // Convert to small anime list diff --git a/jobs/sync-anime/sync-anime.go b/jobs/sync-anime/sync-anime.go index 4e0e3763..0795f16b 100644 --- a/jobs/sync-anime/sync-anime.go +++ b/jobs/sync-anime/sync-anime.go @@ -2,6 +2,7 @@ package main import ( "fmt" + "strconv" "strings" "github.com/animenotifier/arn" @@ -27,6 +28,7 @@ func sync(data *kitsu.Anime) { anime := arn.Anime{} attr := data.Attributes + // General data anime.ID = data.ID anime.Type = strings.ToLower(attr.ShowType) anime.Title.Canonical = attr.CanonicalTitle @@ -46,6 +48,16 @@ func sync(data *kitsu.Anime) { anime.NSFW = attr.Nsfw anime.Summary = arn.FixAnimeDescription(attr.Synopsis) + // Rating + overall, convertError := strconv.ParseFloat(attr.AverageRating, 64) + + if convertError != nil { + overall = 0 + } + + anime.Rating.Overall = overall + + // Trailers if attr.YoutubeVideoID != "" { anime.Trailers = append(anime.Trailers, arn.AnimeTrailer{ Service: "Youtube", @@ -53,6 +65,7 @@ func sync(data *kitsu.Anime) { }) } + // Save in database err := anime.Save() status := "" @@ -62,5 +75,6 @@ func sync(data *kitsu.Anime) { status = color.RedString("✘") } + // Log fmt.Println(status, anime.ID, anime.Title.Canonical) } diff --git a/main.go b/main.go index 436d85bb..27b96372 100644 --- a/main.go +++ b/main.go @@ -5,6 +5,7 @@ import ( "github.com/animenotifier/notify.moe/components" "github.com/animenotifier/notify.moe/pages/airing" "github.com/animenotifier/notify.moe/pages/anime" + "github.com/animenotifier/notify.moe/pages/awards" "github.com/animenotifier/notify.moe/pages/dashboard" "github.com/animenotifier/notify.moe/pages/forum" "github.com/animenotifier/notify.moe/pages/forums" @@ -52,6 +53,7 @@ func main() { app.Ajax("/user/:nick", profile.Get) app.Ajax("/airing", airing.Get) app.Ajax("/users", users.Get) + app.Ajax("/awards", awards.Get) EnableGoogleLogin(app) diff --git a/mixins/Rating.pixy b/mixins/Rating.pixy new file mode 100644 index 00000000..db803beb --- /dev/null +++ b/mixins/Rating.pixy @@ -0,0 +1,2 @@ +component Rating(value float64) + .anime-rating= arn.AnimeRatingStars(value) \ No newline at end of file diff --git a/pages/anime/anime.pixy b/pages/anime/anime.pixy index 384a03f2..c6718b16 100644 --- a/pages/anime/anime.pixy +++ b/pages/anime/anime.pixy @@ -18,6 +18,21 @@ component Anime(anime *arn.Anime) //- h3.anime-section-name.anime-summary-header Summary p.anime-summary= anime.Summary + h3.anime-section-name Ratings + .anime-rating-categories + .anime-rating-category(title=toString(anime.Rating.Overall)) + .anime-rating-category-name Overall + Rating(anime.Rating.Overall) + .anime-rating-category(title=toString(anime.Rating.Story)) + .anime-rating-category-name Story + Rating(anime.Rating.Story) + .anime-rating-category(title=toString(anime.Rating.Visuals)) + .anime-rating-category-name Visuals + Rating(anime.Rating.Visuals) + .anime-rating-category(title=toString(anime.Rating.Music)) + .anime-rating-category-name Music + Rating(anime.Rating.Music) + if len(anime.Trailers) > 0 && anime.Trailers[0].Service == "Youtube" && anime.Trailers[0].VideoID != "" h3.anime-section-name Video .anime-trailer.video-container @@ -106,18 +121,17 @@ component Anime(anime *arn.Anime) //- if providers.Nyaa && providers.Nyaa.episodes !== undefined //- span(class=providers.Nyaa.episodes === 0 ? "entry-error" : "entry-ok")= providers.Nyaa.episodes + " eps" - //- h3.anime-section-name Links - //- .light-button-group - //- if anime.Links != nil - //- each link in anime.Links - //- a.light-button(href=link.URL, target="_blank") - //- Icon("external-link") - //- span= link.Title + h3.anime-section-name Links + .light-button-group + //- if anime.Links != nil + //- each link in anime.Links + //- a.light-button(href=link.URL, target="_blank") + //- Icon("external-link") + //- span= link.Title - //- if anime.CreatedBy == "" - //- a.light-button(href="https://anilist.co/anime/" + toString(anime.ID), target="_blank") - //- Icon("external-link") - //- span AniList + a.light-button(href="https://kitsu.io/anime/" + anime.ID, target="_blank", rel="noopener") + Icon("external-link") + span Kitsu //- if providers.HummingBird //- a.light-button(href="https://hummingbird.me/anime/" + providers.HummingBird.providerId, target="_blank") HummingBird diff --git a/pages/anime/anime.scarlet b/pages/anime/anime.scarlet index e84dfeba..a83c2bfa 100644 --- a/pages/anime/anime.scarlet +++ b/pages/anime/anime.scarlet @@ -41,6 +41,30 @@ margin-bottom 0.5rem color rgba(60, 60, 60, 0.5) !important +.anime-rating-categories + horizontal + width 100% + +.anime-rating-category + ui-element + flex 1 + text-align center + margin 0.5rem + +.anime-rating-category-name + font-size 1.3rem + margin-top 0.5rem + +.anime-rating + margin 0.5rem + letter-spacing 3px + font-size 1.3rem + color link-color + +< 800px + .anime-rating-categories + vertical + .sources font-size 0.8em opacity 0.5 diff --git a/pages/awards/awards.go b/pages/awards/awards.go new file mode 100644 index 00000000..02ff41f7 --- /dev/null +++ b/pages/awards/awards.go @@ -0,0 +1,9 @@ +package awards + +import "github.com/aerogo/aero" +import "github.com/animenotifier/notify.moe/components" + +// Get ... +func Get(ctx *aero.Context) string { + return ctx.HTML(components.Awards()) +} diff --git a/pages/awards/awards.pixy b/pages/awards/awards.pixy new file mode 100644 index 00000000..cdc0e352 --- /dev/null +++ b/pages/awards/awards.pixy @@ -0,0 +1,8 @@ +component Awards + h2.page-title Awards + + ul + li + a(href="https://developers.google.com/speed/pagespeed/insights/?url=https://notify.moe/&tab=desktop", target="_blank", rel="noopener") Google PageSpeed + li + a(href="https://observatory.mozilla.org/analyze.html?host=notify.moe", target="_blank", rel="noopener") Mozilla Observatory \ No newline at end of file diff --git a/pages/dashboard/dashboard.go b/pages/dashboard/dashboard.go index 302aa607..2bb2cc2f 100644 --- a/pages/dashboard/dashboard.go +++ b/pages/dashboard/dashboard.go @@ -11,7 +11,6 @@ const maxPosts = 5 // Get ... func Get(ctx *aero.Context) string { - user := utils.GetUser(ctx) if user != nil { @@ -30,5 +29,5 @@ func Get(ctx *aero.Context) string { return ctx.HTML(components.Dashboard(posts)) } - return ctx.HTML("ARN 4.0 is currently under construction.
Support the development
Login via Google") + return ctx.HTML("ARN 4.0 is currently under construction.
Support the development") } diff --git a/patches/user-references/user-references.go b/patches/user-references/user-references.go index cd5798a2..a3b47a79 100644 --- a/patches/user-references/user-references.go +++ b/patches/user-references/user-references.go @@ -8,7 +8,6 @@ import ( func main() { color.Yellow("Updating user references") - // Delete Nick:User records arn.Truncate("NickToUser") arn.Truncate("EmailToUser") @@ -26,7 +25,10 @@ func main() { println(count, user.Nick) user.SetNick(user.Nick) - user.SetEmail(user.Email) + + if user.Email != "" { + user.SetEmail(user.Email) + } } color.Green("Finished.") diff --git a/styles/grid.scarlet b/styles/grid.scarlet index a4152774..02ab8502 100644 --- a/styles/grid.scarlet +++ b/styles/grid.scarlet @@ -6,7 +6,7 @@ mixin grid-cell position relative width 16vw - height 9vw + height 16vw min-width 90px min-height 127px max-width 200px