fix: recover old GTIN service worker caches
This commit is contained in:
@@ -92,12 +92,13 @@ fi
|
||||
printf '\n== routes\n'
|
||||
for route in / /fotografie/ /businessfotografie/ /portrait-und-model/ /familie/ \
|
||||
/minishootings/ /video/ /musik-und-buehne/ /social-media/ /projekte/ /ueber/ /kontakt/ /impressum/ /datenschutz/ \
|
||||
/gtin/ /gtin/impressum/ /gtin/datenschutz/; do
|
||||
/gtin/ /gtin/impressum/ /gtin/datenschutz/ /gtin/aktualisieren/; do
|
||||
check_status "$base$route" 200
|
||||
done
|
||||
check_redirect "$base/gtin" "$base/gtin/"
|
||||
check_redirect "$base/gtin/impressum" "$base/gtin/impressum/"
|
||||
check_redirect "$base/gtin/datenschutz" "$base/gtin/datenschutz/"
|
||||
check_redirect "$base/gtin/aktualisieren" "$base/gtin/aktualisieren/"
|
||||
|
||||
# The retired photo URL must keep working: it is the umbrella page now.
|
||||
check_redirect "$base/shootings" "$base/fotografie/"
|
||||
@@ -156,6 +157,8 @@ check_contains "$base/gtin/datenschutz/" "Cache API"
|
||||
check_contains "$base/gtin/datenschutz/" "nicht an einen Server übertragen"
|
||||
check_contains "$base/gtin/datenschutz/" 'name="robots" content="noindex, nofollow"'
|
||||
check_contains "$base/gtin/impressum/" 'name="robots" content="noindex, nofollow"'
|
||||
check_contains "$base/gtin/aktualisieren/" 'name="robots" content="noindex, nofollow"'
|
||||
check_status "$base/gtin/js/aktualisieren.js" 200
|
||||
for route in / /fotografie/ /businessfotografie/ /portrait-und-model/ /familie/ \
|
||||
/minishootings/ /video/ /musik-und-buehne/ /social-media/ /projekte/ /ueber/ \
|
||||
/kontakt/ /impressum/ /datenschutz/; do
|
||||
|
||||
@@ -95,7 +95,8 @@ them is a defect, not a style question:
|
||||
to a server. Its `/gtin/impressum/` and `/gtin/datenschutz/` pages are
|
||||
standalone, unlisted legal pages. The tool stays unlisted: no main-site
|
||||
navigation or page links, no sitemap entry, and `noindex,nofollow`; only the
|
||||
tool links to its own legal pages, which never link back to the main site;
|
||||
GTIN area links to its own legal pages, which never link back to the main site.
|
||||
The unlisted `/gtin/aktualisieren/` page repairs old redirected app caches;
|
||||
- `access_log off` in `nginx.conf` — never enable request logging;
|
||||
- `error_log /dev/null crit;` in `nginx.conf` — never write an error-log file either;
|
||||
- fonts, scripts, styles and images are served from this origin only;
|
||||
|
||||
@@ -71,6 +71,8 @@ Werkzeug selbst verlinkt auf seine eigenständigen Rechtstexte unter `/gtin/impr
|
||||
`/gtin/` ohne Weiterleitung; jede Änderung am Werkzeug erhält eine neue
|
||||
Cache-Version. Die eigenständige Datenschutzerklärung liegt unter
|
||||
`/gtin/datenschutz/`; die Rechtstexte sind nicht mit denen des Hauptauftritts verknüpft.
|
||||
Der unverlinkte Pfad `/gtin/aktualisieren/` entfernt eine fehlerhafte
|
||||
Startantwort aus älteren Browser-Caches und öffnet das Werkzeug danach erneut.
|
||||
|
||||
## Herkunft der Inhalte
|
||||
|
||||
|
||||
@@ -67,6 +67,7 @@ server {
|
||||
location = /gtin { return 301 /gtin/; }
|
||||
location = /gtin/impressum { return 301 /gtin/impressum/; }
|
||||
location = /gtin/datenschutz { return 301 /gtin/datenschutz/; }
|
||||
location = /gtin/aktualisieren { return 301 /gtin/aktualisieren/; }
|
||||
location = /gtin/manifest.webmanifest {
|
||||
default_type application/manifest+json;
|
||||
try_files $uri =404;
|
||||
|
||||
@@ -45,6 +45,7 @@ UNLISTED_HTML = [
|
||||
"gtin/index.html",
|
||||
"gtin/impressum/index.html",
|
||||
"gtin/datenschutz/index.html",
|
||||
"gtin/aktualisieren/index.html",
|
||||
]
|
||||
|
||||
INK = (23, 20, 15)
|
||||
|
||||
31
site/gtin/aktualisieren/index.html
Normal file
31
site/gtin/aktualisieren/index.html
Normal file
@@ -0,0 +1,31 @@
|
||||
<!doctype html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>GTIN aktualisieren</title>
|
||||
<meta name="robots" content="noindex, nofollow" />
|
||||
<link rel="canonical" href="https://desfoto.de/gtin/aktualisieren/" />
|
||||
<link rel="icon" href="/gtin/icons/favicon.svg" type="image/svg+xml" />
|
||||
<style>
|
||||
:root { color-scheme: light; font: 16px/1.65 system-ui, sans-serif; color: #202124; background: #fff; }
|
||||
body { box-sizing: border-box; max-width: 42rem; margin: 0 auto; padding: 2.5rem 1.25rem; }
|
||||
h1 { margin: 0 0 1.5rem; font-size: clamp(2rem, 7vw, 3rem); line-height: 1.1; }
|
||||
a { color: #174ea6; }
|
||||
footer { margin-top: 3rem; padding-top: 1rem; border-top: 1px solid #ddd; }
|
||||
footer a + a { margin-left: 1rem; }
|
||||
</style>
|
||||
<script src="/gtin/js/aktualisieren.js" defer></script>
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<h1>GTIN aktualisieren</h1>
|
||||
<p id="status" role="status">Das Werkzeug wird aktualisiert. Du wirst gleich weitergeleitet.</p>
|
||||
<p><a href="/gtin/">GTIN-Werkzeug öffnen</a></p>
|
||||
</main>
|
||||
<footer>
|
||||
<a href="/gtin/impressum/">Impressum</a>
|
||||
<a href="/gtin/datenschutz/">Datenschutz</a>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
33
site/gtin/js/aktualisieren.js
Normal file
33
site/gtin/js/aktualisieren.js
Normal file
@@ -0,0 +1,33 @@
|
||||
/* Entfernt die umgeleitete Startantwort aus frueheren GTIN-Caches. */
|
||||
|
||||
const status = document.querySelector('#status');
|
||||
const appUrl = new URL('../', window.location.href);
|
||||
const alterIndex = new URL('index.html', appUrl).href;
|
||||
|
||||
async function aktualisiereWerkzeug() {
|
||||
if ('caches' in window) {
|
||||
const namen = await caches.keys();
|
||||
for (const name of namen) {
|
||||
if (!name.startsWith('desfoto-gtin-generator-')) continue;
|
||||
const cache = await caches.open(name);
|
||||
const antwort = await cache.match(alterIndex);
|
||||
if (antwort?.redirected) await cache.delete(alterIndex);
|
||||
}
|
||||
}
|
||||
|
||||
if ('serviceWorker' in navigator) {
|
||||
const registrierung = await navigator.serviceWorker.getRegistration(appUrl.href);
|
||||
if (registrierung) {
|
||||
await Promise.race([
|
||||
registrierung.update().catch(() => undefined),
|
||||
new Promise((resolve) => window.setTimeout(resolve, 5000)),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
window.location.replace(appUrl.href);
|
||||
}
|
||||
|
||||
aktualisiereWerkzeug().catch(() => {
|
||||
status.textContent = 'Die Aktualisierung ist fehlgeschlagen. Bitte lösche die Website-Daten für desfoto.de in deinem Browser und öffne das Werkzeug erneut.';
|
||||
});
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
const sw = /** @type {ServiceWorkerGlobalScope} */ (/** @type {unknown} */ (self));
|
||||
|
||||
const CACHE_VERSION = '403b5842d1cd';
|
||||
const CACHE_VERSION = '76462b4916fd';
|
||||
const CACHE_PREFIX = 'desfoto-gtin-generator-';
|
||||
const CACHE_NAME = `${CACHE_PREFIX}${CACHE_VERSION}`;
|
||||
|
||||
|
||||
31
src/gtin/aktualisieren/index.html
Normal file
31
src/gtin/aktualisieren/index.html
Normal file
@@ -0,0 +1,31 @@
|
||||
<!doctype html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>GTIN aktualisieren</title>
|
||||
<meta name="robots" content="noindex, nofollow" />
|
||||
<link rel="canonical" href="https://desfoto.de/gtin/aktualisieren/" />
|
||||
<link rel="icon" href="/gtin/icons/favicon.svg" type="image/svg+xml" />
|
||||
<style>
|
||||
:root { color-scheme: light; font: 16px/1.65 system-ui, sans-serif; color: #202124; background: #fff; }
|
||||
body { box-sizing: border-box; max-width: 42rem; margin: 0 auto; padding: 2.5rem 1.25rem; }
|
||||
h1 { margin: 0 0 1.5rem; font-size: clamp(2rem, 7vw, 3rem); line-height: 1.1; }
|
||||
a { color: #174ea6; }
|
||||
footer { margin-top: 3rem; padding-top: 1rem; border-top: 1px solid #ddd; }
|
||||
footer a + a { margin-left: 1rem; }
|
||||
</style>
|
||||
<script src="/gtin/js/aktualisieren.js" defer></script>
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<h1>GTIN aktualisieren</h1>
|
||||
<p id="status" role="status">Das Werkzeug wird aktualisiert. Du wirst gleich weitergeleitet.</p>
|
||||
<p><a href="/gtin/">GTIN-Werkzeug öffnen</a></p>
|
||||
</main>
|
||||
<footer>
|
||||
<a href="/gtin/impressum/">Impressum</a>
|
||||
<a href="/gtin/datenschutz/">Datenschutz</a>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
33
src/gtin/js/aktualisieren.js
Normal file
33
src/gtin/js/aktualisieren.js
Normal file
@@ -0,0 +1,33 @@
|
||||
/* Entfernt die umgeleitete Startantwort aus frueheren GTIN-Caches. */
|
||||
|
||||
const status = document.querySelector('#status');
|
||||
const appUrl = new URL('../', window.location.href);
|
||||
const alterIndex = new URL('index.html', appUrl).href;
|
||||
|
||||
async function aktualisiereWerkzeug() {
|
||||
if ('caches' in window) {
|
||||
const namen = await caches.keys();
|
||||
for (const name of namen) {
|
||||
if (!name.startsWith('desfoto-gtin-generator-')) continue;
|
||||
const cache = await caches.open(name);
|
||||
const antwort = await cache.match(alterIndex);
|
||||
if (antwort?.redirected) await cache.delete(alterIndex);
|
||||
}
|
||||
}
|
||||
|
||||
if ('serviceWorker' in navigator) {
|
||||
const registrierung = await navigator.serviceWorker.getRegistration(appUrl.href);
|
||||
if (registrierung) {
|
||||
await Promise.race([
|
||||
registrierung.update().catch(() => undefined),
|
||||
new Promise((resolve) => window.setTimeout(resolve, 5000)),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
window.location.replace(appUrl.href);
|
||||
}
|
||||
|
||||
aktualisiereWerkzeug().catch(() => {
|
||||
status.textContent = 'Die Aktualisierung ist fehlgeschlagen. Bitte lösche die Website-Daten für desfoto.de in deinem Browser und öffne das Werkzeug erneut.';
|
||||
});
|
||||
@@ -56,6 +56,7 @@ class BuildLayout(unittest.TestCase):
|
||||
"gtin/index.html",
|
||||
"gtin/impressum/index.html",
|
||||
"gtin/datenschutz/index.html",
|
||||
"gtin/aktualisieren/index.html",
|
||||
}
|
||||
actual = {str(f.relative_to(SITE)) for f in SITE.rglob("*.html")}
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
Reference in New Issue
Block a user