summaryrefslogtreecommitdiff
path: root/static
diff options
context:
space:
mode:
authorBobby <[email protected]>2026-02-11 12:48:01 +0530
committerBobby <[email protected]>2026-02-11 12:48:01 +0530
commit2c567dd96712a887b42cf4df3bdaa9f5f2b51a43 (patch)
tree82c408110dff2898e64688111b08c1d79043d247 /static
parent519a4a81bc3ae4738835a1fcb7cfaf72a06bf13b (diff)
downloadcafe-2c567dd96712a887b42cf4df3bdaa9f5f2b51a43.tar.xz
cafe-2c567dd96712a887b42cf4df3bdaa9f5f2b51a43.zip
Refactor homepage and error templates, add service worker and manifest for PWA support
Diffstat (limited to 'static')
-rw-r--r--static/js/app.js23
-rw-r--r--static/js/worker.js22
-rw-r--r--static/manifest.json24
3 files changed, 69 insertions, 0 deletions
diff --git a/static/js/app.js b/static/js/app.js
new file mode 100644
index 0000000..f1ec61e
--- /dev/null
+++ b/static/js/app.js
@@ -0,0 +1,23 @@
+if ('serviceWorker' in navigator) {
+ window.addEventListener('load', () => {
+ navigator.serviceWorker.register('/worker.js')
+ .then(registration => {
+ console.log('ServiceWorker registered:', registration);
+ })
+ .catch(error => {
+ console.log('ServiceWorker registration failed:', error);
+ });
+ });
+}
+
+let deferredPrompt;
+window.addEventListener('beforeinstallprompt', (e) => {
+ e.preventDefault();
+ deferredPrompt = e;
+});
+
+document.body.addEventListener('htmx:afterSwap', (event) => {
+ event.detail.elt.querySelectorAll('.animate-slide-up').forEach((el, i) => {
+ el.style.animationDelay = `${i * 0.1}s`;
+ });
+}); \ No newline at end of file
diff --git a/static/js/worker.js b/static/js/worker.js
new file mode 100644
index 0000000..84d94df
--- /dev/null
+++ b/static/js/worker.js
@@ -0,0 +1,22 @@
+const CACHE_NAME = 'cafe';
+const urlsToCache = [
+ '/',
+ '/static/css/style.css',
+ '/static/js/htmx.min.js',
+ '/static/js/app.js',
+ '/static/manifest.json'
+];
+
+self.addEventListener('install', (event) => {
+ event.waitUntil(
+ caches.open(CACHE_NAME)
+ .then((cache) => cache.addAll(urlsToCache))
+ );
+});
+
+self.addEventListener('fetch', (event) => {
+ event.respondWith(
+ caches.match(event.request)
+ .then((response) => response || fetch(event.request))
+ );
+}); \ No newline at end of file
diff --git a/static/manifest.json b/static/manifest.json
new file mode 100644
index 0000000..1bca313
--- /dev/null
+++ b/static/manifest.json
@@ -0,0 +1,24 @@
+{
+ "name": "Shifoo's Cafe",
+ "short_name": "Cafe",
+ "description": "A cozy place for close friends!",
+ "start_url": "/",
+ "display": "standalone",
+ "background_color": "#0a0a0f",
+ "theme_color": "#1a1a2e",
+ "orientation": "portrait-primary",
+ "icons": [
+ {
+ "src": "/static/icons/icon-192.png",
+ "sizes": "192x192",
+ "type": "image/png",
+ "purpose": "any maskable"
+ },
+ {
+ "src": "/static/icons/icon-512.png",
+ "sizes": "512x512",
+ "type": "image/png",
+ "purpose": "any maskable"
+ }
+ ]
+} \ No newline at end of file