2017-12-04 00:01:16 +00:00
|
|
|
package quote
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
2019-11-18 09:39:59 +00:00
|
|
|
"github.com/animenotifier/notify.moe/server/middleware"
|
2019-06-01 04:55:49 +00:00
|
|
|
|
2017-12-04 00:01:16 +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"
|
2017-12-04 00:01:16 +00:00
|
|
|
"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)
|
2017-12-04 00:01:16 +00:00
|
|
|
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{
|
2017-12-04 00:01:16 +00:00
|
|
|
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(),
|
2017-12-04 00:01:16 +00:00
|
|
|
"og:site_name": "notify.moe",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2018-01-17 22:30:55 +00:00
|
|
|
if quote.Character() != nil {
|
2019-06-01 04:55:49 +00:00
|
|
|
customCtx.OpenGraph.Tags["og:image"] = quote.Character().ImageLink("large")
|
2018-01-17 22:30:55 +00:00
|
|
|
}
|
|
|
|
|
2017-12-04 00:01:16 +00:00
|
|
|
return ctx.HTML(components.QuoteTabs(quote, user) + editform.Render(quote, "Edit quote", user))
|
|
|
|
}
|