From 9b1d75d47f16f7c0eb6c6ca667e4dd25cf3575e5 Mon Sep 17 00:00:00 2001 From: Eli Ribble Date: Fri, 30 Jan 2026 18:21:27 +0000 Subject: [PATCH] Rename htmlpage to html Because it's going to get more tools. --- .gitignore | 4 +-- README.md | 4 +-- default.nix | 2 +- {htmlpage => html}/fileserver.go | 27 +++++++++++------- {htmlpage => html}/h3.go | 2 +- {htmlpage => html}/html.go | 2 +- {htmlpage => html}/response.go | 2 +- {htmlpage => html}/static.go | 6 ++-- {htmlpage => html}/static/css/placeholder | 0 {htmlpage => html}/static/favicon-rmo.ico | Bin {htmlpage => html}/static/favicon-sync.ico | Bin .../static/img/nidus-logo-256-transparent.png | Bin .../static/img/nidus-logo-no-lettering-64.png | Bin .../static/img/rmo-logo-224.png | Bin {htmlpage => html}/static/img/rmo/banner.jpg | Bin .../static/js/address-display.js | 0 .../static/js/address-suggestion.js | 0 {htmlpage => html}/static/js/geocode.js | 0 {htmlpage => html}/static/js/location.js | 0 {htmlpage => html}/static/js/map-aggregate.js | 0 {htmlpage => html}/static/js/map-locator.js | 0 .../static/js/map-multipoint.js | 0 .../static/js/map-with-markers.js | 0 {htmlpage => html}/static/js/report-table.js | 0 .../static/vendor/css/bootstrap.min.css | 0 .../static/vendor/js/bootstrap.bundle.min.js | 0 .../static/vendor/js/bootstrap.min.js | 0 rmo/mock.go | 7 ++--- rmo/nuisance.go | 6 ++-- rmo/pool.go | 6 ++-- rmo/quick.go | 8 +++--- rmo/root.go | 6 ++-- rmo/routes.go | 4 +-- rmo/search.go | 4 +-- rmo/status.go | 14 ++++----- rmo/template.go | 6 ++-- sync/dash.go | 16 +++++------ sync/mock.go | 6 ++-- sync/oauth.go | 4 +-- sync/page.go | 6 ++-- sync/privacy.go | 4 +-- sync/routes.go | 4 +-- sync/signin.go | 6 ++-- sync/text.go | 4 +-- 44 files changed, 83 insertions(+), 77 deletions(-) rename {htmlpage => html}/fileserver.go (88%) rename {htmlpage => html}/h3.go (97%) rename {htmlpage => html}/html.go (99%) rename {htmlpage => html}/response.go (98%) rename {htmlpage => html}/static.go (75%) rename {htmlpage => html}/static/css/placeholder (100%) rename {htmlpage => html}/static/favicon-rmo.ico (100%) rename {htmlpage => html}/static/favicon-sync.ico (100%) rename {htmlpage => html}/static/img/nidus-logo-256-transparent.png (100%) rename {htmlpage => html}/static/img/nidus-logo-no-lettering-64.png (100%) rename {htmlpage => html}/static/img/rmo-logo-224.png (100%) rename {htmlpage => html}/static/img/rmo/banner.jpg (100%) rename {htmlpage => html}/static/js/address-display.js (100%) rename {htmlpage => html}/static/js/address-suggestion.js (100%) rename {htmlpage => html}/static/js/geocode.js (100%) rename {htmlpage => html}/static/js/location.js (100%) rename {htmlpage => html}/static/js/map-aggregate.js (100%) rename {htmlpage => html}/static/js/map-locator.js (100%) rename {htmlpage => html}/static/js/map-multipoint.js (100%) rename {htmlpage => html}/static/js/map-with-markers.js (100%) rename {htmlpage => html}/static/js/report-table.js (100%) rename {htmlpage => html}/static/vendor/css/bootstrap.min.css (100%) rename {htmlpage => html}/static/vendor/js/bootstrap.bundle.min.js (100%) rename {htmlpage => html}/static/vendor/js/bootstrap.min.js (100%) diff --git a/.gitignore b/.gitignore index 2c345b04..36b3665b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ nidus-sync -htmlpage/static/css/bootstrap.css -htmlpage/static/css/bootstrap.css.map +html/static/css/bootstrap.css +html/static/css/bootstrap.css.map .sass-cache/ tmp/ diff --git a/README.md b/README.md index 8cfe8ff5..521e07f1 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ We're using a customized Bootstrap theme for this site. You'll need to build the ``` nix develop cd scss -scss custom.scss > ../htmlpage/static/css/bootstrap.css +scss custom.scss > ../html/static/css/bootstrap.css ``` ## Running @@ -90,5 +90,5 @@ This uses [goose](https://github.com/pressly/goose). You can use the goose comma For iterating on styles ``` -watchexec -e *.scss sass --style=compressed scss/custom.scss:htmlpage/static/css/bootstrap.css +watchexec -e *.scss sass --style=compressed scss/custom.scss:html/static/css/bootstrap.css ``` diff --git a/default.nix b/default.nix index 700a599f..e38aec3f 100644 --- a/default.nix +++ b/default.nix @@ -16,7 +16,7 @@ pkgs.buildGoModule rec { preBuild = '' SASS_SRC_DIR="./scss" - CSS_OUTPUT_DIR="./htmlpage/static/css/" + CSS_OUTPUT_DIR="./html/static/css/" mkdir -p "$CSS_OUTPUT_DIR" diff --git a/htmlpage/fileserver.go b/html/fileserver.go similarity index 88% rename from htmlpage/fileserver.go rename to html/fileserver.go index 5dc69871..245b8d1c 100644 --- a/htmlpage/fileserver.go +++ b/html/fileserver.go @@ -1,4 +1,4 @@ -package htmlpage +package html import ( "embed" @@ -12,6 +12,7 @@ import ( "github.com/Gleipnir-Technology/nidus-sync/config" "github.com/go-chi/chi/v5" + "github.com/rs/zerolog/log" ) // FileServer conveniently sets up a http.FileServer handler to serve @@ -36,9 +37,21 @@ func FileServer(r chi.Router, path string, root http.FileSystem, embeddedFS embe var err error var fileToServe http.File + found := false - if config.IsProductionEnvironment() { - // For production use the embedded filesystem + // For dev, try the current filesystem + if !config.IsProductionEnvironment() { + // Try to open from local filesystem for development + fileToServe, err = root.Open(requestedPath) + if err != nil { + log.Warn().Str("path", requestedPath).Msg("Failed to read static file for dev") + found = false + } else { + found = true + } + } + // For production use the embedded filesystem + if !found { embeddedFilePath := filepath.Join(embeddedPath, requestedPath) embeddedFile, err := embeddedFS.Open(embeddedFilePath) @@ -49,14 +62,6 @@ func FileServer(r chi.Router, path string, root http.FileSystem, embeddedFS embe // Wrap the embedded file to implement http.File interface fileToServe = &embeddedFileWrapper{embeddedFile} - - } else { - // Try to open from local filesystem for development - fileToServe, err = root.Open(requestedPath) - if err != nil { - RespondError(w, "Failed to open file", err, http.StatusNotFound) - return - } } // Create a custom ResponseWriter that allows us to modify headers diff --git a/htmlpage/h3.go b/html/h3.go similarity index 97% rename from htmlpage/h3.go rename to html/h3.go index 6de2b817..644db8c4 100644 --- a/htmlpage/h3.go +++ b/html/h3.go @@ -1,4 +1,4 @@ -package htmlpage +package html import ( "fmt" diff --git a/htmlpage/html.go b/html/html.go similarity index 99% rename from htmlpage/html.go rename to html/html.go index a3882f55..f16312d8 100644 --- a/htmlpage/html.go +++ b/html/html.go @@ -1,4 +1,4 @@ -package htmlpage +package html import ( "bytes" diff --git a/htmlpage/response.go b/html/response.go similarity index 98% rename from htmlpage/response.go rename to html/response.go index 74b5cc2d..33e1d386 100644 --- a/htmlpage/response.go +++ b/html/response.go @@ -1,4 +1,4 @@ -package htmlpage +package html import ( "net/http" diff --git a/htmlpage/static.go b/html/static.go similarity index 75% rename from htmlpage/static.go rename to html/static.go index 0a544c00..c6fbb429 100644 --- a/htmlpage/static.go +++ b/html/static.go @@ -1,10 +1,12 @@ -package htmlpage +package html import ( "embed" + "io/fs" "net/http" "github.com/go-chi/chi/v5" + "github.com/rs/zerolog/log" ) //go:embed static/* @@ -14,7 +16,7 @@ var localFS http.Dir func AddStaticRoute(r chi.Router, path string) { if localFS == "" { - localFS = http.Dir("./htmlpage/static") + localFS = http.Dir("./html/static") } FileServer(r, "/static", localFS, EmbeddedStaticFS, "static") } diff --git a/htmlpage/static/css/placeholder b/html/static/css/placeholder similarity index 100% rename from htmlpage/static/css/placeholder rename to html/static/css/placeholder diff --git a/htmlpage/static/favicon-rmo.ico b/html/static/favicon-rmo.ico similarity index 100% rename from htmlpage/static/favicon-rmo.ico rename to html/static/favicon-rmo.ico diff --git a/htmlpage/static/favicon-sync.ico b/html/static/favicon-sync.ico similarity index 100% rename from htmlpage/static/favicon-sync.ico rename to html/static/favicon-sync.ico diff --git a/htmlpage/static/img/nidus-logo-256-transparent.png b/html/static/img/nidus-logo-256-transparent.png similarity index 100% rename from htmlpage/static/img/nidus-logo-256-transparent.png rename to html/static/img/nidus-logo-256-transparent.png diff --git a/htmlpage/static/img/nidus-logo-no-lettering-64.png b/html/static/img/nidus-logo-no-lettering-64.png similarity index 100% rename from htmlpage/static/img/nidus-logo-no-lettering-64.png rename to html/static/img/nidus-logo-no-lettering-64.png diff --git a/htmlpage/static/img/rmo-logo-224.png b/html/static/img/rmo-logo-224.png similarity index 100% rename from htmlpage/static/img/rmo-logo-224.png rename to html/static/img/rmo-logo-224.png diff --git a/htmlpage/static/img/rmo/banner.jpg b/html/static/img/rmo/banner.jpg similarity index 100% rename from htmlpage/static/img/rmo/banner.jpg rename to html/static/img/rmo/banner.jpg diff --git a/htmlpage/static/js/address-display.js b/html/static/js/address-display.js similarity index 100% rename from htmlpage/static/js/address-display.js rename to html/static/js/address-display.js diff --git a/htmlpage/static/js/address-suggestion.js b/html/static/js/address-suggestion.js similarity index 100% rename from htmlpage/static/js/address-suggestion.js rename to html/static/js/address-suggestion.js diff --git a/htmlpage/static/js/geocode.js b/html/static/js/geocode.js similarity index 100% rename from htmlpage/static/js/geocode.js rename to html/static/js/geocode.js diff --git a/htmlpage/static/js/location.js b/html/static/js/location.js similarity index 100% rename from htmlpage/static/js/location.js rename to html/static/js/location.js diff --git a/htmlpage/static/js/map-aggregate.js b/html/static/js/map-aggregate.js similarity index 100% rename from htmlpage/static/js/map-aggregate.js rename to html/static/js/map-aggregate.js diff --git a/htmlpage/static/js/map-locator.js b/html/static/js/map-locator.js similarity index 100% rename from htmlpage/static/js/map-locator.js rename to html/static/js/map-locator.js diff --git a/htmlpage/static/js/map-multipoint.js b/html/static/js/map-multipoint.js similarity index 100% rename from htmlpage/static/js/map-multipoint.js rename to html/static/js/map-multipoint.js diff --git a/htmlpage/static/js/map-with-markers.js b/html/static/js/map-with-markers.js similarity index 100% rename from htmlpage/static/js/map-with-markers.js rename to html/static/js/map-with-markers.js diff --git a/htmlpage/static/js/report-table.js b/html/static/js/report-table.js similarity index 100% rename from htmlpage/static/js/report-table.js rename to html/static/js/report-table.js diff --git a/htmlpage/static/vendor/css/bootstrap.min.css b/html/static/vendor/css/bootstrap.min.css similarity index 100% rename from htmlpage/static/vendor/css/bootstrap.min.css rename to html/static/vendor/css/bootstrap.min.css diff --git a/htmlpage/static/vendor/js/bootstrap.bundle.min.js b/html/static/vendor/js/bootstrap.bundle.min.js similarity index 100% rename from htmlpage/static/vendor/js/bootstrap.bundle.min.js rename to html/static/vendor/js/bootstrap.bundle.min.js diff --git a/htmlpage/static/vendor/js/bootstrap.min.js b/html/static/vendor/js/bootstrap.min.js similarity index 100% rename from htmlpage/static/vendor/js/bootstrap.min.js rename to html/static/vendor/js/bootstrap.min.js diff --git a/rmo/mock.go b/rmo/mock.go index 3255eab9..a49554bd 100644 --- a/rmo/mock.go +++ b/rmo/mock.go @@ -4,7 +4,7 @@ import ( "net/http" "github.com/Gleipnir-Technology/nidus-sync/config" - "github.com/Gleipnir-Technology/nidus-sync/htmlpage" + "github.com/Gleipnir-Technology/nidus-sync/html" "github.com/go-chi/chi/v5" ) @@ -57,17 +57,16 @@ func makeContentURL(slug string) ContentURL { Water: makeURLMock(slug, "water"), } } - func makeURLMock(slug, p string) string { return config.MakeURLReport("/mock/district/%s/%s", slug, p) } -func renderMock(t *htmlpage.BuiltTemplate) func(http.ResponseWriter, *http.Request) { +func renderMock(t *html.BuiltTemplate) func(http.ResponseWriter, *http.Request) { return func(w http.ResponseWriter, r *http.Request) { slug := chi.URLParam(r, "slug") if slug == "" { slug = "delta-mvcd" } - htmlpage.RenderOrError( + html.RenderOrError( w, t, ContentMock{ diff --git a/rmo/nuisance.go b/rmo/nuisance.go index ace0ee08..5580daa4 100644 --- a/rmo/nuisance.go +++ b/rmo/nuisance.go @@ -9,7 +9,7 @@ import ( "github.com/Gleipnir-Technology/nidus-sync/db" "github.com/Gleipnir-Technology/nidus-sync/db/enums" "github.com/Gleipnir-Technology/nidus-sync/db/models" - "github.com/Gleipnir-Technology/nidus-sync/htmlpage" + "github.com/Gleipnir-Technology/nidus-sync/html" "github.com/aarondl/opt/omit" "github.com/aarondl/opt/omitnull" "github.com/rs/zerolog/log" @@ -26,7 +26,7 @@ var ( ) func getNuisance(w http.ResponseWriter, r *http.Request) { - htmlpage.RenderOrError( + html.RenderOrError( w, Nuisance, ContextNuisance{}, @@ -34,7 +34,7 @@ func getNuisance(w http.ResponseWriter, r *http.Request) { } func getNuisanceSubmitComplete(w http.ResponseWriter, r *http.Request) { report := r.URL.Query().Get("report") - htmlpage.RenderOrError( + html.RenderOrError( w, NuisanceSubmitComplete, ContextNuisanceSubmitComplete{ diff --git a/rmo/pool.go b/rmo/pool.go index 5b6adb08..6abb7efe 100644 --- a/rmo/pool.go +++ b/rmo/pool.go @@ -13,7 +13,7 @@ import ( "github.com/Gleipnir-Technology/nidus-sync/db" "github.com/Gleipnir-Technology/nidus-sync/db/enums" "github.com/Gleipnir-Technology/nidus-sync/db/models" - "github.com/Gleipnir-Technology/nidus-sync/htmlpage" + "github.com/Gleipnir-Technology/nidus-sync/html" "github.com/aarondl/opt/omit" "github.com/rs/zerolog/log" ) @@ -31,7 +31,7 @@ var ( ) func getPool(w http.ResponseWriter, r *http.Request) { - htmlpage.RenderOrError( + html.RenderOrError( w, Pool, ContextPool{ @@ -41,7 +41,7 @@ func getPool(w http.ResponseWriter, r *http.Request) { } func getPoolSubmitComplete(w http.ResponseWriter, r *http.Request) { report := r.URL.Query().Get("report") - htmlpage.RenderOrError( + html.RenderOrError( w, PoolSubmitComplete, ContextPoolSubmitComplete{ diff --git a/rmo/quick.go b/rmo/quick.go index 87606e71..d001d358 100644 --- a/rmo/quick.go +++ b/rmo/quick.go @@ -16,7 +16,7 @@ import ( "github.com/Gleipnir-Technology/nidus-sync/db/enums" "github.com/Gleipnir-Technology/nidus-sync/db/models" "github.com/Gleipnir-Technology/nidus-sync/h3utils" - "github.com/Gleipnir-Technology/nidus-sync/htmlpage" + "github.com/Gleipnir-Technology/nidus-sync/html" "github.com/Gleipnir-Technology/nidus-sync/platform" "github.com/Gleipnir-Technology/nidus-sync/platform/text" "github.com/aarondl/opt/omit" @@ -44,7 +44,7 @@ var ( ) func getQuick(w http.ResponseWriter, r *http.Request) { - htmlpage.RenderOrError( + html.RenderOrError( w, quickT, ContentQuick{}, @@ -80,7 +80,7 @@ func getQuickSubmitComplete(w http.ResponseWriter, r *http.Request) { } } } - htmlpage.RenderOrError( + html.RenderOrError( w, quickSubmitCompleteT, ContentQuickSubmitComplete{ @@ -91,7 +91,7 @@ func getQuickSubmitComplete(w http.ResponseWriter, r *http.Request) { } func getRegisterNotificationsComplete(w http.ResponseWriter, r *http.Request) { report := r.URL.Query().Get("report") - htmlpage.RenderOrError( + html.RenderOrError( w, registerNotificationsCompleteT, ContentRegisterNotificationsComplete{ diff --git a/rmo/root.go b/rmo/root.go index a2cf985e..18b5284f 100644 --- a/rmo/root.go +++ b/rmo/root.go @@ -5,7 +5,7 @@ import ( "net/http" "github.com/Gleipnir-Technology/nidus-sync/config" - "github.com/Gleipnir-Technology/nidus-sync/htmlpage" + "github.com/Gleipnir-Technology/nidus-sync/html" "github.com/rs/zerolog/log" ) @@ -24,7 +24,7 @@ var ( ) func getPrivacy(w http.ResponseWriter, r *http.Request) { - htmlpage.RenderOrError( + html.RenderOrError( w, PrivacyT, ContentPrivacy{ @@ -36,7 +36,7 @@ func getPrivacy(w http.ResponseWriter, r *http.Request) { ) } func getRoot(w http.ResponseWriter, r *http.Request) { - htmlpage.RenderOrError( + html.RenderOrError( w, RootT, ContentRoot{}, diff --git a/rmo/routes.go b/rmo/routes.go index 105f2422..415fb836 100644 --- a/rmo/routes.go +++ b/rmo/routes.go @@ -1,7 +1,7 @@ package rmo import ( - "github.com/Gleipnir-Technology/nidus-sync/htmlpage" + "github.com/Gleipnir-Technology/nidus-sync/html" "github.com/go-chi/chi/v5" ) @@ -28,6 +28,6 @@ func Router() chi.Router { r.Get("/status", getStatus) r.Get("/status/{report_id}", getStatusByID) r.Get("/terms-of-service", getTerms) - htmlpage.AddStaticRoute(r, "/static") + html.AddStaticRoute(r, "/static") return r } diff --git a/rmo/search.go b/rmo/search.go index d5f0d3ac..d37dbd3a 100644 --- a/rmo/search.go +++ b/rmo/search.go @@ -4,7 +4,7 @@ import ( "net/http" "github.com/Gleipnir-Technology/nidus-sync/config" - "github.com/Gleipnir-Technology/nidus-sync/htmlpage" + "github.com/Gleipnir-Technology/nidus-sync/html" ) type ContentSearch struct { @@ -17,7 +17,7 @@ var ( ) func getSearch(w http.ResponseWriter, r *http.Request) { - htmlpage.RenderOrError( + html.RenderOrError( w, Search, ContentSearch{ diff --git a/rmo/status.go b/rmo/status.go index 98b134ea..402937c1 100644 --- a/rmo/status.go +++ b/rmo/status.go @@ -14,7 +14,7 @@ import ( "github.com/Gleipnir-Technology/nidus-sync/db" "github.com/Gleipnir-Technology/nidus-sync/db/models" "github.com/Gleipnir-Technology/nidus-sync/db/sql" - "github.com/Gleipnir-Technology/nidus-sync/htmlpage" + "github.com/Gleipnir-Technology/nidus-sync/html" "github.com/go-chi/chi/v5" "github.com/rs/zerolog/log" "github.com/stephenafamo/scan" @@ -84,7 +84,7 @@ func formatReportID(s string) string { func getStatus(w http.ResponseWriter, r *http.Request) { report_id_str := r.URL.Query().Get("report") if report_id_str == "" { - htmlpage.RenderOrError( + html.RenderOrError( w, Status, ContentStatus{ @@ -103,7 +103,7 @@ func getStatus(w http.ResponseWriter, r *http.Request) { } if len(results) != 1 { log.Error().Int("count", len(results)).Str("report_id", report_id_str).Msg("Got too many results for report id. This is a programmer error.") - htmlpage.RenderOrError( + html.RenderOrError( w, Status, ContentStatus{ @@ -117,7 +117,7 @@ func getStatus(w http.ResponseWriter, r *http.Request) { http.Redirect(w, r, fmt.Sprintf("/status/%s", report_id), http.StatusFound) return } - htmlpage.RenderOrError( + html.RenderOrError( w, Status, ContentStatus{ @@ -226,7 +226,7 @@ func getStatusByID(w http.ResponseWriter, r *http.Request) { content, err = contentFromQuick(ctx, report_id) } content.MapboxToken = config.MapboxToken - htmlpage.RenderOrError( + html.RenderOrError( w, StatusByID, content, @@ -235,7 +235,7 @@ func getStatusByID(w http.ResponseWriter, r *http.Request) { /* func getQuick(w http.ResponseWriter, r *http.Request) { - htmlpage.RenderOrError( + html.RenderOrError( w, Quick, ContentQuick{}, @@ -244,7 +244,7 @@ func getStatusByID(w http.ResponseWriter, r *http.Request) { func getQuickSubmitComplete(w http.ResponseWriter, r *http.Request) { report := r.URL.Query().Get("report") - htmlpage.RenderOrError( + html.RenderOrError( w, QuickSubmitComplete, ContentQuickSubmitComplete{ diff --git a/rmo/template.go b/rmo/template.go index c7f6ebc4..f7db337d 100644 --- a/rmo/template.go +++ b/rmo/template.go @@ -4,7 +4,7 @@ import ( "embed" "fmt" - "github.com/Gleipnir-Technology/nidus-sync/htmlpage" + "github.com/Gleipnir-Technology/nidus-sync/html" ) //go:embed template/* @@ -13,7 +13,7 @@ var embeddedFiles embed.FS var components = [...]string{"footer", "header", "photo-upload", "photo-upload-header"} var svgs = [...]string{"check-report", "mosquito", "pond"} -func buildTemplate(files ...string) *htmlpage.BuiltTemplate { +func buildTemplate(files ...string) *html.BuiltTemplate { subdir := "rmo" full_files := make([]string, 0) for _, f := range files { @@ -25,5 +25,5 @@ func buildTemplate(files ...string) *htmlpage.BuiltTemplate { for _, c := range svgs { full_files = append(full_files, fmt.Sprintf("%s/template/svg/%s.svg", subdir, c)) } - return htmlpage.NewBuiltTemplate(embeddedFiles, "rmo/", full_files...) + return html.NewBuiltTemplate(embeddedFiles, "rmo/", full_files...) } diff --git a/sync/dash.go b/sync/dash.go index e0b58016..22ef7987 100644 --- a/sync/dash.go +++ b/sync/dash.go @@ -14,7 +14,7 @@ import ( "github.com/Gleipnir-Technology/nidus-sync/db" "github.com/Gleipnir-Technology/nidus-sync/db/models" "github.com/Gleipnir-Technology/nidus-sync/h3utils" - "github.com/Gleipnir-Technology/nidus-sync/htmlpage" + "github.com/Gleipnir-Technology/nidus-sync/html" "github.com/go-chi/chi/v5" "github.com/google/uuid" "github.com/uber/h3-go/v4" @@ -97,7 +97,7 @@ func getDistrict(w http.ResponseWriter, r *http.Request) { context := ContextDistrict{ MapboxToken: config.MapboxToken, } - htmlpage.RenderOrError(w, districtT, &context) + html.RenderOrError(w, districtT, &context) } func getLayoutTest(w http.ResponseWriter, r *http.Request, u *models.User) { @@ -106,7 +106,7 @@ func getLayoutTest(w http.ResponseWriter, r *http.Request, u *models.User) { respondError(w, "Failed to get user", err, http.StatusInternalServerError) return } - htmlpage.RenderOrError(w, layoutTestT, &ContentLayoutTest{User: userContent}) + html.RenderOrError(w, layoutTestT, &ContentLayoutTest{User: userContent}) } func getRoot(w http.ResponseWriter, r *http.Request) { @@ -241,7 +241,7 @@ func cell(ctx context.Context, w http.ResponseWriter, user *models.User, c int64 Treatments: treatments, User: userContent, } - htmlpage.RenderOrError(w, cellT, &data) + html.RenderOrError(w, cellT, &data) } func dashboard(ctx context.Context, w http.ResponseWriter, user *models.User) { @@ -310,7 +310,7 @@ func dashboard(ctx context.Context, w http.ResponseWriter, user *models.User) { RecentRequests: requests, User: userContent, } - htmlpage.RenderOrError(w, dashboardT, data) + html.RenderOrError(w, dashboardT, data) } func settings(w http.ResponseWriter, r *http.Request, user *models.User) { @@ -322,7 +322,7 @@ func settings(w http.ResponseWriter, r *http.Request, user *models.User) { data := ContentAuthenticatedPlaceholder{ User: userContent, } - htmlpage.RenderOrError(w, settingsT, data) + html.RenderOrError(w, settingsT, data) } func source(w http.ResponseWriter, r *http.Request, user *models.User, id uuid.UUID) { @@ -383,7 +383,7 @@ func source(w http.ResponseWriter, r *http.Request, user *models.User, id uuid.U User: userContent, } - htmlpage.RenderOrError(w, sourceT, data) + html.RenderOrError(w, sourceT, data) } func trap(w http.ResponseWriter, r *http.Request, user *models.User, id uuid.UUID) { @@ -423,5 +423,5 @@ func trap(w http.ResponseWriter, r *http.Request, user *models.User, id uuid.UUI User: userContent, } - htmlpage.RenderOrError(w, trapT, data) + html.RenderOrError(w, trapT, data) } diff --git a/sync/mock.go b/sync/mock.go index 923c3840..e61dd847 100644 --- a/sync/mock.go +++ b/sync/mock.go @@ -6,7 +6,7 @@ import ( "strconv" "github.com/Gleipnir-Technology/nidus-sync/config" - "github.com/Gleipnir-Technology/nidus-sync/htmlpage" + "github.com/Gleipnir-Technology/nidus-sync/html" "github.com/go-chi/chi/v5" "github.com/rs/zerolog/log" "github.com/skip2/go-qrcode" @@ -125,13 +125,13 @@ func mock(t string, w http.ResponseWriter, code string) { SettingUserAdd: "/mock/setting/user/add", }, } - template, ok := htmlpage.TemplatesByFilename[t+".html"] + template, ok := html.TemplatesByFilename[t+".html"] if !ok { log.Error().Str("template", t).Msg("Failed to find template") respondError(w, "Failed to render template", nil, http.StatusInternalServerError) return } - htmlpage.RenderOrError(w, &template, data) + html.RenderOrError(w, &template, data) } func renderMock(templateName string) http.HandlerFunc { diff --git a/sync/oauth.go b/sync/oauth.go index 25129363..7dc9d443 100644 --- a/sync/oauth.go +++ b/sync/oauth.go @@ -9,7 +9,7 @@ import ( "github.com/Gleipnir-Technology/nidus-sync/background" "github.com/Gleipnir-Technology/nidus-sync/config" "github.com/Gleipnir-Technology/nidus-sync/db/models" - "github.com/Gleipnir-Technology/nidus-sync/htmlpage" + "github.com/Gleipnir-Technology/nidus-sync/html" "github.com/rs/zerolog/log" ) @@ -89,5 +89,5 @@ func oauthPrompt(w http.ResponseWriter, r *http.Request, user *models.User) { data := ContextOauthPrompt{ User: userContent, } - htmlpage.RenderOrError(w, oauthPromptT, data) + html.RenderOrError(w, oauthPromptT, data) } diff --git a/sync/page.go b/sync/page.go index 291c5e05..50d812ee 100644 --- a/sync/page.go +++ b/sync/page.go @@ -5,7 +5,7 @@ import ( "fmt" "net/http" - "github.com/Gleipnir-Technology/nidus-sync/htmlpage" + "github.com/Gleipnir-Technology/nidus-sync/html" "github.com/rs/zerolog/log" ) @@ -14,7 +14,7 @@ var embeddedFiles embed.FS var components = [...]string{"header", "icons", "map", "sidebar"} -func buildTemplate(files ...string) *htmlpage.BuiltTemplate { +func buildTemplate(files ...string) *html.BuiltTemplate { subdir := "sync" full_files := make([]string, 0) for _, f := range files { @@ -23,7 +23,7 @@ func buildTemplate(files ...string) *htmlpage.BuiltTemplate { for _, c := range components { full_files = append(full_files, fmt.Sprintf("%s/template/components/%s.html", subdir, c)) } - return htmlpage.NewBuiltTemplate(embeddedFiles, "sync/", full_files...) + return html.NewBuiltTemplate(embeddedFiles, "sync/", full_files...) } // Respond with an error that is visible to the user diff --git a/sync/privacy.go b/sync/privacy.go index 9631a1aa..a1e98279 100644 --- a/sync/privacy.go +++ b/sync/privacy.go @@ -4,7 +4,7 @@ import ( "net/http" "github.com/Gleipnir-Technology/nidus-sync/config" - "github.com/Gleipnir-Technology/nidus-sync/htmlpage" + "github.com/Gleipnir-Technology/nidus-sync/html" ) type ContentPrivacy struct { @@ -19,7 +19,7 @@ var ( ) func getPrivacy(w http.ResponseWriter, r *http.Request) { - htmlpage.RenderOrError( + html.RenderOrError( w, PrivacyT, ContentPrivacy{ diff --git a/sync/routes.go b/sync/routes.go index abb2be6b..86c14bb9 100644 --- a/sync/routes.go +++ b/sync/routes.go @@ -3,7 +3,7 @@ package sync import ( "github.com/Gleipnir-Technology/nidus-sync/api" "github.com/Gleipnir-Technology/nidus-sync/auth" - "github.com/Gleipnir-Technology/nidus-sync/htmlpage" + "github.com/Gleipnir-Technology/nidus-sync/html" "github.com/go-chi/chi/v5" ) @@ -67,6 +67,6 @@ func Router() chi.Router { r.Method("GET", "/trap/{globalid}", auth.NewEnsureAuth(getTrap)) r.Method("GET", "/text/{destination}", auth.NewEnsureAuth(getTextMessages)) - htmlpage.AddStaticRoute(r, "/static") + html.AddStaticRoute(r, "/static") return r } diff --git a/sync/signin.go b/sync/signin.go index 6b72d011..40c91861 100644 --- a/sync/signin.go +++ b/sync/signin.go @@ -7,7 +7,7 @@ import ( "github.com/Gleipnir-Technology/nidus-sync/auth" "github.com/Gleipnir-Technology/nidus-sync/db/models" - "github.com/Gleipnir-Technology/nidus-sync/htmlpage" + "github.com/Gleipnir-Technology/nidus-sync/html" "github.com/rs/zerolog/log" ) @@ -92,10 +92,10 @@ func signin(w http.ResponseWriter, errorCode string) { data := ContentSignin{ InvalidCredentials: errorCode == "invalid-credentials", } - htmlpage.RenderOrError(w, signinT, data) + html.RenderOrError(w, signinT, data) } func signup(w http.ResponseWriter, path string) { data := ContentSignup{} - htmlpage.RenderOrError(w, signupT, data) + html.RenderOrError(w, signupT, data) } diff --git a/sync/text.go b/sync/text.go index 2d91cbea..473b51e7 100644 --- a/sync/text.go +++ b/sync/text.go @@ -4,7 +4,7 @@ import ( "net/http" "github.com/Gleipnir-Technology/nidus-sync/db/models" - "github.com/Gleipnir-Technology/nidus-sync/htmlpage" + "github.com/Gleipnir-Technology/nidus-sync/html" ) type ContentTextMessages struct { @@ -24,5 +24,5 @@ func getTextMessages(w http.ResponseWriter, r *http.Request, u *models.User) { content := ContentTextMessages{ User: userContent, } - htmlpage.RenderOrError(w, textMessagesT, content) + html.RenderOrError(w, textMessagesT, content) }