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
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/aerojs/aero"
|
"github.com/aerojs/aero"
|
||||||
"github.com/animenotifier/arn"
|
"github.com/animenotifier/arn"
|
||||||
@ -34,6 +36,21 @@ func main() {
|
|||||||
ctx.HTML(Render.Dashboard())
|
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) {
|
app.Get("/anime/:id", func(ctx *aero.Context) {
|
||||||
id, _ := strconv.Atoi(ctx.Params.ByName("id"))
|
id, _ := strconv.Atoi(ctx.Params.ByName("id"))
|
||||||
anime, err := arn.GetAnime(id)
|
anime, err := arn.GetAnime(id)
|
||||||
@ -82,18 +99,12 @@ func main() {
|
|||||||
ctx.JSON(user)
|
ctx.JSON(user)
|
||||||
})
|
})
|
||||||
|
|
||||||
app.Get("/all", func(ctx *aero.Context) {
|
app.Get("/genres", func(ctx *aero.Context) {
|
||||||
var buffer bytes.Buffer
|
ctx.HTML(Render.Layout(Render.GenreOverview(), css))
|
||||||
|
})
|
||||||
|
|
||||||
results := make(chan *arn.Anime)
|
app.Get("/_/genres", func(ctx *aero.Context) {
|
||||||
arn.Scan("Anime", results)
|
ctx.HTML(Render.GenreOverview())
|
||||||
|
|
||||||
for anime := range results {
|
|
||||||
buffer.WriteString(anime.Title.Romaji)
|
|
||||||
buffer.WriteByte('\n')
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx.Text(buffer.String())
|
|
||||||
})
|
})
|
||||||
|
|
||||||
app.Get("/scripts.js", func(ctx *aero.Context) {
|
app.Get("/scripts.js", func(ctx *aero.Context) {
|
||||||
|
@ -42,6 +42,7 @@ component Anime(anime *arn.Anime)
|
|||||||
each genre in anime.Genres
|
each genre in anime.Genres
|
||||||
if genre != ""
|
if genre != ""
|
||||||
a.light-button.ajax(href="/anime/genres/" + arn.FixGenre(genre))
|
a.light-button.ajax(href="/anime/genres/" + arn.FixGenre(genre))
|
||||||
|
i(class="fa fa-" + GenreIcons[genre] + " fa-fw")
|
||||||
span= genre
|
span= genre
|
||||||
|
|
||||||
if len(anime.Studios) > 0
|
if len(anime.Studios) > 0
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
component Dashboard
|
component Dashboard
|
||||||
section
|
section
|
||||||
header
|
header
|
||||||
h1 ARN 4.0
|
h2 ARN 4.0
|
||||||
p The next version of notify.moe is currently being built here!
|
p Shht! The next version of notify.moe is currently being built here.
|
||||||
hr
|
hr
|
||||||
p Some test links:
|
|
||||||
ul
|
ul
|
||||||
li
|
li
|
||||||
a.ajax(href="/anime/21499") Sousei no Onmyouji
|
a.ajax(href="/anime/21499") Sousei no Onmyouji
|
||||||
@ -12,3 +11,7 @@ component Dashboard
|
|||||||
a.ajax(href="/anime/1000001") RWBY
|
a.ajax(href="/anime/1000001") RWBY
|
||||||
li
|
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…
x
Reference in New Issue
Block a user