Moved radio/trains to regio43
This commit is contained in:
34
regio43/trains.go
Normal file
34
regio43/trains.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package regio43
|
||||
|
||||
import (
|
||||
"html/template"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type TrainsTemplateData struct {
|
||||
PlaylistItems []PlaylistItem
|
||||
}
|
||||
|
||||
func trains(w http.ResponseWriter, r *http.Request) {
|
||||
trainsPlaylist := getPlaylistOfVideos("PLZoWUOSrw9RfbTAwQ1pTg3rZD-jZJHd9S")
|
||||
rand.Shuffle(len(trainsPlaylist), func(i, j int) {
|
||||
trainsPlaylist[i], trainsPlaylist[j] = trainsPlaylist[j], trainsPlaylist[i]
|
||||
})
|
||||
|
||||
templateFile := "templates/regio43.tmpl"
|
||||
files, err := template.New(templateFile).ParseFS(content, templateFile)
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
err = files.ExecuteTemplate(w, "regio43.tmpl", TrainsTemplateData{
|
||||
PlaylistItems: trainsPlaylist,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user