From 493d15eae8735152b59d1e8f39179a54068408c5 Mon Sep 17 00:00:00 2001 From: Angel Beltran Date: Tue, 30 Dec 2025 11:37:29 -0700 Subject: [PATCH] updated nav --- internal/site/templates.go | 17 ++++ .../component_bodies/nav_bar.html.tmpl | 2 + internal/site/templates/layout.html.tmpl | 92 ++++++++++++++++++- .../page_bodies/account-creation.html.tmpl | 2 - .../accounts/{acctID}/index.html.tmpl | 3 - .../accounts/{acctID}/inventory.html.tmpl | 3 - .../accounts/{acctID}/reports.html.tmpl | 2 - .../templates/page_bodies/index.html.tmpl | 2 - .../templates/page_bodies/login.html.tmpl | 2 - .../templates/page_bodies/sign-up.html.tmpl | 2 - 10 files changed, 108 insertions(+), 19 deletions(-) diff --git a/internal/site/templates.go b/internal/site/templates.go index 10ca0cd..e5b96ad 100644 --- a/internal/site/templates.go +++ b/internal/site/templates.go @@ -1,9 +1,11 @@ package site import ( + "errors" "fmt" "net/http" "net/url" + "os" "path" "path/filepath" "strings" @@ -51,6 +53,14 @@ func (s *Server) serveTemplates(w http.ResponseWriter, r *http.Request) { acct, ) if err != nil { + // TODO: handle 401 + + // TODO: handle 403 + + // TODO: handle 404 + if isFileNotFoundError(err) { + } + // TODO: handle 'not found' as a 404? fmt.Println("[ERROR]: failed to load or parse layout template:", err) http.Redirect(w, r, "/", http.StatusTemporaryRedirect) @@ -60,6 +70,13 @@ func (s *Server) serveTemplates(w http.ResponseWriter, r *http.Request) { w.Write(b) } +func isFileNotFoundError(err error) bool { + var pe *os.PathError + isPathErr := errors.As(err, &pe) + + return isPathErr && pe.Err != nil && pe.Err.Error() == "no such file or directory" +} + // TODO: clean this up... // TODO: somehow tell what the path params are and pass them up. // - then consider pushing this functionality into the template library. diff --git a/internal/site/templates/component_bodies/nav_bar.html.tmpl b/internal/site/templates/component_bodies/nav_bar.html.tmpl index bcbf639..4afcfaf 100644 --- a/internal/site/templates/component_bodies/nav_bar.html.tmpl +++ b/internal/site/templates/component_bodies/nav_bar.html.tmpl @@ -1,3 +1,5 @@ +{{/* TODO: delete, once not needed */}} + {{/* "dot" . */}}