diff --git a/docker_entrypoint.sh b/docker_entrypoint.sh index ab0079e..7845dff 100755 --- a/docker_entrypoint.sh +++ b/docker_entrypoint.sh @@ -63,6 +63,101 @@ server { ' echo "$NGINX_CONF" > $CONF_FILE +cd /usr/share/nginx/html +cat <service-worker.js +// Define the cache name for versioning +const CACHE_NAME = 'primal-pwa-cache-v1'; + +// Specify the assets to cache +const ASSETS_TO_CACHE = [ + '/', + '/index.html', + '/$(ls assets/index-*.js)', + '/$(ls assets/index-*.css)', + '/$(ls assets/favicon-*.ico)', + '/public/fonts.css', + // Add all other assets like images, fonts from the public directory + '/public/Nacelle/Nacelle-Regular.otf', + '/public/RobotoCondensed/RobotoCondensed-Regular.ttf', + // ... other font files and assets +]; + +self.addEventListener('install', event => { + event.waitUntil( + caches.open(CACHE_NAME) + .then(cache => cache.addAll(ASSETS_TO_CACHE)) + ); +}); + +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.addEventListener('fetch', event => { + event.respondWith( + caches.match(event.request) + .then(response => { + // Serve from cache if available, otherwise fetch from network + return response || fetch(event.request); + }) + ); +}); +EOF + +cat << EOF >manifest.json +{ + "name": "Primal", + "short_name": "Primal", + "icons": [ + { + "src": "public/primal-logo-large.png", + "sizes": "512x512", + "type": "image/png" + } + ], + "start_url": ".", + "display": "fullscreen", + "orientation": "portrait" +} +EOF + +HTML_FILE="/usr/share/nginx/html/index.html" + +# Define the line to insert after +INSERT_AFTER='<\/title>' + +# Define the manifest code to insert +INSERT_CODE=' ' + +# Use sed to insert the code +sed -i "s|$INSERT_AFTER|$INSERT_AFTER\n$INSERT_CODE|" $HTML_FILE + +# Define the worker code to be injected +CODE=' ' + +# Use awk to inject the worker code after the specified line +awk -v code="$CODE" '/lottie-player.js"><\/script>/ { print; print code; next }1' $HTML_FILE > temp.html && mv temp.html $HTML_FILE + _term() { echo "Caught SIGTERM signal!" kill -SIGTERM "$primal_process" 2>/dev/null diff --git a/instructions.md b/instructions.md index 4fc164f..8b636fe 100644 --- a/instructions.md +++ b/instructions.md @@ -6,5 +6,6 @@ 4. Choose to **Create Account** or if you already have a Nostr account, click **Login**. 5. Follow the onscreen instructions. -Now, you're all set to explore the Nostr world in a sovereign fashion. -Enjoy! 😊 +**Note:** While it's possible to use the Primal web app on your mobile device, we currently recommend using the dedicated mobile app for Android and iOS for a better user experience. + +Enjoy exploring the Nostr world in a sovereign fashion! 😊