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