2018-04-25 17:12:47 +00:00
|
|
|
package post
|
2016-11-22 03:34:59 +00:00
|
|
|
|
|
|
|
import (
|
2017-06-27 22:16:45 +00:00
|
|
|
"net/http"
|
|
|
|
|
2016-11-22 03:34:59 +00:00
|
|
|
"github.com/aerogo/aero"
|
2019-06-03 09:32:43 +00:00
|
|
|
"github.com/animenotifier/notify.moe/arn"
|
2016-11-22 03:34:59 +00:00
|
|
|
"github.com/animenotifier/notify.moe/components"
|
2019-06-01 04:55:49 +00:00
|
|
|
"github.com/animenotifier/notify.moe/middleware"
|
2017-07-06 14:54:10 +00:00
|
|
|
"github.com/animenotifier/notify.moe/utils"
|
2016-11-22 03:34:59 +00:00
|
|
|
)
|
|
|
|
|
2017-06-16 23:25:02 +00:00
|
|
|
// Get post.
|
2019-06-01 04:55:49 +00:00
|
|
|
func Get(ctx aero.Context) error {
|
2016-11-22 03:34:59 +00:00
|
|
|
id := ctx.Get("id")
|
2017-07-06 14:54:10 +00:00
|
|
|
user := utils.GetUser(ctx)
|
2016-11-22 03:34:59 +00:00
|
|
|
post, err := arn.GetPost(id)
|
|
|
|
|
|
|
|
if err != nil {
|
2017-06-27 22:16:45 +00:00
|
|
|
return ctx.Error(http.StatusNotFound, "Post not found", err)
|
2016-11-22 03:34:59 +00:00
|
|
|
}
|
|
|
|
|
2019-06-01 04:55:49 +00:00
|
|
|
customCtx := ctx.(*middleware.OpenGraphContext)
|
|
|
|
customCtx.OpenGraph = getOpenGraph(ctx, post)
|
2017-07-06 14:54:10 +00:00
|
|
|
return ctx.HTML(components.Post(post, user))
|
2016-11-22 03:34:59 +00:00
|
|
|
}
|