Link POI popups to offline Wikipedia via kiwix-serve
lib/maptool/kiwix.rb: a small reachability check for an external kiwix-serve instance. GET /api/kiwix reports it (same optional- integration pattern as offline-tiles/terrain-tiles); the frontend adds a "Nearby on Wikipedia" link to a point's popup pointing straight at kiwix-serve's own geo search (GET /search?latitude=&longitude= &distance=, confirmed from libkiwix's actual source rather than guessed) — linked to directly, not proxied/embedded, since it already has a full search UI of its own. docker-compose.yaml: new `kiwix` service (ghcr.io/kiwix/kiwix-serve) on the default network, KIWIX_URL wired to reach it by service name. The ZIM itself isn't part of the repo (large, self-contained archive) — data/kiwix/ gitignored same as the *.pmtiles files, setup steps in docs/development.adoc. No kiwix-serve/ZIM available here to test end-to-end — verified the app side against a stand-in local HTTP server (GET /api/kiwix flips available correctly) and confirmed the generated popup link matches the real geo-search query shape. docker-compose.yaml validated with `docker-compose config`. Full test suite: 118 runs, 0 failures.
This commit is contained in:
1 parent
7cd3171998
commit
24ac5931f8
13 files changed
+150
-9
No files matched your search
@@ -0,0 +1,21 @@
|
||||
require "net/http"
|
||||
|
||||
module Maptool
|
||||
# A thin reachability check for an external kiwix-serve instance serving
|
||||
# an offline Wikipedia ZIM (see docs/development.adoc for how to set one
|
||||
# up) — the app itself never talks to it beyond this ping. Linking a POI
|
||||
# popup to a geo search there (public/js/gpx.js) is a plain browser <a
|
||||
# href> straight to kiwix-serve, not something this server proxies —
|
||||
# kiwix-serve already has its own full search UI, no reason to rebuild it.
|
||||
module Kiwix
|
||||
def self.reachable?(url, open_timeout: 1, read_timeout: 2)
|
||||
return false if url.to_s.strip.empty?
|
||||
|
||||
uri = URI(url)
|
||||
Net::HTTP.start(uri.host, uri.port, open_timeout: open_timeout, read_timeout: read_timeout) { |http| http.head("/") }
|
||||
true
|
||||
rescue StandardError
|
||||
false
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user