Make the server installable as a home-screen PWA
Adds a web manifest, hand-drawn cup+frame icons, and a presence-only service worker (no offline caching) so mobile browsers offer "Add to Home Screen" for the server UI.
This commit is contained in:
@@ -58,6 +58,15 @@
|
||||
}
|
||||
})();
|
||||
|
||||
// Registering this is what makes Chrome/Android offer the "Add to Home
|
||||
// screen" install prompt -- a manifest link alone isn't enough. Served
|
||||
// from /sw.js (not /static/sw.js) so its scope is the whole app.
|
||||
if ("serviceWorker" in navigator) {
|
||||
window.addEventListener("load", function () {
|
||||
navigator.serviceWorker.register("/sw.js");
|
||||
});
|
||||
}
|
||||
|
||||
// Shared display names for widget_type, everywhere one shows up in the
|
||||
// UI (Layout canvas, Add-a-widget buttons, button-assignment dropdowns).
|
||||
const WIDGET_LABELS = {
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 501 B |
Binary file not shown.
|
After Width: | Height: | Size: 1.3 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 4.1 KiB |
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "ESPresso Frame",
|
||||
"short_name": "ESPresso",
|
||||
"description": "Manage your e-ink photo frames.",
|
||||
"start_url": "/",
|
||||
"scope": "/",
|
||||
"display": "standalone",
|
||||
"background_color": "#f5f6f8",
|
||||
"theme_color": "#2563eb",
|
||||
"icons": [
|
||||
{ "src": "/static/icons/icon-192.png", "sizes": "192x192", "type": "image/png" },
|
||||
{ "src": "/static/icons/icon-512.png", "sizes": "512x512", "type": "image/png" }
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// Presence-only service worker: satisfies the "installable" requirement
|
||||
// (Chrome/Android in particular checks for a controlling SW with a fetch
|
||||
// handler) without adding an offline cache -- every request just goes to
|
||||
// the network as normal. Served from / (see app/main.py's /sw.js route)
|
||||
// so its scope covers the whole app, not just /static/.
|
||||
self.addEventListener("install", () => self.skipWaiting());
|
||||
self.addEventListener("activate", (event) => event.waitUntil(self.clients.claim()));
|
||||
self.addEventListener("fetch", (event) => event.respondWith(fetch(event.request)));
|
||||
Reference in New Issue
Block a user