Browse Source

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

master
Jan-Lukas Else 1 month ago
parent
commit
5c9cd77694
  1. 8
      geoTiles_test.go
  2. 2
      http.go
  3. 6
      httpRouters.go
  4. 2
      templates/assets/js/geomap.js
  5. 2
      templates/assets/js/geotrack.js
  6. 4
      templates/geomap.gohtml
  7. 4
      templates/trackheader.gohtml

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

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

6
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

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

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

4
templates/geomap.gohtml

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

4
templates/trackheader.gohtml

@ -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 }}
Loading…
Cancel
Save