Show relations
This commit is contained in:
parent
3fe3d00134
commit
12558bf718
@ -12,6 +12,11 @@ type AiringAnimeCache struct {
|
||||
Anime []*arn.Anime `json:"anime"`
|
||||
}
|
||||
|
||||
// AiringAnimeCacheSmall ...
|
||||
type AiringAnimeCacheSmall struct {
|
||||
Anime []*arn.AnimeSmall `json:"anime"`
|
||||
}
|
||||
|
||||
// AiringAnime ...
|
||||
func AiringAnime() {
|
||||
animeList, err := arn.GetAiringAnime()
|
||||
@ -24,8 +29,20 @@ func AiringAnime() {
|
||||
|
||||
sort.Sort(arn.AnimeByPopularity(animeList))
|
||||
|
||||
saveErr := arn.SetObject("Cache", "airingAnime", &AiringAnimeCache{
|
||||
Anime: animeList,
|
||||
// Convert to small anime list
|
||||
var animeListSmall []*arn.AnimeSmall
|
||||
|
||||
for _, anime := range animeList {
|
||||
animeListSmall = append(animeListSmall, &arn.AnimeSmall{
|
||||
ID: anime.ID,
|
||||
Title: anime.Title,
|
||||
Image: anime.Image,
|
||||
Watching: anime.Watching,
|
||||
})
|
||||
}
|
||||
|
||||
saveErr := arn.SetObject("Cache", "airingAnime", &AiringAnimeCacheSmall{
|
||||
Anime: animeListSmall,
|
||||
})
|
||||
|
||||
if saveErr != nil {
|
||||
|
9
main.go
9
main.go
@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"runtime"
|
||||
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/notify.moe/components"
|
||||
@ -23,6 +24,7 @@ var app = aero.New()
|
||||
|
||||
func main() {
|
||||
app.SetStyle(components.BundledCSS)
|
||||
app.Config.GZipCache = false
|
||||
|
||||
// user, _ := arn.GetUserByNick("Akyoto")
|
||||
// user.CoverImage.URL = "https://www.pixelstalk.net/wp-content/uploads/2016/10/Hanyijie-sky-scenery-ship-anime-art-1920x1080.jpg"
|
||||
@ -42,7 +44,12 @@ func main() {
|
||||
})
|
||||
|
||||
app.Get("/hello", func(ctx *aero.Context) string {
|
||||
return "Hello World"
|
||||
return ctx.Text("Hello World")
|
||||
})
|
||||
|
||||
app.Get("/gc", func(ctx *aero.Context) string {
|
||||
runtime.GC()
|
||||
return ctx.Text("Ran garbage collector")
|
||||
})
|
||||
|
||||
app.Layout = func(ctx *aero.Context, content string) string {
|
||||
|
@ -9,7 +9,12 @@ import (
|
||||
|
||||
// Get ...
|
||||
func Get(ctx *aero.Context) string {
|
||||
var airingAnimeCache jobs.AiringAnimeCache
|
||||
arn.GetObject("Cache", "airingAnime", &airingAnimeCache)
|
||||
airingAnimeCache := new(jobs.AiringAnimeCache)
|
||||
err := arn.GetObject("Cache", "airingAnime", airingAnimeCache)
|
||||
|
||||
if err != nil {
|
||||
return ctx.Error(500, "Couldn't fetch airing anime", err)
|
||||
}
|
||||
|
||||
return ctx.HTML(components.Airing(airingAnimeCache.Anime))
|
||||
}
|
||||
|
@ -36,6 +36,14 @@ component Anime(anime *arn.Anime)
|
||||
//- each watcher in friendsWatching
|
||||
//- +avatar(watcher)
|
||||
|
||||
if len(anime.Relations) > 0
|
||||
h3.anime-header Relations
|
||||
.relations
|
||||
each relation in anime.Relations
|
||||
a.relation.ajax(href="/anime/" + toString(relation.ID), title=relation.Anime().Title.Romaji)
|
||||
img.anime-image.relation-image(src=relation.Anime().Image, alt=relation.Anime().Title.Romaji)
|
||||
span= arn.Capitalize(relation.Type)
|
||||
|
||||
if len(anime.Genres) > 0
|
||||
h3.anime-header Genres
|
||||
.light-button-group
|
||||
|
@ -117,16 +117,32 @@
|
||||
display flex
|
||||
flex-flow row wrap
|
||||
justify-content flex-start
|
||||
font-size 0.9em
|
||||
font-size 0.9rem
|
||||
|
||||
.light-button
|
||||
display inline-block
|
||||
padding 0.5em 1em
|
||||
padding 0.5rem 1rem
|
||||
border-radius 3px
|
||||
&:hover
|
||||
color white !important
|
||||
background-color linkHoverColor
|
||||
|
||||
.relations
|
||||
float left
|
||||
display flex
|
||||
flex-flow row wrap
|
||||
|
||||
.relation
|
||||
display flex
|
||||
flex-flow column
|
||||
font-size 0.9rem
|
||||
align-items center
|
||||
padding 0.5rem
|
||||
|
||||
.relation-image
|
||||
width 100px
|
||||
height 141px
|
||||
|
||||
.entry-error
|
||||
color red !important
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user