feat: PWA (#15)

add for PWA capability
This commit is contained in:
2026-03-26 18:32:07 -04:00
parent 36f3ab3bd1
commit 5ac8736004
5 changed files with 100 additions and 0 deletions

9
public/.htaccess Normal file
View File

@@ -0,0 +1,9 @@
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
SetEnvIf X-Forwarded-Proto "https" HTTPS=on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 255 KiB

35
public/manifest.json Normal file
View File

@@ -0,0 +1,35 @@
{
"name": "Sermon Notes",
"short_name": "Sermon Notes",
"description": "A personal note-taking app for sermons with reference material",
"start_url": "/",
"display": "standalone",
"orientation": "landscape",
"background_color": "#ffffff",
"theme_color": "#000000",
"icons": [
{
"src": "/images/Notes-icon-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "/images/Notes-icon-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
],
"screenshots": [
{
"src": "/images/Notes-icon-512x512.png",
"sizes": "512x512",
"type": "image/png"
},
{
"src": "/images/Notes-icon-512x512.png",
"sizes": "512x512",
"type": "image/png",
"form_factor": "wide"
}
]
}

56
public/sw.js Normal file
View File

@@ -0,0 +1,56 @@
// public/sw.js
const CACHE_NAME = 'app-cache-v1';
const ASSETS_TO_CACHE = [
'/',
'/manifest.json',
// Add paths to your main CSS and JS files here
// e.g., '/build/app.css', '/build/app.js'
];
// Install Event: Cache core static assets
self.addEventListener('install', event => {
event.waitUntil(
caches.open(CACHE_NAME)
.then(cache => {
return cache.addAll(ASSETS_TO_CACHE);
})
);
self.skipWaiting();
});
// Activate Event: Clean up old caches if you change the CACHE_NAME version
self.addEventListener('activate', event => {
event.waitUntil(
caches.keys().then(cacheNames => {
return Promise.all(
cacheNames.map(cache => {
if (cache !== CACHE_NAME) {
return caches.delete(cache);
}
})
);
})
);
self.clients.claim();
});
// Fetch Event: Network First, Fallback to Cache
self.addEventListener('fetch', event => {
// Only cache GET requests
if (event.request.method !== 'GET') return;
event.respondWith(
fetch(event.request)
.then(networkResponse => {
// If the network request succeeds, clone it and put it in the cache
return caches.open(CACHE_NAME).then(cache => {
cache.put(event.request, networkResponse.clone());
return networkResponse;
});
})
.catch(() => {
// If the network fails (offline), try to serve from cache
return caches.match(event.request);
})
);
});