Make the app installable on mobile (PWA manifest, icons, offline service worker)
This commit is contained in:
1 parent
b6a74f2eee
commit
95dbfc0678
9 files changed
+89
-2
No files matched your search
+2
-1
@@ -1,6 +1,7 @@
|
|||||||
FROM nginx:1.27-alpine
|
FROM nginx:1.27-alpine
|
||||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||||
COPY faelle.html /usr/share/nginx/html/index.html
|
COPY faelle.html /usr/share/nginx/html/index.html
|
||||||
COPY faelle.html /usr/share/nginx/html/faelle.html
|
COPY faelle.html manifest.webmanifest sw.js /usr/share/nginx/html/
|
||||||
|
COPY icons /usr/share/nginx/html/icons
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
HEALTHCHECK --interval=30s --timeout=3s CMD wget -qO- http://127.0.0.1/ >/dev/null || exit 1
|
HEALTHCHECK --interval=30s --timeout=3s CMD wget -qO- http://127.0.0.1/ >/dev/null || exit 1
|
||||||
+13
@@ -66,6 +66,14 @@ td.n{color:var(--mu)}td.t{font-weight:700;font-size:20px;color:var(--c)}
|
|||||||
.stats b{display:block;font-family:'Fredoka',sans-serif;font-size:26px}
|
.stats b{display:block;font-family:'Fredoka',sans-serif;font-size:26px}
|
||||||
@media (prefers-reduced-motion:reduce){*{transition:none!important}}
|
@media (prefers-reduced-motion:reduce){*{transition:none!important}}
|
||||||
</style>
|
</style>
|
||||||
|
<link rel="manifest" href="/manifest.webmanifest">
|
||||||
|
<meta name="theme-color" content="#8B6CFF">
|
||||||
|
<link rel="icon" type="image/png" sizes="192x192" href="/icons/icon-192.png">
|
||||||
|
<link rel="apple-touch-icon" href="/icons/apple-touch-icon.png">
|
||||||
|
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||||
|
<meta name="mobile-web-app-capable" content="yes">
|
||||||
|
<meta name="apple-mobile-web-app-title" content="Fälle">
|
||||||
|
<meta name="apple-mobile-web-app-status-bar-style" content="default">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="app" id="app"></div>
|
<div class="app" id="app"></div>
|
||||||
@@ -227,5 +235,10 @@ function quiz(k){
|
|||||||
}
|
}
|
||||||
home();
|
home();
|
||||||
</script>
|
</script>
|
||||||
|
<script>
|
||||||
|
if ('serviceWorker' in navigator) {
|
||||||
|
window.addEventListener('load', function () { navigator.serviceWorker.register('/sw.js').catch(function () {}); });
|
||||||
|
}
|
||||||
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 2.0 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.5 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 7.2 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 5.5 KiB |
@@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"name": "Fälle – Akkusativ, Dativ, Genitiv",
|
||||||
|
"short_name": "Fälle",
|
||||||
|
"description": "تعلّم Akkusativ, Dativ, Genitiv بالألوان، خطوة بخطوة.",
|
||||||
|
"lang": "ar",
|
||||||
|
"dir": "rtl",
|
||||||
|
"id": "/",
|
||||||
|
"start_url": "/",
|
||||||
|
"scope": "/",
|
||||||
|
"display": "standalone",
|
||||||
|
"orientation": "portrait",
|
||||||
|
"background_color": "#F5F3FF",
|
||||||
|
"theme_color": "#8B6CFF",
|
||||||
|
"icons": [
|
||||||
|
{ "src": "/icons/icon-192.png", "sizes": "192x192", "type": "image/png", "purpose": "any" },
|
||||||
|
{ "src": "/icons/icon-512.png", "sizes": "512x512", "type": "image/png", "purpose": "any" },
|
||||||
|
{ "src": "/icons/icon-maskable-512.png", "sizes": "512x512", "type": "image/png", "purpose": "maskable" }
|
||||||
|
]
|
||||||
|
}
|
||||||
+15
-1
@@ -6,7 +6,21 @@ server {
|
|||||||
|
|
||||||
charset utf-8;
|
charset utf-8;
|
||||||
gzip on;
|
gzip on;
|
||||||
gzip_types text/html text/css application/javascript;
|
gzip_types text/html text/css application/javascript application/manifest+json;
|
||||||
|
|
||||||
|
location = /manifest.webmanifest {
|
||||||
|
default_type application/manifest+json;
|
||||||
|
add_header Cache-Control "no-cache";
|
||||||
|
}
|
||||||
|
|
||||||
|
location = /sw.js {
|
||||||
|
add_header Cache-Control "no-cache";
|
||||||
|
add_header Service-Worker-Allowed "/";
|
||||||
|
}
|
||||||
|
|
||||||
|
location /icons/ {
|
||||||
|
add_header Cache-Control "public, max-age=604800";
|
||||||
|
}
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
try_files $uri $uri/ /index.html;
|
try_files $uri $uri/ /index.html;
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
const CACHE = 'faelle-v1';
|
||||||
|
const SHELL = ['/', '/manifest.webmanifest', '/icons/icon-192.png', '/icons/icon-512.png'];
|
||||||
|
|
||||||
|
self.addEventListener('install', (e) => {
|
||||||
|
e.waitUntil(caches.open(CACHE).then((c) => c.addAll(SHELL)).then(() => self.skipWaiting()));
|
||||||
|
});
|
||||||
|
|
||||||
|
self.addEventListener('activate', (e) => {
|
||||||
|
e.waitUntil(
|
||||||
|
caches.keys()
|
||||||
|
.then((keys) => Promise.all(keys.filter((k) => k !== CACHE).map((k) => caches.delete(k))))
|
||||||
|
.then(() => self.clients.claim())
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
self.addEventListener('fetch', (e) => {
|
||||||
|
const req = e.request;
|
||||||
|
if (req.method !== 'GET') return;
|
||||||
|
|
||||||
|
// Pages: network first so updates show up, cache as offline fallback.
|
||||||
|
if (req.mode === 'navigate') {
|
||||||
|
e.respondWith(
|
||||||
|
fetch(req)
|
||||||
|
.then((res) => { const copy = res.clone(); caches.open(CACHE).then((c) => c.put('/', copy)); return res; })
|
||||||
|
.catch(() => caches.match('/'))
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Everything else (icons, Google Fonts): cache first, fill cache on miss.
|
||||||
|
e.respondWith(
|
||||||
|
caches.match(req).then((hit) => hit || fetch(req).then((res) => {
|
||||||
|
if (res.ok || res.type === 'opaque') {
|
||||||
|
const copy = res.clone();
|
||||||
|
caches.open(CACHE).then((c) => c.put(req, copy));
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}))
|
||||||
|
);
|
||||||
|
});
|
||||||
Reference in new issue
Block a user