Minor updates

This commit is contained in:
2017-06-10 02:19:31 +02:00
parent 36137f208f
commit c0744d8ba5
8 changed files with 194 additions and 106 deletions

View File

@ -9,7 +9,7 @@ import (
// Get ...
func Get(ctx *aero.Context) string {
var cache arn.ListOfIDs
err := arn.GetObject("Cache", "airing anime", &cache)
err := arn.DB.GetObject("Cache", "airing anime", &cache)
airing, err := arn.GetAiringAnimeCached()

View File

@ -13,21 +13,28 @@ const maxPosts = 5
func Get(ctx *aero.Context) string {
nick := ctx.Get("nick")
viewUser, err := arn.GetUserByNick(nick)
user := utils.GetUser(ctx)
if err != nil {
return ctx.Error(404, "User not found", err)
}
threads := viewUser.Threads()
var user *arn.User
var threads []*arn.Thread
var animeList *arn.AnimeList
arn.SortThreadsByDate(threads)
aero.Async(func() {
user = utils.GetUser(ctx)
}, func() {
animeList = viewUser.AnimeList()
}, func() {
threads = viewUser.Threads()
if len(threads) > maxPosts {
threads = threads[:maxPosts]
}
arn.SortThreadsByDate(threads)
animeList := viewUser.AnimeList()
if len(threads) > maxPosts {
threads = threads[:maxPosts]
}
})
return ctx.HTML(components.Profile(viewUser, user, animeList, threads))
}

View File

@ -1,11 +1,22 @@
package users
import (
"net/http"
"github.com/aerogo/aero"
"github.com/animenotifier/arn"
"github.com/animenotifier/notify.moe/components"
)
// Get ...
func Get(ctx *aero.Context) string {
return ctx.HTML(components.Users())
users, err := arn.FilterUsers(func(user *arn.User) bool {
return user.IsActive()
})
if err != nil {
return ctx.Error(http.StatusInternalServerError, "Could not fetch user data", err)
}
return ctx.HTML(components.Users(users))
}

View File

@ -1,2 +1,5 @@
component Users
h2 Users
component Users(users []*arn.User)
h2.page-title Users
each user in users
p= user.Nick