42 lines
995 B
Go
Raw Normal View History

2017-12-03 21:33:24 +00:00
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"
)
2018-02-24 12:11:12 +00:00
// Get quote.
2017-12-03 21:33:24 +00:00
func Get(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)
}
openGraph := &arn.OpenGraph{
Tags: map[string]string{
2018-02-25 11:19:27 +00:00
"og:title": "Quote",
2018-02-25 18:22:59 +00:00
"og:description": quote.Text.English,
2017-12-03 21:33:24 +00:00
"og:url": "https://" + ctx.App.Config.Domain + quote.Link(),
"og:site_name": "notify.moe",
"og:type": "article",
},
}
2018-02-25 11:19:27 +00:00
character, _ := arn.GetCharacter(quote.CharacterID)
if character != nil {
2018-03-27 03:25:25 +00:00
openGraph.Tags["og:title"] = character.Name.Canonical + "'s quote"
openGraph.Tags["og:image"] = "https:" + character.ImageLink("large")
2018-02-25 11:19:27 +00:00
}
2017-12-03 21:33:24 +00:00
ctx.Data = openGraph
return ctx.HTML(components.QuotePage(quote, character, user))
}