Implemented ratings UI

This commit is contained in:
Eduard Urbach 2017-06-08 11:51:34 +02:00
parent 74b405e4b4
commit 4a6e4378ce
12 changed files with 92 additions and 18 deletions

View File

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

View File

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

View File

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

View File

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

2
mixins/Rating.pixy Normal file
View File

@ -0,0 +1,2 @@
component Rating(value float64)
.anime-rating= arn.AnimeRatingStars(value)

View File

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

View File

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

9
pages/awards/awards.go Normal file
View File

@ -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())
}

8
pages/awards/awards.pixy Normal file
View File

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

View File

@ -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.<br><a href='https://paypal.me/blitzprog' target='_blank' rel='noopener'>Support the development</a><br><a href='/auth/google'>Login via Google</a>")
return ctx.HTML("ARN 4.0 is currently under construction.<br><a href='https://paypal.me/blitzprog' target='_blank' rel='noopener'>Support the development</a>")
}

View File

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

View File

@ -6,7 +6,7 @@ mixin grid-cell
position relative
width 16vw
height 9vw
height 16vw
min-width 90px
min-height 127px
max-width 200px