From 2df51e89039b9b160aafb52b700e874411eb0555 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Tue, 27 Oct 2026 19:13:03 +0100 Subject: wipfel: PWA — manifest, service worker, Web Share Target MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - manifest.webmanifest: standalone, dark theme, mountain icons (regular + maskable) - sw.js: network-first with cache fallback -> full offline after first visit (wasm + hill DB included); versioned cache, stale caches pruned - share_target: images shared to the installed app are POSTed to __share; the SW stashes the bytes at __shared and redirects with ?shared=1; the app picks them up on startup and cleans the URL - index.html: manifest link, theme-color, icons, SW registration - build/serve scripts ship the new files; dist refreshed Note: sharing does not bypass AOSP GPS redaction when the share source passes a MediaStore URI (the browser is still the reader) — the .nomedia/rename trick remains the way to get GPS EXIF into a browser. --- crates/wipfel/src/app.rs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'crates/wipfel/src') diff --git a/crates/wipfel/src/app.rs b/crates/wipfel/src/app.rs index 78961fc..441f17c 100644 --- a/crates/wipfel/src/app.rs +++ b/crates/wipfel/src/app.rs @@ -11,6 +11,7 @@ use gipfel_core::metadata::{apply_image_metadata, ImageMetaData}; use gipfel_core::panorama::Panorama; use wasm_bindgen::closure::Closure; use wasm_bindgen::JsCast; +use wasm_bindgen::JsValue; use wasm_bindgen_futures::spawn_local; use web_sys::{DragEvent, Event, HtmlCanvasElement, HtmlInputElement, InputEvent, MouseEvent}; use yew::prelude::*; @@ -450,6 +451,37 @@ pub fn app() -> Html { }) }; + // Web Share Target handoff: the service worker stashes the shared + // file at `__shared` and redirects here with ?shared=1 + { + let load_bytes = load_bytes.clone(); + let status = status.clone(); + use_effect_with((), move |_| { + let shared = web_sys::window() + .map(|w| { + w.location() + .search() + .map(|s| s.contains("shared=1")) + .unwrap_or(false) + }) + .unwrap_or(false); + if shared { + spawn_local(async move { + match bridge::fetch_bytes("__shared").await { + Ok(bytes) => load_bytes.emit((bytes, "shared image".into())), + Err(e) => status.set(format!("shared image missing: {e}")), + } + }); + if let Some(w) = web_sys::window() { + let _ = w + .history() + .and_then(|h| h.replace_state_with_url(&JsValue::NULL, "", Some("./"))); + } + } + || () + }); + } + let on_drop = { let read_file = read_file.clone(); let status = status.clone(); -- cgit v1.2.3