From 5c9cd77694d0837a44cbc2977cd06d29aac221c7 Mon Sep 17 00:00:00 2001 From: Jan-Lukas Else Date: Sun, 12 Dec 2021 11:03:14 +0100 Subject: [PATCH] Fix broken routes, use "/-" for leaflet and tiles instead of "/x" which broke the date archives --- geoTiles_test.go | 8 ++++---- http.go | 2 +- httpRouters.go | 6 +++--- templates/assets/js/geomap.js | 2 +- templates/assets/js/geotrack.js | 2 +- templates/geomap.gohtml | 4 ++-- templates/trackheader.gohtml | 4 ++-- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/geoTiles_test.go b/geoTiles_test.go index 99cae16..0381ce0 100644 --- a/geoTiles_test.go +++ b/geoTiles_test.go @@ -23,9 +23,9 @@ func Test_proxyTiles(t *testing.T) { // Default tile source m := chi.NewMux() - m.Get("/x/tiles/{s}/{z}/{x}/{y}.png", app.proxyTiles("/x/tiles")) + m.Get("/-/tiles/{s}/{z}/{x}/{y}.png", app.proxyTiles("/-/tiles")) - req, err := http.NewRequest(http.MethodGet, "https://example.org/x/tiles/c/8/134/84.png", nil) + req, err := http.NewRequest(http.MethodGet, "https://example.org/-/tiles/c/8/134/84.png", nil) require.NoError(t, err) resp, err := doHandlerRequest(req, m) require.NoError(t, err) @@ -40,9 +40,9 @@ func Test_proxyTiles(t *testing.T) { } m = chi.NewMux() - m.Get("/x/tiles/{s}/{z}/{x}/{y}.png", app.proxyTiles("/x/tiles")) + m.Get("/-/tiles/{s}/{z}/{x}/{y}.png", app.proxyTiles("/-/tiles")) - req, err = http.NewRequest(http.MethodGet, "https://example.org/x/tiles/c/8/134/84.png", nil) + req, err = http.NewRequest(http.MethodGet, "https://example.org/-/tiles/c/8/134/84.png", nil) require.NoError(t, err) resp, err = doHandlerRequest(req, m) require.NoError(t, err) diff --git a/http.go b/http.go index 0047d6d..45110c5 100644 --- a/http.go +++ b/http.go @@ -186,7 +186,7 @@ func (a *goBlog) buildRouter() (http.Handler, error) { r.Route("/m", a.mediaFilesRouter) // Other routes - r.Route("/x", a.xRouter) + r.Route("/-", a.otherRoutesRouter) // Captcha r.Handle("/captcha/*", captcha.Server(500, 250)) diff --git a/httpRouters.go b/httpRouters.go index 4702620..f8a3244 100644 --- a/httpRouters.go +++ b/httpRouters.go @@ -97,10 +97,10 @@ func (a *goBlog) mediaFilesRouter(r chi.Router) { } // Various other routes -func (a *goBlog) xRouter(r chi.Router) { +func (a *goBlog) otherRoutesRouter(r chi.Router) { r.Use(a.privateModeHandler) - r.Get("/tiles/{s}/{z}/{x}/{y}.png", a.proxyTiles("/x/tiles")) - r.With(cacheLoggedIn, a.cacheMiddleware).HandleFunc("/leaflet/*", a.serveFs(leafletFiles, "/x/")) + r.Get("/tiles/{s}/{z}/{x}/{y}.png", a.proxyTiles("/-/tiles")) + r.With(cacheLoggedIn, a.cacheMiddleware).HandleFunc("/leaflet/*", a.serveFs(leafletFiles, "/-/")) } // Blog diff --git a/templates/assets/js/geomap.js b/templates/assets/js/geomap.js index 999dabc..0038f31 100644 --- a/templates/assets/js/geomap.js +++ b/templates/assets/js/geomap.js @@ -8,7 +8,7 @@ maxZoom: mapEl.dataset.maxzoom }) - L.tileLayer("/x/tiles/{s}/{z}/{x}/{y}.png", { + L.tileLayer("/-/tiles/{s}/{z}/{x}/{y}.png", { attribution: mapEl.dataset.attribution, }).addTo(map) diff --git a/templates/assets/js/geotrack.js b/templates/assets/js/geotrack.js index 559def3..7e3f890 100644 --- a/templates/assets/js/geotrack.js +++ b/templates/assets/js/geotrack.js @@ -8,7 +8,7 @@ maxZoom: mapEl.dataset.maxzoom }) - L.tileLayer("/x/tiles/{s}/{z}/{x}/{y}.png", { + L.tileLayer("/-/tiles/{s}/{z}/{x}/{y}.png", { attribution: mapEl.dataset.attribution, }).addTo(map) diff --git a/templates/geomap.gohtml b/templates/geomap.gohtml index d93d363..307740e 100644 --- a/templates/geomap.gohtml +++ b/templates/geomap.gohtml @@ -1,8 +1,8 @@ {{ define "title" }} {{ mdtitle .Blog.Title }} {{ if not .Data.nolocations }} - - + + {{ end }} {{ end }} diff --git a/templates/trackheader.gohtml b/templates/trackheader.gohtml index f7b76e1..8aac7b0 100644 --- a/templates/trackheader.gohtml +++ b/templates/trackheader.gohtml @@ -1,6 +1,6 @@ {{ define "trackheader" }} {{ if .Data.HasTrack }} - - + + {{ end }} {{ end }} \ No newline at end of file