From 457f123f69df66b24d8a3f5ee9cc36c7f4db6b9f Mon Sep 17 00:00:00 2001 From: Eli Ribble Date: Fri, 3 Apr 2026 00:12:52 +0000 Subject: [PATCH] Add simple compliance landing page --- html/template/rmo/district-compliance.html | 144 +++++++++++++++++++++ rmo/compliance.go | 23 ++++ rmo/routes.go | 1 + static/static.go | 36 ++---- 4 files changed, 181 insertions(+), 23 deletions(-) create mode 100644 html/template/rmo/district-compliance.html create mode 100644 rmo/compliance.go diff --git a/html/template/rmo/district-compliance.html b/html/template/rmo/district-compliance.html new file mode 100644 index 00000000..70a00000 --- /dev/null +++ b/html/template/rmo/district-compliance.html @@ -0,0 +1,144 @@ +{{ template "rmo/layout/base.html" . }} + +{{ define "title" }}Compliance Request{{ end }} +{{ define "extraheader" }} + +{{ end }} +{{ define "content" }} +
+
+ +
+ +
+
+ Location + 1 of 4 +
+
+
+
+
+ +
+

Confirm Property Location

+ +
+
+
+ +
+
+ +
+
Detected Address:
+
123 Maple Street, Riverside, CA 92501
+
+ +
+

Is this the correct location of the property in question?

+
+ + +
+ +
+

+ If you need assistance, please contact Vector Control at (555) 123-4567 +

+
+
+{{ end }} diff --git a/rmo/compliance.go b/rmo/compliance.go new file mode 100644 index 00000000..787c5711 --- /dev/null +++ b/rmo/compliance.go @@ -0,0 +1,23 @@ +package rmo + +import ( + "net/http" + + "github.com/Gleipnir-Technology/nidus-sync/html" +) + +func getDistrictCompliance(w http.ResponseWriter, r *http.Request) { + district, err := districtBySlug(r) + if err != nil { + respondError(w, "Failed to lookup organization", err, http.StatusBadRequest) + return + } + html.RenderOrError( + w, + "rmo/district-compliance.html", + ContentNuisance{ + District: newContentDistrict(district), + URL: makeContentURL(nil), + }, + ) +} diff --git a/rmo/routes.go b/rmo/routes.go index 40cf7062..6c333ac5 100644 --- a/rmo/routes.go +++ b/rmo/routes.go @@ -16,6 +16,7 @@ func Router(r *mux.Router) { r.HandleFunc("/district", getDistrictList).Methods("GET") r.HandleFunc("/district/{slug}", getRootDistrict).Methods("GET") + r.HandleFunc("/district/{slug}/compliance", getDistrictCompliance).Methods("GET") r.HandleFunc("/district/{slug}/nuisance", getNuisanceDistrict).Methods("GET") //r.HandleFunc("/district/{slug}/nuisance-submit-complete", renderMock(mockNuisanceSubmitCompleteT)).Methods("GET") //r.HandleFunc("/district/{slug}/status", renderMock(mockStatusT)).Methods("GET") diff --git a/static/static.go b/static/static.go index 3a724dd2..6d4a824e 100644 --- a/static/static.go +++ b/static/static.go @@ -35,28 +35,18 @@ func AddStaticRoute(r *mux.Router, path string) { }) } } - fileServer(r, "/static", localFS, embeddedStaticFS) + fileServer(r, "/static/", localFS, embeddedStaticFS) } func fileServer(r *mux.Router, path string, root http.FileSystem, embeddedFS embed.FS) { - if strings.ContainsAny(path, "{}*") { - panic("FileServer does not permit any URL parameters.") - } - - if path != "/" && path[len(path)-1] != '/' { - r.HandleFunc(path, http.RedirectHandler(path+"/", 301).ServeHTTP) - path += "/" - } - path += "*" - - r.HandleFunc(path, func(w http.ResponseWriter, r *http.Request) { + log.Debug().Str("path", path).Msg("adding file server") + r.PathPrefix(path).HandlerFunc(func(w http.ResponseWriter, r *http.Request) { //rctx := chi.RouteContext(r.Context()) //pathPrefix := strings.TrimSuffix(rctx.RoutePattern(), "/*") - pathPrefix := strings.TrimPrefix(r.URL.Path, "/static") - - // Determine the actual file path - requestedPath := strings.TrimPrefix(r.URL.Path, pathPrefix+"/") + //pathPrefix := strings.TrimPrefix(r.URL.Path, "/static") + path := strings.TrimPrefix(r.URL.Path, "/static/") + //log.Debug().Str("path", path).Msg("handling request") var err error var fileToServe http.File @@ -65,9 +55,9 @@ func fileServer(r *mux.Router, path string, root http.FileSystem, embeddedFS emb // For dev, try the current filesystem if !config.IsProductionEnvironment() { // Try to open from local filesystem for development - fileToServe, err = root.Open(requestedPath) + fileToServe, err = root.Open(path) if err != nil { - log.Warn().Str("path", requestedPath).Msg("Failed to read static file for dev") + log.Warn().Err(err).Str("path", path).Msg("Failed to read static file for dev") found = false } else { found = true @@ -76,10 +66,10 @@ func fileServer(r *mux.Router, path string, root http.FileSystem, embeddedFS emb // For production use the embedded filesystem if !found { // Requested paths start with - embeddedFile, err := embeddedFS.Open(requestedPath) + embeddedFile, err := embeddedFS.Open(path) if err != nil { - log.Debug().Err(err).Str("requested path", requestedPath).Msg("Failed to find resource") + log.Debug().Err(err).Str("embedded path", path).Msg("Failed to find resource") http.NotFound(w, r) return } @@ -93,14 +83,14 @@ func fileServer(r *mux.Router, path string, root http.FileSystem, embeddedFS emb // Add caching headers if config.IsProductionEnvironment() { - ext := filepath.Ext(requestedPath) + ext := filepath.Ext(path) switch ext { case ".css", ".jpg", ".jpeg", ".png", ".gif", ".svg", ".woff", ".woff2", ".ttf": // Cache for 1 week (604800 seconds) crw.Header().Set("Cache-Control", "public, max-age=604800, stale-while-revalidate=86400") default: // If it's a generated file, cache it essentially forever (1 year) - if strings.HasPrefix(requestedPath, "gen/") { + if strings.HasPrefix(path, "/static/gen/") { crw.Header().Set("Cache-Control", "public, max-age=31536000, immutable") } else { // Other files, 1 hour @@ -109,7 +99,7 @@ func fileServer(r *mux.Router, path string, root http.FileSystem, embeddedFS emb } } // Serve the file - http.ServeContent(crw, r, requestedPath, startedTime, fileToServe) + http.ServeContent(crw, r, path, startedTime, fileToServe) // Close the file fileToServe.Close()