37 lines
891 B
Go
Raw Normal View History

package quote
import (
"net/http"
"github.com/aerogo/aero"
"github.com/animenotifier/arn"
"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.
func Edit(ctx *aero.Context) string {
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)
}
ctx.Data = &arn.OpenGraph{
Tags: map[string]string{
2018-02-25 18:22:59 +00:00
"og:title": quote.Text.English,
"og:url": "https://" + ctx.App.Config.Domain + quote.Link(),
"og:site_name": "notify.moe",
},
}
if quote.Character() != nil {
2018-03-27 03:25:25 +00:00
ctx.Data.(*arn.OpenGraph).Tags["og:image"] = quote.Character().ImageLink("large")
}
return ctx.HTML(components.QuoteTabs(quote, user) + editform.Render(quote, "Edit quote", user))
}