40 lines
1014 B
Go
Raw Normal View History

package quote
import (
"net/http"
"github.com/animenotifier/notify.moe/server/middleware"
2019-06-01 04:55:49 +00:00
"github.com/aerogo/aero"
2019-06-03 09:32:43 +00:00
"github.com/animenotifier/notify.moe/arn"
2019-06-01 04:55:49 +00:00
"github.com/animenotifier/notify.moe/assets"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils/editform"
)
2018-02-24 12:11:12 +00:00
// Edit quote.
2019-06-01 04:55:49 +00:00
func Edit(ctx aero.Context) error {
2019-11-17 07:59:34 +00:00
user := arn.GetUserFromContext(ctx)
id := ctx.Get("id")
quote, err := arn.GetQuote(id)
if err != nil {
return ctx.Error(http.StatusNotFound, "Quote not found", err)
}
2019-06-01 04:55:49 +00:00
customCtx := ctx.(*middleware.OpenGraphContext)
customCtx.OpenGraph = &arn.OpenGraph{
Tags: map[string]string{
2018-02-25 18:22:59 +00:00
"og:title": quote.Text.English,
2019-06-01 04:55:49 +00:00
"og:url": "https://" + assets.Domain + quote.Link(),
"og:site_name": "notify.moe",
},
}
if quote.Character() != nil {
2019-06-01 04:55:49 +00:00
customCtx.OpenGraph.Tags["og:image"] = quote.Character().ImageLink("large")
}
return ctx.HTML(components.QuoteTabs(quote, user) + editform.Render(quote, "Edit quote", user))
}