31 lines
614 B
Go
Raw Normal View History

2017-10-02 06:29:58 +02:00
package soundtracks
2017-06-27 12:39:41 +02:00
2017-06-27 14:01:32 +02:00
import (
2017-06-27 16:23:57 +02:00
"net/http"
2017-06-27 14:01:32 +02:00
"github.com/aerogo/aero"
"github.com/animenotifier/arn"
"github.com/animenotifier/notify.moe/components"
)
2017-06-27 12:39:41 +02:00
2017-06-27 18:53:31 +02:00
const maxTracks = 9
2017-06-27 14:04:25 +02:00
2017-10-09 15:47:40 +02:00
// Get renders the soundtracks page.
2017-06-27 12:39:41 +02:00
func Get(ctx *aero.Context) string {
2017-10-09 15:47:40 +02:00
tracks, err := arn.FilterSoundTracks(func(track *arn.SoundTrack) bool {
return !track.IsDraft
})
2017-06-27 13:46:29 +02:00
2017-06-27 16:23:57 +02:00
if err != nil {
return ctx.Error(http.StatusInternalServerError, "Error fetching soundtracks", err)
}
2017-06-27 14:38:36 +02:00
2017-06-27 16:54:16 +02:00
arn.SortSoundTracksLatestFirst(tracks)
2017-06-27 14:04:25 +02:00
if len(tracks) > maxTracks {
tracks = tracks[:maxTracks]
}
2017-10-09 15:47:40 +02:00
return ctx.HTML(components.SoundTracks(tracks))
2017-06-27 12:39:41 +02:00
}