Fix broken routes, use "/-" for leaflet and tiles instead of "/x" which broke the date archives

This commit is contained in:
Jan-Lukas Else 2021-12-12 11:03:14 +01:00
parent 787e5fb807
commit 5c9cd77694
7 changed files with 14 additions and 14 deletions

View File

@ -23,9 +23,9 @@ func Test_proxyTiles(t *testing.T) {
// Default tile source // Default tile source
m := chi.NewMux() 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) require.NoError(t, err)
resp, err := doHandlerRequest(req, m) resp, err := doHandlerRequest(req, m)
require.NoError(t, err) require.NoError(t, err)
@ -40,9 +40,9 @@ func Test_proxyTiles(t *testing.T) {
} }
m = chi.NewMux() 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) require.NoError(t, err)
resp, err = doHandlerRequest(req, m) resp, err = doHandlerRequest(req, m)
require.NoError(t, err) require.NoError(t, err)

View File

@ -186,7 +186,7 @@ func (a *goBlog) buildRouter() (http.Handler, error) {
r.Route("/m", a.mediaFilesRouter) r.Route("/m", a.mediaFilesRouter)
// Other routes // Other routes
r.Route("/x", a.xRouter) r.Route("/-", a.otherRoutesRouter)
// Captcha // Captcha
r.Handle("/captcha/*", captcha.Server(500, 250)) r.Handle("/captcha/*", captcha.Server(500, 250))

View File

@ -97,10 +97,10 @@ func (a *goBlog) mediaFilesRouter(r chi.Router) {
} }
// Various other routes // Various other routes
func (a *goBlog) xRouter(r chi.Router) { func (a *goBlog) otherRoutesRouter(r chi.Router) {
r.Use(a.privateModeHandler) r.Use(a.privateModeHandler)
r.Get("/tiles/{s}/{z}/{x}/{y}.png", a.proxyTiles("/x/tiles")) r.Get("/tiles/{s}/{z}/{x}/{y}.png", a.proxyTiles("/-/tiles"))
r.With(cacheLoggedIn, a.cacheMiddleware).HandleFunc("/leaflet/*", a.serveFs(leafletFiles, "/x/")) r.With(cacheLoggedIn, a.cacheMiddleware).HandleFunc("/leaflet/*", a.serveFs(leafletFiles, "/-/"))
} }
// Blog // Blog

View File

@ -8,7 +8,7 @@
maxZoom: mapEl.dataset.maxzoom 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, attribution: mapEl.dataset.attribution,
}).addTo(map) }).addTo(map)

View File

@ -8,7 +8,7 @@
maxZoom: mapEl.dataset.maxzoom 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, attribution: mapEl.dataset.attribution,
}).addTo(map) }).addTo(map)

View File

@ -1,8 +1,8 @@
{{ define "title" }} {{ define "title" }}
<title>{{ mdtitle .Blog.Title }}</title> <title>{{ mdtitle .Blog.Title }}</title>
{{ if not .Data.nolocations }} {{ if not .Data.nolocations }}
<link rel="stylesheet" href="/x/leaflet/leaflet.css"/> <link rel="stylesheet" href="/-/leaflet/leaflet.css"/>
<script src="/x/leaflet/leaflet.js"></script> <script src="/-/leaflet/leaflet.js"></script>
{{ end }} {{ end }}
{{ end }} {{ end }}

View File

@ -1,6 +1,6 @@
{{ define "trackheader" }} {{ define "trackheader" }}
{{ if .Data.HasTrack }} {{ if .Data.HasTrack }}
<link rel="stylesheet" href="/x/leaflet/leaflet.css"/> <link rel="stylesheet" href="/-/leaflet/leaflet.css"/>
<script src="/x/leaflet/leaflet.js"></script> <script src="/-/leaflet/leaflet.js"></script>
{{ end }} {{ end }}
{{ end }} {{ end }}