42 lines
1.1 KiB
Go
Raw Normal View History

2017-10-09 15:47:40 +02:00
package soundtrack
import (
"net/http"
2019-06-01 13:55:49 +09:00
"github.com/animenotifier/notify.moe/assets"
2017-10-09 15:47:40 +02:00
"github.com/animenotifier/notify.moe/components"
2019-06-01 13:55:49 +09:00
"github.com/animenotifier/notify.moe/middleware"
2017-10-10 12:14:52 +02:00
"github.com/animenotifier/notify.moe/utils"
2017-10-17 23:17:04 +02:00
"github.com/animenotifier/notify.moe/utils/editform"
2017-10-09 15:47:40 +02:00
"github.com/aerogo/aero"
2019-06-03 18:32:43 +09:00
"github.com/animenotifier/notify.moe/arn"
2017-10-09 15:47:40 +02:00
)
// Edit track.
2019-06-01 13:55:49 +09:00
func Edit(ctx aero.Context) error {
2017-10-09 15:47:40 +02:00
id := ctx.Get("id")
track, err := arn.GetSoundTrack(id)
2017-10-17 11:43:07 +02:00
user := utils.GetUser(ctx)
2017-10-09 15:47:40 +02:00
if err != nil {
return ctx.Error(http.StatusNotFound, "Track not found", err)
}
2019-06-01 13:55:49 +09:00
customCtx := ctx.(*middleware.OpenGraphContext)
customCtx.OpenGraph = &arn.OpenGraph{
2017-10-09 15:47:40 +02:00
Tags: map[string]string{
2018-04-08 22:44:21 +02:00
"og:title": track.Title.ByUser(user),
2019-06-01 13:55:49 +09:00
"og:url": "https://" + assets.Domain + track.Link(),
2017-10-09 15:47:40 +02:00
"og:site_name": "notify.moe",
"og:type": "music.song",
},
}
2017-10-12 17:52:46 +02:00
if track.MainAnime() != nil {
2019-06-01 13:55:49 +09:00
customCtx.OpenGraph.Tags["og:image"] = track.MainAnime().ImageLink("large")
2017-10-12 17:52:46 +02:00
}
2017-11-05 14:54:58 -04:00
return ctx.HTML(components.SoundTrackTabs(track, user) + editform.Render(track, "Edit soundtrack", user))
2017-10-09 15:47:40 +02:00
}