Updated to latest ARN API

This commit is contained in:
Eduard Urbach 2017-06-27 12:39:41 +02:00
parent 93e7ad01d5
commit 04373033cc
10 changed files with 23 additions and 14 deletions

View File

@ -14,7 +14,7 @@ const maxPopularAnime = 10
func main() { func main() {
color.Yellow("Caching popular anime") color.Yellow("Caching popular anime")
animeChan, err := arn.AllAnime() animeList, err := arn.AllAnime()
if err != nil { if err != nil {
color.Red("Failed fetching anime channel") color.Red("Failed fetching anime channel")
@ -22,12 +22,6 @@ func main() {
return return
} }
var animeList []*arn.Anime
for anime := range animeChan {
animeList = append(animeList, anime)
}
sort.Slice(animeList, func(i, j int) bool { sort.Slice(animeList, func(i, j int) bool {
return animeList[i].Rating.Overall > animeList[j].Rating.Overall return animeList[i].Rating.Overall > animeList[j].Rating.Overall
}) })

View File

@ -21,7 +21,7 @@ func updateAnimeIndex() {
animeSearchIndex := arn.NewSearchIndex() animeSearchIndex := arn.NewSearchIndex()
// Anime // Anime
animeStream, err := arn.AllAnime() animeStream, err := arn.StreamAnime()
if err != nil { if err != nil {
panic(err) panic(err)

View File

@ -15,7 +15,7 @@ func main() {
color.Yellow("Syncing Anime") color.Yellow("Syncing Anime")
// Get a stream of all anime // Get a stream of all anime
allAnime := kitsu.AllAnime() allAnime := kitsu.StreamAnime()
// Iterate over the stream // Iterate over the stream
for anime := range allAnime { for anime := range allAnime {

View File

@ -18,6 +18,7 @@ import (
"github.com/animenotifier/notify.moe/pages/forum" "github.com/animenotifier/notify.moe/pages/forum"
"github.com/animenotifier/notify.moe/pages/forums" "github.com/animenotifier/notify.moe/pages/forums"
"github.com/animenotifier/notify.moe/pages/login" "github.com/animenotifier/notify.moe/pages/login"
"github.com/animenotifier/notify.moe/pages/music"
"github.com/animenotifier/notify.moe/pages/newthread" "github.com/animenotifier/notify.moe/pages/newthread"
"github.com/animenotifier/notify.moe/pages/popularanime" "github.com/animenotifier/notify.moe/pages/popularanime"
"github.com/animenotifier/notify.moe/pages/posts" "github.com/animenotifier/notify.moe/pages/posts"
@ -67,7 +68,9 @@ func configure(app *aero.Application) *aero.Application {
app.Ajax("/user/:nick/animelist/:id", animelistitem.Get) app.Ajax("/user/:nick/animelist/:id", animelistitem.Get)
app.Ajax("/new/thread", newthread.Get) app.Ajax("/new/thread", newthread.Get)
app.Ajax("/settings", settings.Get) app.Ajax("/settings", settings.Get)
app.Ajax("/music", music.Get)
app.Ajax("/admin", admin.Get) app.Ajax("/admin", admin.Get)
app.Ajax("/search", search.Get)
app.Ajax("/search/:term", search.Get) app.Ajax("/search/:term", search.Get)
app.Ajax("/users", users.Get) app.Ajax("/users", users.Get)
app.Ajax("/login", login.Get) app.Ajax("/login", login.Get)

View File

@ -26,7 +26,7 @@ component LoggedInMenu(user *arn.User)
NavigationButton("Dash", "/", "dashboard") NavigationButton("Dash", "/", "dashboard")
NavigationButton("Profile", "/+", "user") NavigationButton("Profile", "/+", "user")
NavigationButton("Forum", "/forum", "comment") NavigationButton("Forum", "/forum", "comment")
NavigationButton("Anime", "/anime", "television") NavigationButton("Music", "/music", "music")
FuzzySearch FuzzySearch

View File

@ -33,9 +33,13 @@ func dashboard(ctx *aero.Context) string {
user := utils.GetUser(ctx) user := utils.GetUser(ctx)
flow.Parallel(func() { flow.Parallel(func() {
posts, err = arn.AllPostsSlice() posts, err = arn.AllPosts()
arn.SortPostsLatestFirst(posts) arn.SortPostsLatestFirst(posts)
posts = arn.FilterPostsWithUniqueThreads(posts, maxPosts) posts = arn.FilterPostsWithUniqueThreads(posts, maxPosts)
}, func() {
// threads, err = arn.AllThreadsSlice()
// arn.SortPostsLatestFirst(posts)
// posts = arn.FilterPostsWithUniqueThreads(posts, maxPosts)
}, func() { }, func() {
userList, err = arn.DB.GetMany("User", user.Following) userList, err = arn.DB.GetMany("User", user.Following)
followingList = userList.([]*arn.User) followingList = userList.([]*arn.User)

View File

@ -15,7 +15,7 @@ component Dashboard(posts []*arn.Post, following []*arn.User)
h3.widget-title Forums h3.widget-title Forums
each post in posts each post in posts
a.widget-element.ajax(href=post.Thread().Link() + "#" + post.ID) a.widget-element.ajax(href=post.Thread().Link())
.widget-element-text .widget-element-text
Icon(arn.GetForumIcon(post.Thread().Tags[0])) Icon(arn.GetForumIcon(post.Thread().Tags[0]))
span= post.Thread().Title span= post.Thread().Title

8
pages/music/music.go Normal file
View File

@ -0,0 +1,8 @@
package music
import "github.com/aerogo/aero"
// Get renders the music page.
func Get(ctx *aero.Context) string {
return ctx.HTML("Coming soon.")
}

View File

@ -7,7 +7,7 @@ import (
func main() { func main() {
// Get a stream of all posts // Get a stream of all posts
allPosts, err := arn.AllPosts() allPosts, err := arn.StreamPosts()
arn.PanicOnError(err) arn.PanicOnError(err)
// Iterate over the stream // Iterate over the stream

View File

@ -6,7 +6,7 @@ import (
func main() { func main() {
// Get a stream of all posts // Get a stream of all posts
allPosts, err := arn.AllPosts() allPosts, err := arn.StreamPosts()
arn.PanicOnError(err) arn.PanicOnError(err)
threadToPosts := make(map[string][]string) threadToPosts := make(map[string][]string)