update track API and lyrics fixes

Signed-off-by: ari melody <ari@arimelody.me>
This commit is contained in:
ari melody 2024-08-04 00:23:55 +01:00
parent 05e16a0867
commit f276ef1ff2
5 changed files with 60 additions and 15 deletions

View file

@ -3,7 +3,9 @@ package view
import (
"encoding/json"
"fmt"
"html/template"
"net/http"
"strings"
"arimelody.me/arimelody.me/admin"
"arimelody.me/arimelody.me/global"
@ -52,6 +54,7 @@ func ServeGateway() http.Handler {
type (
GatewayTrack struct {
*model.Track
Lyrics template.HTML
Number int
}
@ -72,6 +75,7 @@ func ServeGateway() http.Handler {
for i, track := range release.Tracks {
tracks = append([]GatewayTrack{GatewayTrack{
Track: track,
Lyrics: template.HTML(strings.Replace(track.Lyrics, "\n", "<br>", -1)),
Number: len(release.Tracks) - i,
}}, tracks...)
}