2018-04-13 10:20:13 +00:00
|
|
|
package soundtrack
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/aerogo/aero"
|
2019-06-03 09:32:43 +00:00
|
|
|
"github.com/animenotifier/notify.moe/arn"
|
2018-04-13 10:20:13 +00:00
|
|
|
"github.com/animenotifier/notify.moe/components"
|
2019-06-01 04:55:49 +00:00
|
|
|
"github.com/animenotifier/notify.moe/middleware"
|
2018-04-13 10:20:13 +00:00
|
|
|
"github.com/animenotifier/notify.moe/utils"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Lyrics of a soundtrack.
|
2019-06-01 04:55:49 +00:00
|
|
|
func Lyrics(ctx aero.Context) error {
|
2018-04-13 10:20:13 +00:00
|
|
|
id := ctx.Get("id")
|
|
|
|
track, err := arn.GetSoundTrack(id)
|
|
|
|
user := utils.GetUser(ctx)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return ctx.Error(http.StatusNotFound, "Track not found", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
openGraph := getOpenGraph(ctx, track)
|
|
|
|
|
|
|
|
if track.Lyrics.Native != "" {
|
|
|
|
openGraph.Tags["og:description"] = utils.CutLongDescription(track.Lyrics.Native)
|
|
|
|
}
|
|
|
|
|
|
|
|
if track.Lyrics.Romaji != "" {
|
|
|
|
openGraph.Tags["og:description"] = utils.CutLongDescription(track.Lyrics.Romaji)
|
|
|
|
}
|
|
|
|
|
2019-06-01 04:55:49 +00:00
|
|
|
customCtx := ctx.(*middleware.OpenGraphContext)
|
|
|
|
customCtx.OpenGraph = openGraph
|
2018-04-13 10:20:13 +00:00
|
|
|
return ctx.HTML(components.SoundTrackLyricsPage(track, user))
|
|
|
|
}
|