31 lines
653 B
Go
31 lines
653 B
Go
package model
|
|
|
|
import (
|
|
"html/template"
|
|
"strings"
|
|
)
|
|
|
|
type (
|
|
Track struct {
|
|
ID string `json:"id"`
|
|
Title string `json:"title"`
|
|
Description string `json:"description"`
|
|
Lyrics string `json:"lyrics" db:"lyrics"`
|
|
PreviewURL string `json:"previewURL" db:"preview_url"`
|
|
}
|
|
|
|
DisplayTrack struct {
|
|
*Track
|
|
Lyrics template.HTML `json:"lyrics"`
|
|
Number int `json:"-"`
|
|
}
|
|
)
|
|
|
|
func (track Track) MakeDisplay(number int) DisplayTrack {
|
|
return DisplayTrack{
|
|
Track: &track,
|
|
Lyrics: template.HTML(strings.Replace(track.Lyrics, "\n", "<br>", -1)),
|
|
Number: number,
|
|
}
|
|
}
|