Skip to content

Commit

Permalink
changed: updated for Elgg 6
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalsem committed Jun 4, 2024
1 parent da83b3a commit eb99a0a
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 51 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ name: PHPUnit Plugin Tests
on: [push, pull_request]

jobs:
lint:
phpunit:
name: Run PHPUnit test suites
uses: ColdTrick/.github/.github/workflows/phpunit.yml@master
with:
elgg_major_version: 6
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Progressive Web App

![Elgg 5.0](https://img.shields.io/badge/Elgg-5.0-green.svg)
![Elgg 6.0](https://img.shields.io/badge/Elgg-6.0-green.svg)
![Lint Checks](https://github.com/ColdTrick/pwa/actions/workflows/lint.yml/badge.svg?event=push)
[![Latest Stable Version](https://poser.pugx.org/coldtrick/pwa/v/stable.svg)](https://packagist.org/packages/coldtrick/pwa)
[![License](https://poser.pugx.org/coldtrick/pwa/license.svg)](https://packagist.org/packages/coldtrick/pwa)
Expand Down
11 changes: 2 additions & 9 deletions classes/ColdTrick/PWA/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,12 @@
class Bootstrap extends DefaultPluginBootstrap {

/**
* {@inheritDoc}
* {@inheritdoc}
*/
public function init() {
elgg_register_external_file('js', 'upup', elgg_get_simplecache_url('pwa/upup/upup.js'));
elgg_load_external_file('js', 'upup');

elgg_register_simplecache_view('page/elements/offline.css');
elgg_register_simplecache_view('pwa/upup/upup.sw.js');
elgg_register_simplecache_view('resources/pwa/offline.html');

elgg_define_js('pwa/installable', [
'src' => elgg_get_simplecache_url('pwa/installable.js'),
]);
elgg_require_js('pwa/installable');
elgg_import_esm('pwa/installable');
}
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"npm-asset/upup": "~1.1.0"
},
"conflict": {
"elgg/elgg": "<5.0"
"elgg/elgg": "<6.0"
},
"config": {
"process-timeout": 0,
Expand Down
2 changes: 1 addition & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions elgg-plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,10 @@
'pwa/upup.config.js' => [],
],
],
'view_options' => [
'page/elements/offline.css' => ['simplecache' => true],
'pwa/installable.mjs' => ['simplecache' => true],
'pwa/upup/upup.sw.js' => ['simplecache' => true],
'resources/pwa/offline.html' => ['simplecache' => true],
],
];
38 changes: 0 additions & 38 deletions views/default/pwa/installable.js.php

This file was deleted.

37 changes: 37 additions & 0 deletions views/default/pwa/installable.mjs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php
$plugin = elgg_get_plugin_from_id('pwa');
?>

import 'jquery';

// Initialize deferredPrompt for use later to show browser install prompt.
let deferredPrompt;

window.addEventListener('beforeinstallprompt', (e) => {
// Stash the event so it can be triggered later.
deferredPrompt = e;

<?php if ($plugin->installable !== 'default') { ?>
// Prevent the mini-infobar from appearing on mobile
e.preventDefault();

<?php if ($plugin->installable === 'custom') { ?>
// Update UI notify the user they can install the PWA
showPWAInstallPromotion();
<?php } ?>
<?php } ?>
});

window.addEventListener('appinstalled', () => {
// Handle app installed event
appInstalledEventHandler();

// Clear the deferredPrompt so it can be garbage collected
deferredPrompt = null;
});

<?php

// the following view contains the code for showPWAInstallPromotion()
echo elgg_view('pwa/install_events.js');

0 comments on commit eb99a0a

Please sign in to comment.