2017-10-17 23:17:04 +02:00

39 lines
925 B
Go

package soundtrack
import (
"net/http"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
"github.com/animenotifier/notify.moe/utils/editform"
"github.com/aerogo/aero"
"github.com/animenotifier/arn"
)
// Edit track.
func Edit(ctx *aero.Context) string {
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)
}
ctx.Data = &arn.OpenGraph{
Tags: map[string]string{
"og:title": track.Title,
"og:url": "https://" + ctx.App.Config.Domain + track.Link(),
"og:site_name": "notify.moe",
"og:type": "music.song",
},
}
if track.MainAnime() != nil {
ctx.Data.(*arn.OpenGraph).Tags["og:image"] = track.MainAnime().Image.Large
}
return ctx.HTML(components.SoundTrackTabs(track) + editform.Render(track, "Edit soundtrack", user))
}