41 lines
1.0 KiB
Go
Raw Normal View History

package quote
import (
"net/http"
2019-06-01 04:55:49 +00:00
"github.com/animenotifier/notify.moe/middleware"
"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"
"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 {
user := utils.GetUser(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))
}