Upgraded to latest aero version

This commit is contained in:
2019-06-01 13:55:49 +09:00
parent ae591e5e7e
commit 28db818c37
196 changed files with 645 additions and 593 deletions

View File

@ -9,7 +9,7 @@ import (
)
// Download tries to refresh the soundtrack file.
func Download(ctx *aero.Context) string {
func Download(ctx aero.Context) error {
id := ctx.Get("id")
user := utils.GetUser(ctx)
@ -24,6 +24,5 @@ func Download(ctx *aero.Context) string {
}
track.Download()
return ""
return nil
}

View File

@ -3,7 +3,9 @@ package soundtrack
import (
"net/http"
"github.com/animenotifier/notify.moe/assets"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/middleware"
"github.com/animenotifier/notify.moe/utils"
"github.com/animenotifier/notify.moe/utils/editform"
@ -12,7 +14,7 @@ import (
)
// Edit track.
func Edit(ctx *aero.Context) string {
func Edit(ctx aero.Context) error {
id := ctx.Get("id")
track, err := arn.GetSoundTrack(id)
user := utils.GetUser(ctx)
@ -21,17 +23,18 @@ func Edit(ctx *aero.Context) string {
return ctx.Error(http.StatusNotFound, "Track not found", err)
}
ctx.Data = &arn.OpenGraph{
customCtx := ctx.(*middleware.OpenGraphContext)
customCtx.OpenGraph = &arn.OpenGraph{
Tags: map[string]string{
"og:title": track.Title.ByUser(user),
"og:url": "https://" + ctx.App.Config.Domain + track.Link(),
"og:url": "https://" + assets.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().ImageLink("large")
customCtx.OpenGraph.Tags["og:image"] = track.MainAnime().ImageLink("large")
}
return ctx.HTML(components.SoundTrackTabs(track, user) + editform.Render(track, "Edit soundtrack", user))

View File

@ -6,11 +6,12 @@ import (
"github.com/aerogo/aero"
"github.com/animenotifier/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/middleware"
"github.com/animenotifier/notify.moe/utils"
)
// Lyrics of a soundtrack.
func Lyrics(ctx *aero.Context) string {
func Lyrics(ctx aero.Context) error {
id := ctx.Get("id")
track, err := arn.GetSoundTrack(id)
user := utils.GetUser(ctx)
@ -29,6 +30,7 @@ func Lyrics(ctx *aero.Context) string {
openGraph.Tags["og:description"] = utils.CutLongDescription(track.Lyrics.Romaji)
}
ctx.Data = openGraph
customCtx := ctx.(*middleware.OpenGraphContext)
customCtx.OpenGraph = openGraph
return ctx.HTML(components.SoundTrackLyricsPage(track, user))
}

View File

@ -5,14 +5,15 @@ import (
"github.com/aerogo/aero"
"github.com/animenotifier/arn"
"github.com/animenotifier/notify.moe/assets"
)
func getOpenGraph(ctx *aero.Context, track *arn.SoundTrack) *arn.OpenGraph {
func getOpenGraph(ctx aero.Context, track *arn.SoundTrack) *arn.OpenGraph {
openGraph := &arn.OpenGraph{
Tags: map[string]string{
"og:title": track.Title.ByUser(nil),
"og:url": "https://" + ctx.App.Config.Domain + track.Link(),
"og:site_name": ctx.App.Config.Domain,
"og:url": "https://" + assets.Domain + track.Link(),
"og:site_name": assets.Domain,
"og:type": "music.song",
},
}
@ -33,7 +34,7 @@ func getOpenGraph(ctx *aero.Context, track *arn.SoundTrack) *arn.OpenGraph {
}
if track.File != "" {
openGraph.Tags["og:audio"] = "https://" + ctx.App.Config.Domain + "/audio/" + track.File
openGraph.Tags["og:audio"] = "https://" + assets.Domain + "/audio/" + track.File
openGraph.Tags["og:audio:type"] = "audio/vnd.facebook.bridge"
}

View File

@ -8,7 +8,7 @@ import (
)
// Random returns a random soundtrack.
func Random(ctx *aero.Context) string {
func Random(ctx aero.Context) error {
tracks := arn.FilterSoundTracks(func(track *arn.SoundTrack) bool {
return !track.IsDraft
})
@ -20,7 +20,7 @@ func Random(ctx *aero.Context) string {
}
// Next returns the next soundtrack for the audio player.
func Next(ctx *aero.Context) string {
func Next(ctx aero.Context) error {
tracks := arn.FilterSoundTracks(func(track *arn.SoundTrack) bool {
return !track.IsDraft && track.File != ""
})

View File

@ -6,11 +6,12 @@ import (
"github.com/aerogo/aero"
"github.com/animenotifier/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/middleware"
"github.com/animenotifier/notify.moe/utils"
)
// Get track.
func Get(ctx *aero.Context) string {
func Get(ctx aero.Context) error {
id := ctx.Get("id")
track, err := arn.GetSoundTrack(id)
user := utils.GetUser(ctx)
@ -19,6 +20,7 @@ func Get(ctx *aero.Context) string {
return ctx.Error(http.StatusNotFound, "Track not found", err)
}
ctx.Data = getOpenGraph(ctx, track)
customCtx := ctx.(*middleware.OpenGraphContext)
customCtx.OpenGraph = getOpenGraph(ctx, track)
return ctx.HTML(components.SoundTrackPage(track, user))
}