2018-04-25 19:12:47 +02:00
|
|
|
package post
|
2016-11-22 12:34:59 +09:00
|
|
|
|
|
|
|
import (
|
2017-06-28 00:16:45 +02:00
|
|
|
"net/http"
|
|
|
|
|
2016-11-22 12:34:59 +09:00
|
|
|
"github.com/aerogo/aero"
|
|
|
|
"github.com/animenotifier/arn"
|
|
|
|
"github.com/animenotifier/notify.moe/components"
|
2017-07-06 16:54:10 +02:00
|
|
|
"github.com/animenotifier/notify.moe/utils"
|
2016-11-22 12:34:59 +09:00
|
|
|
)
|
|
|
|
|
2017-06-17 01:25:02 +02:00
|
|
|
// Get post.
|
2016-11-22 12:34:59 +09:00
|
|
|
func Get(ctx *aero.Context) string {
|
|
|
|
id := ctx.Get("id")
|
2017-07-06 16:54:10 +02:00
|
|
|
user := utils.GetUser(ctx)
|
2016-11-22 12:34:59 +09:00
|
|
|
post, err := arn.GetPost(id)
|
2018-04-25 20:03:35 +02:00
|
|
|
// a := 0
|
|
|
|
// a++
|
2016-11-22 12:34:59 +09:00
|
|
|
|
|
|
|
if err != nil {
|
2017-06-28 00:16:45 +02:00
|
|
|
return ctx.Error(http.StatusNotFound, "Post not found", err)
|
2016-11-22 12:34:59 +09:00
|
|
|
}
|
|
|
|
|
2017-07-06 16:54:10 +02:00
|
|
|
return ctx.HTML(components.Post(post, user))
|
2016-11-22 12:34:59 +09:00
|
|
|
}
|