New genre overview
This commit is contained in:
parent
95ddd6774b
commit
e17f377dc6
23
api.go
23
api.go
@ -1,27 +1,24 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/arn"
|
||||
)
|
||||
|
||||
func init() {
|
||||
app.Get("/all/anime", func(ctx *aero.Context) string {
|
||||
var titles []string
|
||||
// app.Get("/all/anime", func(ctx *aero.Context) string {
|
||||
// var titles []string
|
||||
|
||||
results := make(chan *arn.Anime)
|
||||
arn.Scan("Anime", results)
|
||||
// results := make(chan *arn.Anime)
|
||||
// arn.Scan("Anime", results)
|
||||
|
||||
for anime := range results {
|
||||
titles = append(titles, anime.Title.Romaji)
|
||||
}
|
||||
sort.Strings(titles)
|
||||
// for anime := range results {
|
||||
// titles = append(titles, anime.Title.Romaji)
|
||||
// }
|
||||
// sort.Strings(titles)
|
||||
|
||||
return ctx.Text(toString(len(titles)) + "\n\n" + strings.Join(titles, "\n"))
|
||||
})
|
||||
// return ctx.Text(toString(len(titles)) + "\n\n" + strings.Join(titles, "\n"))
|
||||
// })
|
||||
|
||||
app.Get("/api/anime/:id", func(ctx *aero.Context) string {
|
||||
id, _ := ctx.GetInt("id")
|
||||
|
@ -1,5 +1,5 @@
|
||||
#!/bin/bash
|
||||
pack
|
||||
go build
|
||||
#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 &'
|
||||
ssh eduard@arn 'cd beta; killall notify.moe; rm notify.moe; mv notify.moe.new notify.moe; ./notify.moe &'
|
||||
|
@ -23,8 +23,9 @@ component Content(content string)
|
||||
|
||||
component Navigation
|
||||
nav#navigation
|
||||
NavigationButton("Dash", "/", "dashboard")
|
||||
NavigationButton("Dash", "/", "inbox")
|
||||
NavigationButton("Forum", "/forum", "comment")
|
||||
NavigationButton("Genres", "/genres", "tags")
|
||||
|
||||
component NavigationButton(name string, target string, icon string)
|
||||
a.navigation-link.navigation-link-left.ajax(href=target)
|
||||
|
14
main.go
14
main.go
@ -5,6 +5,12 @@ import (
|
||||
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/notify.moe/components"
|
||||
"github.com/animenotifier/notify.moe/pages/anime"
|
||||
"github.com/animenotifier/notify.moe/pages/dashboard"
|
||||
"github.com/animenotifier/notify.moe/pages/forum"
|
||||
"github.com/animenotifier/notify.moe/pages/genre"
|
||||
"github.com/animenotifier/notify.moe/pages/genres"
|
||||
"github.com/animenotifier/notify.moe/pages/threads"
|
||||
)
|
||||
|
||||
var app = aero.New()
|
||||
@ -28,5 +34,13 @@ func main() {
|
||||
return components.Layout(content)
|
||||
}
|
||||
|
||||
app.Ajax("/", dashboard.Get)
|
||||
app.Ajax("/anime/:id", anime.Get)
|
||||
app.Ajax("/genres", genres.Get)
|
||||
app.Ajax("/genres/:name", genre.Get)
|
||||
app.Ajax("/forum", forum.Get)
|
||||
app.Ajax("/forum/:tag", forum.Get)
|
||||
app.Ajax("/threads/:id", threads.Get)
|
||||
|
||||
app.Run()
|
||||
}
|
||||
|
19
pages/anime/anime.go
Normal file
19
pages/anime/anime.go
Normal file
@ -0,0 +1,19 @@
|
||||
package anime
|
||||
|
||||
import (
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/arn"
|
||||
"github.com/animenotifier/notify.moe/components"
|
||||
)
|
||||
|
||||
// Get ...
|
||||
func Get(ctx *aero.Context) string {
|
||||
id, _ := ctx.GetInt("id")
|
||||
anime, err := arn.GetAnime(id)
|
||||
|
||||
if err != nil {
|
||||
return ctx.Text("Anime not found")
|
||||
}
|
||||
|
||||
return ctx.HTML(components.Anime(anime))
|
||||
}
|
14
pages/beta/beta.pixy
Normal file
14
pages/beta/beta.pixy
Normal file
@ -0,0 +1,14 @@
|
||||
component Beta
|
||||
section
|
||||
header
|
||||
h2 The future
|
||||
|
||||
p Shht! The next version of notify.moe is currently being built here.
|
||||
hr
|
||||
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)
|
11
pages/dashboard/dashboard.go
Normal file
11
pages/dashboard/dashboard.go
Normal file
@ -0,0 +1,11 @@
|
||||
package dashboard
|
||||
|
||||
import (
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/notify.moe/components"
|
||||
)
|
||||
|
||||
// Get ...
|
||||
func Get(ctx *aero.Context) string {
|
||||
return ctx.HTML(components.Dashboard())
|
||||
}
|
@ -1,17 +1,4 @@
|
||||
component Dashboard
|
||||
section
|
||||
header
|
||||
h2 ARN 4.0
|
||||
p Shht! The next version of notify.moe is currently being built here.
|
||||
hr
|
||||
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)
|
||||
li
|
||||
a.ajax(href="/genres") Genre Overview
|
||||
li
|
||||
a(href="/all/anime") All anime titles on notify.moe (text file)
|
||||
h2 Dash
|
29
pages/forum/forum.go
Normal file
29
pages/forum/forum.go
Normal file
@ -0,0 +1,29 @@
|
||||
package forum
|
||||
|
||||
import (
|
||||
"sort"
|
||||
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/arn"
|
||||
"github.com/animenotifier/notify.moe/components"
|
||||
)
|
||||
|
||||
const threadsPerPage = 20
|
||||
|
||||
// Get ...
|
||||
func Get(ctx *aero.Context) string {
|
||||
tag := ctx.Get("tag")
|
||||
threads, _ := arn.GetThreadsByTag(tag)
|
||||
|
||||
sort.Sort(threads)
|
||||
|
||||
if len(threads) > threadsPerPage {
|
||||
threads = threads[:threadsPerPage]
|
||||
}
|
||||
|
||||
for _, thread := range threads {
|
||||
thread.Init()
|
||||
}
|
||||
|
||||
return ctx.HTML(components.Forum(threads))
|
||||
}
|
21
pages/genre/genre.go
Normal file
21
pages/genre/genre.go
Normal file
@ -0,0 +1,21 @@
|
||||
package genre
|
||||
|
||||
import (
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/arn"
|
||||
"github.com/animenotifier/notify.moe/components"
|
||||
)
|
||||
|
||||
// Get ...
|
||||
func Get(ctx *aero.Context) string {
|
||||
genreName := ctx.Get("name")
|
||||
genreInfo := new(arn.Genre)
|
||||
|
||||
err := arn.GetObject("Genres", genreName, genreInfo)
|
||||
|
||||
if err != nil {
|
||||
return err.Error()
|
||||
}
|
||||
|
||||
return ctx.HTML(components.Genre(genreInfo.Genre, genreInfo.AnimeList))
|
||||
}
|
6
pages/genre/genre.pixy
Normal file
6
pages/genre/genre.pixy
Normal file
@ -0,0 +1,6 @@
|
||||
component Genre(genre string, animeList []*arn.Anime)
|
||||
h2.genre-header= arn.Capitalize(genre)
|
||||
.grid
|
||||
each anime in animeList
|
||||
a.grid-cell.ajax(href="/anime/" + toString(anime.ID))
|
||||
img.anime-image.grid-cell-content.grid-cell-image(src=anime.Image, alt=anime.Title.Romaji, title=anime.Title.Romaji + " (" + toString(anime.Watching) + ")")
|
28
pages/genre/genre.styl
Normal file
28
pages/genre/genre.styl
Normal file
@ -0,0 +1,28 @@
|
||||
.grid
|
||||
display flex
|
||||
flex-flow row wrap
|
||||
float none !important
|
||||
justify-content center
|
||||
|
||||
.grid-cell
|
||||
margin 0.5em
|
||||
flex-grow 0
|
||||
flex-shrink 0
|
||||
|
||||
.grid-cell-content
|
||||
width 16vw
|
||||
height 9vw
|
||||
min-width 90px
|
||||
min-height 127px
|
||||
max-width 200px
|
||||
max-height 282px
|
||||
|
||||
.grid-cell-image
|
||||
object-fit cover
|
||||
|
||||
.grid-cell-text
|
||||
display flex
|
||||
flex-flow column
|
||||
align-items center
|
||||
justify-content center
|
||||
padding 0.75em
|
11
pages/genres/genres.go
Normal file
11
pages/genres/genres.go
Normal file
@ -0,0 +1,11 @@
|
||||
package genres
|
||||
|
||||
import (
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/notify.moe/components"
|
||||
)
|
||||
|
||||
// Get ...
|
||||
func Get(ctx *aero.Context) string {
|
||||
return ctx.HTML(components.Genres())
|
||||
}
|
@ -1,15 +1,9 @@
|
||||
component GenreOverview
|
||||
component Genres
|
||||
h2.genre-header Genres
|
||||
|
||||
div
|
||||
.grid
|
||||
each genre in arn.Genres
|
||||
a.light-button.ajax(href="/genres/" + arn.FixGenre(genre))
|
||||
Icon(arn.GetGenreIcon(genre))
|
||||
span= genre
|
||||
|
||||
component AnimeInGenre(genre string, animeList []*arn.Anime)
|
||||
h2.genre-header= arn.Capitalize(genre)
|
||||
.genre-anime-list
|
||||
each anime in animeList
|
||||
a.genre-anime-link.ajax(href="/anime/" + toString(anime.ID))
|
||||
img.anime-image.genre-anime-image(src=anime.Image, alt=anime.Title.Romaji, title=anime.Title.Romaji + " (" + toString(anime.Watching) + ")")
|
||||
a.grid-cell.light-button.ajax(href="/genres/" + arn.FixGenre(genre))
|
||||
.genre.grid-cell-content.grid-cell-text
|
||||
Icon(arn.GetGenreIcon(genre))
|
||||
span= genre
|
@ -1,22 +1,9 @@
|
||||
.genre-header
|
||||
text-align center
|
||||
|
||||
.genre-anime-list
|
||||
display flex
|
||||
flex-flow row wrap
|
||||
float none !important
|
||||
justify-content center
|
||||
|
||||
.genre-anime-image
|
||||
width 16vw
|
||||
height 9vw
|
||||
min-width 90px
|
||||
min-height 127px
|
||||
max-width 200px
|
||||
max-height 282px
|
||||
object-fit cover
|
||||
|
||||
.genre-anime-link
|
||||
margin 0.5em
|
||||
flex-grow 0
|
||||
flex-shrink 0
|
||||
.genre
|
||||
font-size 1rem
|
||||
.fa
|
||||
font-size 2rem
|
||||
margin-right 0
|
||||
margin-bottom 1rem
|
33
pages/threads/threads.go
Normal file
33
pages/threads/threads.go
Normal file
@ -0,0 +1,33 @@
|
||||
package threads
|
||||
|
||||
import (
|
||||
"sort"
|
||||
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/arn"
|
||||
"github.com/animenotifier/notify.moe/components"
|
||||
)
|
||||
|
||||
// Get ...
|
||||
func Get(ctx *aero.Context) string {
|
||||
id := ctx.Get("id")
|
||||
thread, err := arn.GetThread(id)
|
||||
|
||||
if err != nil {
|
||||
return ctx.Text("Thread not found")
|
||||
}
|
||||
|
||||
thread.Author, _ = arn.GetUser(thread.AuthorID)
|
||||
|
||||
replies, filterErr := arn.FilterPosts(func(post *arn.Post) bool {
|
||||
return post.ThreadID == thread.ID
|
||||
})
|
||||
|
||||
sort.Sort(replies)
|
||||
|
||||
if filterErr != nil {
|
||||
return ctx.Text("Error fetching thread replies")
|
||||
}
|
||||
|
||||
return ctx.HTML(components.Thread(thread, replies))
|
||||
}
|
@ -1,16 +1,15 @@
|
||||
component Thread(thread *arn.Thread)
|
||||
component Thread(thread *arn.Thread, posts []*arn.Post)
|
||||
.thread
|
||||
h2.thread-title= thread.Title
|
||||
|
||||
.posts
|
||||
Post(thread.ToPostable(), nil, "Threads", "Thread", thread.AuthorID)
|
||||
//- +renderMessage(thread, user, "Threads", thread.author.ID)
|
||||
Post(thread.ToPostable(), nil, "Threads", "Thread", thread.Author.ID)
|
||||
|
||||
//- each post in posts
|
||||
//- +renderMessage(post, user, "Posts", thread.author.ID)
|
||||
each post in posts
|
||||
Post(post.ToPostable(), nil, "Posts", "Post", thread.Author.ID)
|
||||
|
||||
component Post(post arn.Postable, viewUser *arn.User, postType string, postTypeSingular string, highlightAuthorID string)
|
||||
.post(class=[]string{"", "special-post"}[post.Author().ID == highlightAuthorID])
|
||||
.post(data-highlight=post.Author().ID == highlightAuthorID)
|
||||
.post-author
|
||||
Avatar(post.Author())
|
||||
|
||||
|
78
router.go
78
router.go
@ -1,78 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"sort"
|
||||
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/arn"
|
||||
"github.com/animenotifier/notify.moe/components"
|
||||
)
|
||||
|
||||
func init() {
|
||||
app.Ajax("/", func(ctx *aero.Context) string {
|
||||
return ctx.HTML(components.Dashboard())
|
||||
})
|
||||
|
||||
app.Ajax("/anime/:id", func(ctx *aero.Context) string {
|
||||
id, _ := ctx.GetInt("id")
|
||||
anime, err := arn.GetAnime(id)
|
||||
|
||||
if err != nil {
|
||||
return ctx.Text("Anime not found")
|
||||
}
|
||||
|
||||
return ctx.HTML(components.Anime(anime))
|
||||
})
|
||||
|
||||
app.Ajax("/genres", func(ctx *aero.Context) string {
|
||||
return ctx.HTML(components.GenreOverview())
|
||||
})
|
||||
|
||||
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()
|
||||
}
|
||||
|
||||
return ctx.HTML(components.AnimeInGenre(genreInfo.Genre, genreInfo.AnimeList))
|
||||
})
|
||||
|
||||
const threadsPerPage = 12
|
||||
|
||||
forumHandler := func(ctx *aero.Context) string {
|
||||
tag := ctx.Get("tag")
|
||||
threads, _ := arn.GetThreadsByTag(tag)
|
||||
|
||||
sort.Sort(threads)
|
||||
|
||||
if len(threads) > threadsPerPage {
|
||||
threads = threads[:threadsPerPage]
|
||||
}
|
||||
|
||||
for _, thread := range threads {
|
||||
thread.Author, _ = arn.GetUser(thread.AuthorID)
|
||||
}
|
||||
|
||||
return ctx.HTML(components.Forum(threads))
|
||||
}
|
||||
|
||||
app.Ajax("/forum", forumHandler)
|
||||
app.Ajax("/forum/:tag", forumHandler)
|
||||
|
||||
app.Ajax("/threads/:id", func(ctx *aero.Context) string {
|
||||
id := ctx.Get("id")
|
||||
thread, err := arn.GetThread(id)
|
||||
|
||||
if err != nil {
|
||||
return ctx.Text("Thread not found")
|
||||
}
|
||||
|
||||
thread.Author, _ = arn.GetUser(thread.AuthorID)
|
||||
|
||||
return ctx.HTML(components.Thread(thread))
|
||||
})
|
||||
}
|
@ -102,7 +102,7 @@
|
||||
line-height 2em
|
||||
font-weight normal
|
||||
|
||||
.special-post
|
||||
.post[data-highlight="true"]
|
||||
.post-content
|
||||
border 2px solid alpha(mainColor, 70%)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user