From d0faeebf8fb2d4baf71cf506cf37552231590a73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C3=ADas=20Minevitz?= Date: Fri, 7 Jun 2024 14:51:24 -0300 Subject: [PATCH] Added Genially provider --- doc/02-providers.md | 1 + doc/providers/Genially.md | 16 ++++++ src/Embera/Provider/Genially.php | 53 +++++++++++++++++++ .../DefaultProviderCollection.php | 1 + tests/Embera/Provider/GeniallyTest.php | 44 +++++++++++++++ 5 files changed, 115 insertions(+) create mode 100644 doc/providers/Genially.md create mode 100644 src/Embera/Provider/Genially.php create mode 100644 tests/Embera/Provider/GeniallyTest.php diff --git a/doc/02-providers.md b/doc/02-providers.md index 047aa39..a33345b 100644 --- a/doc/02-providers.md +++ b/doc/02-providers.md @@ -75,6 +75,7 @@ I try to support all the providers listed on [oembed.com](https://oembed.com). - [FlowHubOrg](providers/FlowHubOrg.md) - [Framer](providers/Framer.md) - [Fooday](providers/Fooday.md) +- [Genially](providers/Genially.md) - [GeographUk](providers/GeographUk.md) - [GeographCI](providers/GeographCI.md) - [GeographDE](providers/GeographDE.md) diff --git a/doc/providers/Genially.md b/doc/providers/Genially.md new file mode 100644 index 0000000..ef297b6 --- /dev/null +++ b/doc/providers/Genially.md @@ -0,0 +1,16 @@ +# [Genially](https://genially.com) + +Genially Provider +Engage your audience with clickable, gamified, media-rich experiences. +Create your interactive content now! + +## Implementation Details + +- Provider Name: Genially +- Documentation: NO +- HTTPS support: YES +- Fake Response: NO +- Oembed Params: NO +- Supported Hosts: view.genially.com, view.genial.ly +- Responsive response: YES +- Collections: DefaultProviderCollection diff --git a/src/Embera/Provider/Genially.php b/src/Embera/Provider/Genially.php new file mode 100644 index 0000000..2a7097c --- /dev/null +++ b/src/Embera/Provider/Genially.php @@ -0,0 +1,53 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Embera\Provider; + +use Embera\Url; + +/** + * Genially Provider + * Engage your audience with clickable, gamified, media-rich experiences. Create your interactive content now! + * + * @link https://genially.com + */ +class Genially extends ProviderAdapter implements ProviderInterface +{ + /** inline {@inheritdoc} */ + protected $endpoint = 'https://genially.com/services/oembed?format=json'; + + /** inline {@inheritdoc} */ + protected static $hosts = [ + '*.genial.ly', + '*.genially.com', + ]; + + /** inline {@inheritdoc} */ + protected $httpsSupport = true; + + /** inline {@inheritdoc} */ + protected $responsiveSupport = true; + + /** inline {@inheritdoc} */ + public function validateUrl(Url $url) + { + return (bool) (preg_match('~view\.(?:genial\.ly|genially\.com)/[a-z0-9]{24}(?:$|/)~i', (string) $url)); + } + + /** inline {@inheritdoc} */ + public function normalizeUrl(Url $url) + { + $url->convertToHttps(); + $url->removeQueryString(); + + return $url; + } +} diff --git a/src/Embera/ProviderCollection/DefaultProviderCollection.php b/src/Embera/ProviderCollection/DefaultProviderCollection.php index a64c7ed..7849500 100755 --- a/src/Embera/ProviderCollection/DefaultProviderCollection.php +++ b/src/Embera/ProviderCollection/DefaultProviderCollection.php @@ -95,6 +95,7 @@ public function __construct(array $config = []) 'FlowHubOrg', 'Framer', 'Fooday', + 'Genially', 'GeographUk', 'GeographCI', 'GeographDE', diff --git a/tests/Embera/Provider/GeniallyTest.php b/tests/Embera/Provider/GeniallyTest.php new file mode 100644 index 0000000..dc4acfa --- /dev/null +++ b/tests/Embera/Provider/GeniallyTest.php @@ -0,0 +1,44 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Embera\Provider; + +use Embera\ProviderTester; + +/** + * Test the Genially Provider + */ +final class GeniallyTest extends ProviderTester +{ + protected $tasks = [ + 'valid_urls' => [ + 'https://view.genially.com/66560826885e160014487db5', + 'https://view.genially.com/66560826885e160014487db5/', + 'https://view.genially.com/66560826885e160014487db5/asd', + 'https://view.genial.ly/663449c0ebfbaa0014b24cc9', + 'https://view.genial.ly/663449c0ebfbaa0014b24cc9/', + 'https://view.genial.ly/663449c0ebfbaa0014b24cc9/asd', + ], + 'invalid_urls' => [ + 'https://view.genially.com/66560826885e160014487db', + 'https://view.genially.com/66560826885e160014487db5a', + 'https://view.genially.com/en/66560826885e160014487db5', + 'https://view.genial.ly/en/663449c0ebfbaa0014b24cc9', + 'https://view.genial.ly/663449c0ebfbaa0014b24cc', + 'https://view.genial.ly/663449c0ebfbaa0014b24cc9a', + ], + ]; + + public function testProvider() + { + $this->validateProvider('Genially', ['width' => 480, 'height' => 270]); + } +}