Moved regio43 to base HTML template
This commit is contained in:
@@ -1,6 +1,21 @@
|
||||
package baseTemplates
|
||||
|
||||
import "embed"
|
||||
import (
|
||||
"embed"
|
||||
"html/template"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
//go:embed templates/*
|
||||
var FS embed.FS
|
||||
|
||||
func WithBase(w http.ResponseWriter, templateData any, patterns ...string) {
|
||||
args := append([]string{"templates/base.tmpl"}, patterns...)
|
||||
tmpl := template.Must(template.ParseFS(FS, args...))
|
||||
|
||||
err := tmpl.ExecuteTemplate(w, "base", templateData)
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
@@ -1,19 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>prettysunflower - Regio 43</title>
|
||||
<link rel="stylesheet" type="text/css" href="/static/css/style.css">
|
||||
</head>
|
||||
<body class="page-radio-trains">
|
||||
<div class="video-zone">
|
||||
{{ define "bodyClass" }}page-regio43{{ end }}
|
||||
|
||||
{{ define "content" }}
|
||||
<div class="video-zone max-80">
|
||||
<video id="video-player" controls></video>
|
||||
</div>
|
||||
|
||||
<h1>Regio 43</h1>
|
||||
<h1>Regio43</h1>
|
||||
|
||||
<main>
|
||||
<main class="max-80">
|
||||
{{ range .PlaylistItems }}
|
||||
<div class="playlist-item" data-videoid="{{ .VideoId }}">
|
||||
<img src="{{ .ThumbnailUrl }}">
|
||||
@@ -52,5 +46,4 @@
|
||||
}
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
{{ end }}
|
@@ -1,13 +1,9 @@
|
||||
package regio43
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
//go:embed templates/*
|
||||
var content embed.FS
|
||||
|
||||
func InitHttpHandlers() {
|
||||
http.HandleFunc("/regio43/", trains)
|
||||
}
|
||||
|
@@ -1,9 +1,9 @@
|
||||
package regio43
|
||||
|
||||
import (
|
||||
"html/template"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
"prettysunflower-website/baseTemplates"
|
||||
)
|
||||
|
||||
type TrainsTemplateData struct {
|
||||
@@ -16,19 +16,7 @@ func trains(w http.ResponseWriter, r *http.Request) {
|
||||
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{
|
||||
baseTemplates.WithBase(w, TrainsTemplateData{
|
||||
PlaylistItems: trainsPlaylist,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
}, "templates/regio43.tmpl")
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
@use "colors";
|
||||
|
||||
.page-radio-trains {
|
||||
.page-regio43 {
|
||||
.video-zone {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
|
@@ -192,53 +192,53 @@ body {
|
||||
border: 0.5px solid oklch(75% 0 0deg);
|
||||
}
|
||||
|
||||
.page-radio-trains .video-zone {
|
||||
.page-regio43 .video-zone {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
padding: 1rem;
|
||||
}
|
||||
.page-radio-trains .video-zone #video-player {
|
||||
.page-regio43 .video-zone #video-player {
|
||||
aspect-ratio: 16/9;
|
||||
max-width: 80%;
|
||||
max-height: 50vh;
|
||||
width: 100%;
|
||||
}
|
||||
.page-radio-trains h1 {
|
||||
.page-regio43 h1 {
|
||||
padding: 0 1rem;
|
||||
text-align: center;
|
||||
}
|
||||
.page-radio-trains main {
|
||||
.page-regio43 main {
|
||||
display: grid;
|
||||
gap: 1rem;
|
||||
padding: 1rem;
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
}
|
||||
.page-radio-trains main > div img {
|
||||
.page-regio43 main > div img {
|
||||
width: 100%;
|
||||
}
|
||||
.page-radio-trains main > div.active {
|
||||
.page-regio43 main > div.active {
|
||||
background-color: oklch(from oklch(97% 0.0261 90.1deg) calc(l - 0.05) c h);
|
||||
}
|
||||
.page-radio-trains main > div p {
|
||||
.page-regio43 main > div p {
|
||||
margin: 0.5em;
|
||||
}
|
||||
.page-radio-trains main > div p a {
|
||||
.page-regio43 main > div p a {
|
||||
text-decoration: none;
|
||||
color: black;
|
||||
}
|
||||
@media screen and (max-width: 992px) {
|
||||
.page-radio-trains main {
|
||||
.page-regio43 main {
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
}
|
||||
}
|
||||
@media screen and (max-width: 768px) {
|
||||
.page-radio-trains main {
|
||||
.page-regio43 main {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
}
|
||||
@media screen and (max-width: 576px) {
|
||||
.page-radio-trains main {
|
||||
.page-regio43 main {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user