Minor changes
This commit is contained in:
parent
fa848a63ea
commit
eacf0e2399
49
genres.go
Normal file
49
genres.go
Normal file
@ -0,0 +1,49 @@
|
||||
package main
|
||||
|
||||
import "sort"
|
||||
|
||||
// Genres ...
|
||||
var Genres []string
|
||||
|
||||
// GenreIcons ...
|
||||
var GenreIcons = map[string]string{
|
||||
"Action": "bomb",
|
||||
"Adventure": "diamond",
|
||||
"Cars": "car",
|
||||
"Comedy": "smile-o",
|
||||
"Drama": "heartbeat",
|
||||
"Ecchi": "heart-o",
|
||||
"Fantasy": "tree",
|
||||
"Game": "gamepad",
|
||||
"Harem": "group",
|
||||
"Hentai": "venus-mars",
|
||||
"Historical": "history",
|
||||
"Horror": "frown-o",
|
||||
"Kids": "child",
|
||||
"Martial Arts": "hand-rock-o",
|
||||
"Magic": "magic",
|
||||
"Mecha": "reddit-alien",
|
||||
"Military": "fighter-jet",
|
||||
"Music": "music",
|
||||
"Mystery": "question",
|
||||
"Psychological": "lightbulb-o",
|
||||
"Romance": "heart",
|
||||
"Sci-Fi": "space-shuttle",
|
||||
"School": "graduation-cap",
|
||||
"Seinen": "male",
|
||||
"Shounen": "male",
|
||||
"Shoujo": "female",
|
||||
"Slice of Life": "hand-peace-o",
|
||||
"Sports": "soccer-ball-o",
|
||||
"Supernatural": "magic",
|
||||
"Super Power": "flash",
|
||||
"Thriller": "hourglass-end",
|
||||
"Vampire": "eye",
|
||||
}
|
||||
|
||||
func init() {
|
||||
for k := range GenreIcons {
|
||||
Genres = append(Genres, k)
|
||||
}
|
||||
sort.Strings(Genres)
|
||||
}
|
35
main.go
35
main.go
@ -1,10 +1,12 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/aerojs/aero"
|
||||
"github.com/animenotifier/arn"
|
||||
@ -34,6 +36,21 @@ func main() {
|
||||
ctx.HTML(Render.Dashboard())
|
||||
})
|
||||
|
||||
app.Get("/all/anime", func(ctx *aero.Context) {
|
||||
start := time.Now()
|
||||
var titles []string
|
||||
|
||||
results := make(chan *arn.Anime)
|
||||
arn.Scan("Anime", results)
|
||||
|
||||
for anime := range results {
|
||||
titles = append(titles, anime.Title.Romaji)
|
||||
}
|
||||
sort.Strings(titles)
|
||||
|
||||
ctx.Text(s(len(titles)) + " anime fetched in " + s(time.Since(start)) + "\n\n" + strings.Join(titles, "\n"))
|
||||
})
|
||||
|
||||
app.Get("/anime/:id", func(ctx *aero.Context) {
|
||||
id, _ := strconv.Atoi(ctx.Params.ByName("id"))
|
||||
anime, err := arn.GetAnime(id)
|
||||
@ -82,18 +99,12 @@ func main() {
|
||||
ctx.JSON(user)
|
||||
})
|
||||
|
||||
app.Get("/all", func(ctx *aero.Context) {
|
||||
var buffer bytes.Buffer
|
||||
app.Get("/genres", func(ctx *aero.Context) {
|
||||
ctx.HTML(Render.Layout(Render.GenreOverview(), css))
|
||||
})
|
||||
|
||||
results := make(chan *arn.Anime)
|
||||
arn.Scan("Anime", results)
|
||||
|
||||
for anime := range results {
|
||||
buffer.WriteString(anime.Title.Romaji)
|
||||
buffer.WriteByte('\n')
|
||||
}
|
||||
|
||||
ctx.Text(buffer.String())
|
||||
app.Get("/_/genres", func(ctx *aero.Context) {
|
||||
ctx.HTML(Render.GenreOverview())
|
||||
})
|
||||
|
||||
app.Get("/scripts.js", func(ctx *aero.Context) {
|
||||
|
@ -42,6 +42,7 @@ component Anime(anime *arn.Anime)
|
||||
each genre in anime.Genres
|
||||
if genre != ""
|
||||
a.light-button.ajax(href="/anime/genres/" + arn.FixGenre(genre))
|
||||
i(class="fa fa-" + GenreIcons[genre] + " fa-fw")
|
||||
span= genre
|
||||
|
||||
if len(anime.Studios) > 0
|
||||
|
@ -1,14 +1,17 @@
|
||||
component Dashboard
|
||||
section
|
||||
header
|
||||
h1 ARN 4.0
|
||||
p The next version of notify.moe is currently being built here!
|
||||
h2 ARN 4.0
|
||||
p Shht! The next version of notify.moe is currently being built here.
|
||||
hr
|
||||
p Some test links:
|
||||
ul
|
||||
li
|
||||
a.ajax(href="/anime/21499") Sousei no Onmyouji
|
||||
li
|
||||
a.ajax(href="/anime/1000001") RWBY
|
||||
li
|
||||
a(href="/api/anime/1000001") RWBY (JSON API)
|
||||
a(href="/api/anime/1000001") RWBY (JSON API)
|
||||
li
|
||||
a.ajax(href="/genres") Genre Overview
|
||||
li
|
||||
a(href="/all/anime") All anime titles on notify.moe (text file)
|
13
pages/genres/genres.pixy
Normal file
13
pages/genres/genres.pixy
Normal file
@ -0,0 +1,13 @@
|
||||
component GenreOverview
|
||||
section
|
||||
header
|
||||
h2 Genres
|
||||
|
||||
each genre in Genres
|
||||
p
|
||||
a(href="/genres/" + arn.FixGenre(genre))
|
||||
Icon(GenreIcons[genre])
|
||||
span= genre
|
||||
|
||||
component Icon(name string)
|
||||
i(class="fa fa-fw fa-" + name)
|
Loading…
Reference in New Issue
Block a user