39 lines
925 B
Go
Raw Normal View History

2017-10-09 13:47:40 +00:00
package soundtrack
import (
"net/http"
"github.com/animenotifier/notify.moe/components"
2017-10-10 10:14:52 +00:00
"github.com/animenotifier/notify.moe/utils"
2017-10-17 21:17:04 +00:00
"github.com/animenotifier/notify.moe/utils/editform"
2017-10-09 13:47:40 +00:00
"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)
2017-10-17 09:43:07 +00:00
user := utils.GetUser(ctx)
2017-10-09 13:47:40 +00:00
if err != nil {
return ctx.Error(http.StatusNotFound, "Track not found", err)
}
ctx.Data = &arn.OpenGraph{
Tags: map[string]string{
2017-10-09 14:23:18 +00:00
"og:title": track.Title,
2017-10-09 13:47:40 +00:00
"og:url": "https://" + ctx.App.Config.Domain + track.Link(),
"og:site_name": "notify.moe",
"og:type": "music.song",
},
}
2017-10-12 15:52:46 +00:00
if track.MainAnime() != nil {
ctx.Data.(*arn.OpenGraph).Tags["og:image"] = track.MainAnime().Image.Large
}
2017-10-17 21:17:04 +00:00
return ctx.HTML(components.SoundTrackTabs(track) + editform.Render(track, "Edit soundtrack", user))
2017-10-09 13:47:40 +00:00
}