Installable PWA with a share target; design for an item-based library
Android's share sheet (OsmAnd, Locus, mapy.com, ...) can now send GPX/FIT/GeoJSON/ZIP files to the installed app: the service worker parks them and the page offers to import them into a Tracks & Points folder, waiting through a login if needed. Manifest, app icon, a server-side fallback for /share-target. docs/library-design.adoc proposes replacing the file-based GpxStore with folders and items (stable ids, timestamps, tombstones, a change feed) as the base for syncing with OsmAnd and Locus.
This commit is contained in:
1 parent
e2461f794c
commit
25b87b94fe
14 files changed
+637
-5
No files matched your search
@@ -52,6 +52,9 @@ module Maptool
|
||||
|
||||
class App < Sinatra::Base
|
||||
set :public_folder, File.join(__dir__, "public")
|
||||
# The PWA manifest (public/manifest.webmanifest) — Rack doesn't know
|
||||
# this extension and would serve it as application/octet-stream.
|
||||
mime_type :webmanifest, "application/manifest+json"
|
||||
set :views, File.join(__dir__, "views")
|
||||
|
||||
# sinatra/json defaults to MultiJson, whose `encode` (what
|
||||
@@ -250,6 +253,14 @@ module Maptool
|
||||
erb :index, locals: { logged_in: logged_in?, user: session[:user], revision: REVISION }
|
||||
end
|
||||
|
||||
# A share to the installed app normally never reaches the server: the
|
||||
# service worker (public/sw.js) takes the POST, parks the files and
|
||||
# opens the app. Only lands here if no worker is running yet — back to
|
||||
# the map rather than a 404, the share just has to be repeated.
|
||||
post "/share-target" do
|
||||
redirect "/", 303
|
||||
end
|
||||
|
||||
get "/api/health" do
|
||||
json status: "ok", revision: REVISION
|
||||
end
|
||||
|
||||
Reference in new issue
Block a user