Apple PWA fixes

This commit is contained in:
Joey Kimsey
2025-02-07 16:14:00 -05:00
parent db58927df1
commit 7d2293208f
11 changed files with 84 additions and 35 deletions

1
.gitattributes vendored Normal file
View File

@ -0,0 +1 @@
* text=auto eol=lf

2
.gitignore vendored
View File

@ -65,4 +65,4 @@ vendor/canary/logs/*
components/* components/*
mailhog.log mailhog.log
uploads/* uploads/*
images/qr-codes/ images/qr-codes/*

View File

@ -8,8 +8,13 @@
* @link https://TheTempusProject.com * @link https://TheTempusProject.com
* @license https://opensource.org/licenses/MIT [MIT LICENSE] * @license https://opensource.org/licenses/MIT [MIT LICENSE]
*/ */
/**
* Progressive Web-App
**/
let deferredPrompt; let deferredPrompt;
const installPrompt = document.getElementById("install-prompt"); const installPrompt = document.getElementById("install-prompt");
const chromeMessage = document.getElementById("chrome-install-message");
const iosMessage = document.getElementById("ios-install-message");
const installButton = document.getElementById("install-button"); const installButton = document.getElementById("install-button");
const dismissButton = document.querySelector("#install-prompt .btn-close"); const dismissButton = document.querySelector("#install-prompt .btn-close");
@ -19,9 +24,27 @@ if (!localStorage.getItem("pwaInstallDismissed")) {
event.preventDefault(); event.preventDefault();
deferredPrompt = event; deferredPrompt = event;
installPrompt.classList.remove("d-none"); installPrompt.classList.remove("d-none");
installPrompt.classList.add("d-block"); // Show the prompt installPrompt.classList.add("d-block"); // Show the alert
chromeMessage.classList.remove("d-none");
chromeMessage.classList.add("d-block"); // Show the prompt
}); });
if ( isIos() && ! isInStandaloneMode() ) {
installPrompt.classList.remove("d-none");
installPrompt.classList.add("d-block"); // Show the alert
iosMessage.classList.remove("d-none");
iosMessage.classList.add("d-block"); // Show the prompt
} }
}
// ios REQUIRES a service worker
if ( 'serviceWorker' in navigator ) {
navigator.serviceWorker.register('app/js/sw.js')
.then(() => console.log('Service Worker Registered'));
}
// self.addEventListener('install', () => self.skipWaiting());
// self.addEventListener('activate', () => self.clients.claim());
// self.addEventListener('fetch', () => {}); // No file interception
// Handle Install Button Click // Handle Install Button Click
if ( installButton ) { if ( installButton ) {
@ -65,6 +88,14 @@ if (localStorage.getItem("pwaInstallDismissed")) {
} }
} }
function isIos() {
return /iphone|ipad|ipod/i.test(navigator.userAgent);
}
function isInStandaloneMode() {
return window.matchMedia('(display-mode: standalone)').matches || window.navigator.standalone;
}
/** /**
* Automatically selects/de-selects all check boxes associated with that field * Automatically selects/de-selects all check boxes associated with that field
**/ **/

1
app/js/sw.js Normal file
View File

@ -0,0 +1 @@
self.addEventListener('fetch', () => {});

View File

