From 96419b9f8118e4ddf74932f0fc5c01dd15bfc971 Mon Sep 17 00:00:00 2001 From: Jason Hilder Date: Thu, 21 May 2026 14:28:44 +0200 Subject: [PATCH] Rethink... --- Makefile | 13 ----------- cmd/main.go | 23 ------------------- go.mod | 3 --- internal/handlers/home.go | 12 ---------- internal/handlers/utils.go | 32 --------------------------- internal/templates/layouts/base.html | 33 ---------------------------- internal/templates/pages/home.html | 7 ------ 7 files changed, 123 deletions(-) delete mode 100644 Makefile delete mode 100644 cmd/main.go delete mode 100644 go.mod delete mode 100644 internal/handlers/home.go delete mode 100644 internal/handlers/utils.go delete mode 100644 internal/templates/layouts/base.html delete mode 100644 internal/templates/pages/home.html diff --git a/Makefile b/Makefile deleted file mode 100644 index 78318b8..0000000 --- a/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -# Run the application -run: - go run ./cmd - -# Build the application binary into a bin/ folder -build: - go build -o bin/website ./cmd - @echo "Project built in bin directory" - -# Clean up binaries and build artifacts -clean: - rm -rf bin/ - @echo "Build artifacts removed." diff --git a/cmd/main.go b/cmd/main.go deleted file mode 100644 index 266f808..0000000 --- a/cmd/main.go +++ /dev/null @@ -1,23 +0,0 @@ -package main - -import ( - "log" - "net/http" - - "jh/website/internal/handlers" -) - -func main() { - mux := http.NewServeMux() - - // Resolve static dir relative to the binary's location - mux.Handle("GET /static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static")))) - - // Routes - mux.HandleFunc("GET /", handlers.Home) - - log.Println("Server starting on http://localhost:8080") - if err := http.ListenAndServe(":8080", mux); err != nil { - log.Fatal(err) - } -} diff --git a/go.mod b/go.mod deleted file mode 100644 index c5f9fe5..0000000 --- a/go.mod +++ /dev/null @@ -1,3 +0,0 @@ -module jh/website - -go 1.26.1 diff --git a/internal/handlers/home.go b/internal/handlers/home.go deleted file mode 100644 index 8729135..0000000 --- a/internal/handlers/home.go +++ /dev/null @@ -1,12 +0,0 @@ -package handlers - -import "net/http" - -type HomeData struct { - Title string -} - -func Home(w http.ResponseWriter, r *http.Request) { - data := HomeData{Title: "Home"} - view(w, r, "home", data) -} diff --git a/internal/handlers/utils.go b/internal/handlers/utils.go deleted file mode 100644 index 7dac199..0000000 --- a/internal/handlers/utils.go +++ /dev/null @@ -1,32 +0,0 @@ -package handlers - -import ( - "html/template" - "net/http" - "path/filepath" -) - -// Renders a full page by combining the base template with a page template -// Parsed together so the page can define blocks needed for base template -func render(w http.ResponseWriter, _ *http.Request, page string, data any) { - files := []string{ - filepath.Join("internal", "templates", "layouts", "base.html"), - filepath.Join("internal", "templates", "pages", page+".html"), - } - - tmpl, err := template.ParseFiles(files...) - if err != nil { - http.Error(w, "template error: " + err.Error(), http.StatusInternalServerError) - return - } - - w.Header().Set("Content-Type", "text/html") - - if err := tmpl.ExecuteTemplate(w, "base", data); err != nil { - http.Error(w, "render error: " + err.Error(), http.StatusInternalServerError) - } -} - -func view(w http.ResponseWriter, r *http.Request, page string, data any) { - render(w, r, page, data) -} diff --git a/internal/templates/layouts/base.html b/internal/templates/layouts/base.html deleted file mode 100644 index babe73b..0000000 --- a/internal/templates/layouts/base.html +++ /dev/null @@ -1,33 +0,0 @@ -{{define "base"}} - - - - - - {{.Title}} - - - - - - -
- -
- -
- {{template "content" .}} -
- - - - - - -{{end}} diff --git a/internal/templates/pages/home.html b/internal/templates/pages/home.html deleted file mode 100644 index a599989..0000000 --- a/internal/templates/pages/home.html +++ /dev/null @@ -1,7 +0,0 @@ -{{define "content"}} -
-

Hi, I'm Jason

-

PHP & Go developer. I build web applications and tools.

- Codeberg -
-{{end}}