41 lines
918 B
Go
Raw Normal View History

2016-11-19 14:54:31 +00:00
package dashboard
import (
2017-06-07 19:12:59 +00:00
"net/http"
2016-11-19 14:54:31 +00:00
"github.com/aerogo/aero"
2017-06-07 19:12:59 +00:00
"github.com/animenotifier/arn"
2016-11-19 14:54:31 +00:00
)
2016-12-06 03:36:31 +00:00
const maxPosts = 5
2016-11-19 14:54:31 +00:00
// Get ...
func Get(ctx *aero.Context) string {
2017-06-02 14:17:58 +00:00
// posts, err := arn.GetPosts()
2017-06-02 14:17:58 +00:00
// if err != nil {
// return ctx.Error(500, "Error fetching posts", err)
// }
2017-06-02 14:17:58 +00:00
// arn.SortPostsLatestFirst(posts)
2017-06-02 14:17:58 +00:00
// if len(posts) > maxPosts {
// posts = posts[:maxPosts]
// }
2017-06-02 14:17:58 +00:00
// return ctx.HTML(components.Dashboard(posts))
2017-06-07 19:12:59 +00:00
userID := ctx.Session().GetString("userId")
if userID != "" {
user, err := arn.GetUser(userID)
if err != nil {
return ctx.Error(http.StatusInternalServerError, "Error fetching user data", err)
}
return ctx.HTML("Welcome back, " + user.Nick + "!")
}
2017-06-07 16:06:57 +00:00
return ctx.HTML("ARN 4.0 is currently under construction.<br><a href='https://paypal.me/blitzprog' target='_blank' rel='noopener'>Support the development</a><br><a href='/auth/google'>Login via Google</a>")
2016-11-19 14:54:31 +00:00
}