mirror of https://github.com/jlelse/GoBlog
Fix broken routes, use "/-" for leaflet and tiles instead of "/x" which broke the date archives
This commit is contained in:
parent
787e5fb807
commit
5c9cd77694
|
@ -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
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))
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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 }}
|
||||
|
||||
|
|
|
@ -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…
Reference in New Issue