diff options
| author | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2026-10-27 19:13:03 +0100 |
|---|---|---|
| committer | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2026-10-27 19:13:03 +0100 |
| commit | 2df51e89039b9b160aafb52b700e874411eb0555 (patch) | |
| tree | ffed8ff63fb39a422f7d14d1c6da3e8281997631 /crates/wipfel/src/app.rs | |
| parent | 2d3cba97ff6ffbfe094ed0045329d875c6d1960b (diff) | |
wipfel: PWA — manifest, service worker, Web Share Target
- 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.
Diffstat (limited to 'crates/wipfel/src/app.rs')
| -rw-r--r-- | crates/wipfel/src/app.rs | 32 |
1 files changed, 32 insertions, 0 deletions
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(); |