@ -59,7 +59,7 @@ class Sessions extends DatabaseModel {
public function checkSession( $sessionID ) { public function checkSession( $sessionID ) {
$user = new User; $user = new User;
// @todo lets put this on some sort of realistic checking regime other than check everything every time // @todo lets put this on some sort of realistic checking regime other than check everything every time
if ( $sessionID == false ) { if ( empty( $sessionID ) ) {
Debug::log( 'sessionID false' ); Debug::log( 'sessionID false' );
return false; return false;
} }

View File

@ -28,7 +28,12 @@
{AUTHOR} {AUTHOR}
{ROBOT} {ROBOT}
<link rel="icon" href="{ROOT_URL}images/favicon.ico" sizes="32x32"> <link rel="icon" href="{ROOT_URL}images/favicon.ico" sizes="32x32">
<!-- Apple PWA -->
<link rel="apple-touch-icon" href="{ROOT_URL}images/apple-touch-icon.png"><!-- 180×180 --> <link rel="apple-touch-icon" href="{ROOT_URL}images/apple-touch-icon.png"><!-- 180×180 -->
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="apple-mobile-web-app-title" content="{SITENAME}">
<!-- PWA -->
<link rel="manifest" href="{ROOT_URL}manifest.webmanifest"> <link rel="manifest" href="{ROOT_URL}manifest.webmanifest">
<!-- Required CSS --> <!-- Required CSS -->
<!-- <link rel="stylesheet" href="{FONT_AWESOME_URL}fontawesome.min.css" crossorigin="anonymous"> --> <!-- <link rel="stylesheet" href="{FONT_AWESOME_URL}fontawesome.min.css" crossorigin="anonymous"> -->

View File

@ -56,8 +56,8 @@
<div id="collapse3" class="accordion-collapse collapse" aria-labelledby="generalHeading3" data-bs-parent="#generalAccordion"> <div id="collapse3" class="accordion-collapse collapse" aria-labelledby="generalHeading3" data-bs-parent="#generalAccordion">
<div class="accordion-body context-main context-other-bg" id="general3"> <div class="accordion-body context-main context-other-bg" id="general3">
<span class="text-lead text-primary"> <span class="text-lead text-primary">
{SITENAME} is open source and available free of charge through <a href="{ROOT_URL}libraries/ttp/git" class="text-decoration-none">GitLab</a> and <a href="{ROOT_URL}libraries/ttp/packagist" class="text-decoration-none">Packagist</a>. {SITENAME} is open source and available free of charge through <a href="{ROOT_URL}libraries/ttp/git" class="text-decoration-none context-main">GitLab</a> and <a href="{ROOT_URL}libraries/ttp/packagist" class="text-decoration-none context-main">Packagist</a>.
The developer behind the project is <a href="https://joeykimsey.com/" class="text-decoration-none">Joey Kimsey</a> and he can be contacted through his website for development services. The developer behind the project is <a href="https://joeykimsey.com/" class="text-decoration-none context-main">Joey Kimsey</a> and he can be contacted through his website for development services.
</span> </span>
</div> </div>
</div> </div>

View File

@ -1,11 +1,18 @@
<div class="container pt-4 d-none" id="install-prompt"> <div class="container pt-4 d-none" id="install-prompt">
<div class="row"> <div class="row">
<div class="alert alert-success alert-dismissible w-100" role="alert"> <div class="alert alert-success alert-dismissible w-100 d-none" role="alert" id="chrome-install-message">
<div class="d-flex justify-content-between align-items-center"> <div class="d-flex justify-content-between align-items-center">
{SITENAME} is now available as a Progressive Web App, click the button to install now. {SITENAME} is now available as a Progressive Web App, click the button to install now.
<button class="btn btn-md btn-outline-primary mx-2" id="install-button">Install App</button> <button class="btn btn-md btn-outline-primary mx-2" id="install-button">Install App</button>
</div> </div>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button> <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div> </div>
<div class="alert alert-success alert-dismissible w-100 d-none" role="alert" id="ios-install-message">
<div class="d-flex justify-content-between align-items-center">
{SITENAME} is now available as a Progressive-Web-App, tap the share icon and then "Add to Home Screen".
</div>
<img src="/images/share-icon.png" class="iimg-fluid">
</div>
</div> </div>
</div> </div>

54
composer.lock generated
View File

@ -244,9 +244,9 @@
}, },
"require": { "require": {
"php": ">=8.1.0", "php": ">=8.1.0",
"thetempusproject/canary": "1.0.6", "thetempusproject/canary": "1.0.9",
"thetempusproject/hermes": "1.0.3", "thetempusproject/hermes": "1.0.5",
"thetempusproject/houdini": "2.0.2" "thetempusproject/houdini": "2.0.5"
}, },
"type": "library", "type": "library",
"autoload": { "autoload": {
@ -272,20 +272,22 @@
} }
], ],
"description": "Bedrock is intended as the core functionality used by The Tempus Project: a rapid prototyping framework. This library utilizes the MVC architecture in addition to a custom templating engine designed to make building web applications simple.", "description": "Bedrock is intended as the core functionality used by The Tempus Project: a rapid prototyping framework. This library utilizes the MVC architecture in addition to a custom templating engine designed to make building web applications simple.",
"homepage": "https://git.thetempusproject.com/the-tempus-project/bedrock", "homepage": "https://thetempusproject.com/libraries/bedrock",
"keywords": [ "keywords": [
"framework", "framework",
"mvc" "mvc",
"php",
"thetempusproject"
], ],
"time": "2025-02-06T03:02:46+00:00" "time": "2025-02-06T03:02:46+00:00"
}, },
{ {
"name": "thetempusproject/canary", "name": "thetempusproject/canary",
"version": "1.0.6", "version": "1.0.9",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://git.thetempusproject.com/the-tempus-project/canary", "url": "https://git.thetempusproject.com/the-tempus-project/canary",
"reference": "44b2ad688cff933964ec2ff50b408d94c7f51e40" "reference": "77cef522e9919573836901eb82b59b20f453fb61"
}, },
"require": { "require": {
"php": ">=8.1.0" "php": ">=8.1.0"
@ -313,22 +315,23 @@
} }
], ],
"description": "Functionality for tracking, logging, and sending log messages to chrome for debugging.", "description": "Functionality for tracking, logging, and sending log messages to chrome for debugging.",
"homepage": "https://git.thetempusproject.com/the-tempus-project/canary", "homepage": "https://thetempusproject.com/libraries/canary",
"keywords": [ "keywords": [
"debugging", "debugging",
"logging",
"php", "php",
"thetempusproject", "thetempusproject",
"tools" "tools"
], ],
"time": "2025-01-22T01:39:34+00:00" "time": "2025-02-04T12:16:29+00:00"
}, },
{ {
"name": "thetempusproject/hermes", "name": "thetempusproject/hermes",
"version": "1.0.3", "version": "1.0.5",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://git.thetempusproject.com/the-tempus-project/hermes", "url": "https://git.thetempusproject.com/the-tempus-project/hermes",
"reference": "4b4e06a98f0f01695bda18de240bb3294d096ef4" "reference": "802581b1d2d70877ccc75d8954b33efcc05d9371"
}, },
"require": { "require": {
"php": ">=8.1.0" "php": ">=8.1.0"
@ -355,28 +358,29 @@
"role": "Lead Developer" "role": "Lead Developer"
} }
], ],
"description": "Php functions that aid in routing and redirecting; requests and responses.", "description": "This library handles redirects, provides a common backbone for routing, and can handle autoloading in cases where composer is unavailable.",
"homepage": "https://git.thetempusproject.com/the-tempus-project/hermes", "homepage": "https://thetempusproject.com/libraries/hermes",
"keywords": [ "keywords": [
"autoloader",
"php", "php",
"routing", "routing",
"thetempusproject", "thetempusproject",
"tools" "tools"
], ],
"time": "2025-01-22T01:43:15+00:00" "time": "2025-02-02T23:22:15+00:00"
}, },
{ {
"name": "thetempusproject/houdini", "name": "thetempusproject/houdini",
"version": "2.0.2", "version": "2.0.5",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://git.thetempusproject.com/the-tempus-project/houdini", "url": "https://git.thetempusproject.com/the-tempus-project/houdini",
"reference": "fb027a4ebc327e709ad3da29a4cf112894c2b7e6" "reference": "2c7538471ab1f900048ccdb2c71d6bf2bee975e0"
}, },
"require": { "require": {
"php": ">=8.1.0", "php": ">=8.1.0",
"thetempusproject/canary": "1.0.6", "thetempusproject/canary": "1.0.9",
"thetempusproject/hermes": "1.0.3" "thetempusproject/hermes": "1.0.5"
}, },
"type": "library", "type": "library",
"autoload": { "autoload": {
@ -399,15 +403,15 @@
"role": "Lead Developer" "role": "Lead Developer"
} }
], ],
"description": "Php functions that aid in creating, managing, and displaying frontend components.", "description": "This library handles creating, managing, and displaying frontend components.",
"homepage": "https://git.thetempusproject.com/the-tempus-project/houdini", "homepage": "https://thetempusproject.com/libraries/houdini",
"keywords": [ "keywords": [
"frontend", "frontend",
"php", "php",
"thetempusproject", "thetempusproject",
"tools" "tools"
], ],
"time": "2025-01-27T05:02:14+00:00" "time": "2025-02-04T12:19:25+00:00"
}, },
{ {
"name": "twbs/bootstrap", "name": "twbs/bootstrap",
@ -463,10 +467,10 @@
"packages-dev": [], "packages-dev": [],
"aliases": [], "aliases": [],
"minimum-stability": "dev", "minimum-stability": "dev",
"stability-flags": [], "stability-flags": {},
"prefer-stable": true, "prefer-stable": true,
"prefer-lowest": false, "prefer-lowest": false,
"platform": [], "platform": {},
"platform-dev": [], "platform-dev": {},
"plugin-api-version": "2.3.0" "plugin-api-version": "2.6.0"
} }

BIN
images/apple-touch-icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

BIN
images/share-icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB