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
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)

View File

@ -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))

View File

@ -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

View File

@ -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)

View File

@ -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)

View File

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

View File

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