tracks can be edited! + major template overhaul

This commit is contained in:
ari melody 2024-08-31 15:25:44 +01:00
parent 99b6a21179
commit 63122eb428
Signed by: ari
GPG key ID: CF99829C92678188
21 changed files with 674 additions and 221 deletions

28
admin/trackhttp.go Normal file
View file

@ -0,0 +1,28 @@
package admin
import (
"fmt"
"net/http"
"strings"
"arimelody.me/arimelody.me/global"
)
func serveTrack() http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
slices := strings.Split(r.URL.Path[1:], "/")
id := slices[0]
track := global.GetTrack(id)
if track == nil {
http.NotFound(w, r)
return
}
err := pages["track"].Execute(w, track)
if err != nil {
fmt.Printf("Error rendering admin track page for %s: %s\n", id, err)
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
}
})
}