Link POI popups to offline Wikipedia via kiwix-serve
CI / check (push) Successful in 40s
CI / deploy (push) Successful in 12s

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:
randy committed 2026-09-09 13:44:37 +02:00
1 parent 7cd3171998
commit 24ac5931f8
13 files changed
+150 -9

No files matched your search

+14
View File
@@ -10,6 +10,7 @@ require_relative "lib/maptool/gpx_store"
require_relative "lib/maptool/gpsd_client"
require_relative "lib/maptool/livetrack_store"
require_relative "lib/maptool/livetrack_client"
require_relative "lib/maptool/kiwix"
module Maptool
class App < Sinatra::Base
@@ -69,6 +70,12 @@ module Maptool
# OAuth2 secrets: fine outside production, nothing works without it set.
LIVETRACK_WEBHOOK_SECRET = ENV.fetch("LIVETRACK_WEBHOOK_SECRET", "")
# An external kiwix-serve instance (see docs/development.adoc), not
# something this app runs itself — blank disables the "Nearby on
# Wikipedia" popup link the same way the other optional-integration
# blanks above do.
KIWIX_URL = ENV.fetch("KIWIX_URL", "")
# Login delegates to the Gitea instance the user already has an account
# on, rather than maintaining a local username/password — see
# docs/architecture.adoc. Only users listed in ALLOWED_GITEA_USERS may
@@ -199,6 +206,13 @@ module Maptool
send_file TERRAIN_PMTILES_PATH, type: "application/octet-stream"
end
# Pinged once per page load (public/js/map.js) — url is handed back so
# the frontend can build the geo-search link itself; this server never
# proxies to kiwix-serve, just says whether it's there.
get "/api/kiwix" do
json available: Kiwix.reachable?(KIWIX_URL), url: KIWIX_URL
end
get "/api/gpx/tree" do
json GPX_STORE.tree
end