diff --git a/forms.html b/forms.html
index 2bb5ffa..cff32e1 100644
--- a/forms.html
+++ b/forms.html
@@ -2,190 +2,191 @@
-
-
-
+

+
diff --git a/images/banner.jpg b/images/banner.jpg
new file mode 100644
index 0000000..f81a65f
Binary files /dev/null and b/images/banner.jpg differ
diff --git a/main.go b/main.go
index d396732..2d9876c 100644
--- a/main.go
+++ b/main.go
@@ -98,8 +98,9 @@ type Source struct {
var (
mu sync.Mutex
chars []Character
- //go:embed forms.html
- page embed.FS
+ //go:embed templates/*.html
+ //go:embed images/*
+ content embed.FS
)
func main() {
@@ -107,21 +108,27 @@ func main() {
http.HandleFunc("/", formHandler(filename))
http.HandleFunc("/submit", submitHandler(filename))
+ http.Handle("/images/", http.StripPrefix("/images/", http.FileServer(http.FS(content))))
fmt.Println("Server gestartet, erreichbar unter http://localhost:8080")
http.ListenAndServe(":8080", nil)
}
-// formHandler zeigt das Formular an
func formHandler(filename string) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
- tmpl, err := template.ParseFS(page, "forms.html")
+ tmpl, err := template.ParseFS(content, "templates/base.html", "templates/header.html", "templates/main.html", "templates/footer.html")
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
- tmpl.Execute(w, nil)
+ err = tmpl.ExecuteTemplate(w, "base", map[string]interface{}{
+ "Title": "Dungeons & Dragons Monster Generator",
+ })
+ if err != nil {
+ fmt.Println("Template execution error:", err)
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ }
}
}
diff --git a/templates/base.html b/templates/base.html
new file mode 100644
index 0000000..ececfbb
--- /dev/null
+++ b/templates/base.html
@@ -0,0 +1,64 @@
+{{ define "base" }}
+
+
+
+
+
+
+
{{.Title}}
+
+
+
+
+
+
+
+
+ {{ template "header" . }}
+
+ {{ template "main" . }}
+
+ {{ template "footer" . }}
+
+
+
+
+
+
+{{ end }}
diff --git a/templates/footer.html b/templates/footer.html
new file mode 100644
index 0000000..696f204
--- /dev/null
+++ b/templates/footer.html
@@ -0,0 +1,7 @@
+{{ define "footer" }}
+
+{{ end }}
diff --git a/templates/header.html b/templates/header.html
new file mode 100644
index 0000000..196cbef
--- /dev/null
+++ b/templates/header.html
@@ -0,0 +1,15 @@
+{{ define "header" }}
+
+{{ end }}
diff --git a/templates/main.html b/templates/main.html
new file mode 100644
index 0000000..35b6123
--- /dev/null
+++ b/templates/main.html
@@ -0,0 +1,132 @@
+{{ define "main" }}
+
+{{ end }}