44 lines
909 B
Go
Raw Normal View History

2016-11-09 11:32:19 +00:00
package main
import (
"strconv"
2016-11-09 13:11:49 +00:00
"github.com/aerogo/aero"
2016-11-09 11:32:19 +00:00
"github.com/animenotifier/arn"
2016-11-12 16:40:16 +00:00
"github.com/animenotifier/notify.moe/components"
2016-11-09 11:32:19 +00:00
)
func init() {
app.Ajax("/", func(ctx *aero.Context) string {
2016-11-12 16:40:16 +00:00
return ctx.HTML(components.Dashboard())
2016-11-09 11:32:19 +00:00
})
app.Ajax("/anime/:id", func(ctx *aero.Context) string {
id, _ := strconv.Atoi(ctx.Get("id"))
anime, err := arn.GetAnime(id)
if err != nil {
return ctx.Text("Anime not found")
}
2016-11-12 16:40:16 +00:00
return ctx.HTML(components.Anime(anime))
2016-11-09 11:32:19 +00:00
})
app.Ajax("/genres", func(ctx *aero.Context) string {
2016-11-12 16:40:16 +00:00
return ctx.HTML(components.GenreOverview())
2016-11-09 11:32:19 +00:00
})
app.Ajax("/genres/:name", func(ctx *aero.Context) string {
genreName := ctx.Get("name")
genreInfo := new(arn.Genre)
err := arn.GetObject("Genres", genreName, genreInfo)
if err != nil {
return err.Error()
}
2016-11-12 16:40:16 +00:00
return ctx.HTML(components.AnimeInGenre(genreInfo.Genre, genreInfo.AnimeList))
2016-11-09 11:32:19 +00:00
})
}