From 2bd24850df06198eb38a92a7748a98bc3c18097f Mon Sep 17 00:00:00 2001 From: reganlawton Date: Mon, 12 Aug 2024 17:22:33 +1000 Subject: [PATCH 1/4] chore: Registing plugin to test CDN build process --- src/Oembed.php | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/Oembed.php b/src/Oembed.php index 3ce3a83..b6beec8 100644 --- a/src/Oembed.php +++ b/src/Oembed.php @@ -10,25 +10,26 @@ namespace wrav\oembed; -use wrav\oembed\events\BrokenUrlEvent; -use wrav\oembed\fields\OembedField; -use wrav\oembed\jobs\BrokenUrlNotify; -use wrav\oembed\services\OembedService; -use wrav\oembed\variables\OembedVariable; -use wrav\oembed\models\Settings; - use Craft; +use craft\web\View; +use yii\base\Event; use craft\base\Plugin; +use craft\web\UrlManager; +use craft\services\Fields; + use craft\services\Plugins; use craft\events\PluginEvent; -use craft\services\Fields; -use craft\web\twig\variables\CraftVariable; -use craft\events\RegisterComponentTypesEvent; -use craft\web\View; +use wrav\oembed\models\Settings; +use wrav\oembed\fields\OembedField; +use wrav\oembed\jobs\BrokenUrlNotify; +use wrav\oembed\events\BrokenUrlEvent; use craft\events\RegisterUrlRulesEvent; -use craft\web\UrlManager; +use wrav\oembed\services\OembedService; +use wrav\oembed\variables\OembedVariable; +use craft\web\twig\variables\CraftVariable; -use yii\base\Event; +use craft\events\RegisterComponentTypesEvent; +use wrav\oembed\assetbundles\oembed\OembedAsset; /** * @author reganlawton @@ -117,6 +118,9 @@ function (PluginEvent $event) { } ); + // Register Assets + Craft::$app->getView()->registerAssetBundle(OembedAsset::class); + Event::on( View::class, View::EVENT_END_PAGE, From fb9c2faba90b722a8730441275e3f929602df044 Mon Sep 17 00:00:00 2001 From: reganlawton Date: Mon, 12 Aug 2024 17:50:13 +1000 Subject: [PATCH 2/4] chore: Register the OembedAsset for all but Site requests --- src/Oembed.php | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/src/Oembed.php b/src/Oembed.php index b6beec8..52a62de 100644 --- a/src/Oembed.php +++ b/src/Oembed.php @@ -119,22 +119,9 @@ function (PluginEvent $event) { ); // Register Assets - Craft::$app->getView()->registerAssetBundle(OembedAsset::class); - - Event::on( - View::class, - View::EVENT_END_PAGE, - function(Event $event) { - if (Craft::$app->getRequest()->getIsCpRequest() && preg_match('/^\/.+\/entries\//', Craft::$app->getRequest()->getUrl())) { - $url = Craft::$app->assetManager->getPublishedUrl('@wrav/oembed/assetbundles/oembed/dist/js/oembed.js', true); - - echo ""; - - $url = Craft::$app->assetManager->getPublishedUrl('@wrav/oembed/assetbundles/oembed/dist/css/oembed.css', true); - echo ""; - } - } - ); + if (!Craft::$app->getRequest()->getIsSiteRequest()) { + Craft::$app->getView()->registerAssetBundle(OembedAsset::class); + } Event::on( UrlManager::class, From 35913d04dae97d9bbd1fb803f47ddeec151dca54 Mon Sep 17 00:00:00 2001 From: reganlawton Date: Mon, 9 Sep 2024 18:21:13 +1000 Subject: [PATCH 3/4] feat: Added additional fallback logic and added custom extractor support --- CHANGELOG.md | 70 ++++++++++++++++++++++++++++++++ README.md | 11 ++++- composer.json | 2 +- src/adapters/EmbedAdapter.php | 74 +++++++++++++++++++++++++++++++++- src/services/OembedService.php | 16 ++++++-- 5 files changed, 164 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 65239c7..cdb0ea8 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,23 +1,37 @@ # oEmbed Changelog +## 3.1.0 - 2024-07-09 + +### Added + +- Added support for adapter extractor support to allow custom site handling + +### Update + +- Refactor EmbedAdapter to handle extractor object to support better fallback for some websites + ## 3.0.9 - 2024-07-26 ### Update + - Resolves error when querying an entry with a empty oEmbed URL. Thanks to @jaapfaes for PR #157 ## 3.0.8 - 2024-02-26 ### Update + - Resolved GraphQL issues. Special thanks to @davidwebca ## 3.0.7 - 2023-12-15 ### Update + - Resolve YT loop issues. Reported by @holiday-jan in issue #146. Thanks @holiday-jan ## 3.0.6 - 2023-12-15 ### Update + - Fixed issue with src attribute not being set on iframe. Reported by @holiday-jan in issue #146. Thanks @holiday-jan - Rework preview handling - Updated README docs @@ -26,101 +40,121 @@ ## 3.0.5 - 2023-12-08 ### Update + - Modified handling of empty embedded media codes ## 3.0.4 - 2023-12-07 ### Update + - Adds version to cache key to prevent cache key collisions. ## 3.0.3 - 2023-12-04 ### Update + - Add GDPR compliance with CookieBot settings and functionality. Reported by @joepagan in issue #131. Thanks @joepagan and @iparr for discussion and logging. ## 3.0.2 - 2023-12-01 ### Update + - Add data mapping and fallback for image properties. Reported by @maxfenton in issue #143 and @helleholmsen in issue #145. Thanks @maxfenton and @helleholmsen ## 3.0.1 - 2023-11-17 ### Update + - Handle all exceptions in OembedService to prevent edge case errors. Reported by @holiday-jan in issue #141. Thanks @holiday-jan ## 3.0.0 - 2023-11-04 ### Update + - Update embed/embed to v4 to allow for support with newer plugins. ## 2.3.1 - 2023-10-11 ### Update + - Added fix for issue #138, caused by static return type on the JobInterface. Thanks @laurabennett - Added @sgtpenguin 's PR to avoid GraphQL bug by defaulting the height and width to NULL for the fallback adapter. Thanks @sgtpenguin ## 2.3.0 - 2023-02-02 ### Update + - Added default caching keys to resolve missing field data while cached ## 2.2.2 - 2022-08-26 ### Update + - Fix Craft 4 type compatibility. THANKS @raymondelooff ## 2.2.1 - 2022-06-30 ### Update + - Fix a side effect of #101 fix where the preview and embed will fallback to the default Craft site if no or invalid URL is provided (@juban) ## 2.2.0 - 2022-06-30 ### Update + - Converting DOMDocument to JSON and back to StdClass due to error "Serialization of 'DOMDocument' is not allowed" with caching in PHP 8. - Fixed `required` option not applying ## 2.1.0 - 2022-06-29 ### Added + - Added `ext-dom` requirement ### Updated + - Fix for issue #101 for the v2 version track for Craft v4. Thanks again @juban ## 2.0.0 - 2022-06-18 ### Updated + - Updated plugin to support Craft v4 - Removed requirement for Craft v3 and requiremnt is now PHP to >=8.0.2 ## 1.3.15 - 2022-03-09 ### Updated + - Fix for issue #101, where the plugin is unable to set a webpage as a valid source URL. Thanks @juban ## 1.3.13 - 2021-10-21 ### Added + - Add referrer to Embed for videos with privacy restrictions. ### Updated + - Changes to the handle of FallbackAdapter with no URL. - Preview changes ## 1.3.12 - 2021-08-05 ### Added + - Fix issue with blank URLs where fallback adapter sets URL to '/'. This also fixes #88 issue. ## 1.3.11 - 2021-07-21 ### Added + - Added fallback adapter for invalid URLs and PHP 8 issues, thanks [@gglnx](https://github.com/gglnx). This also fixes #81, #76 issues. ## 1.3.10 - 2021-07-20 ### Updated + - Fixes issue with caching key, thanks [@mijewe](https://github.com/mijewe). - Fixes to 'class@anonymous' handling, this should help resolve issues [#81](https://github.com/wrav/oembed/issues/81), [#50](https://github.com/wrav/oembed/issues/50), [#10](https://github.com/wrav/oembed/issues/10). - Updated CHANGELOG dates. @@ -128,179 +162,215 @@ ## 1.3.9 - 2021-06-16 ### Updated + - Fixes issue with `params` option not applying if query / GET params not yet set, this resolves issues [#53](https://github.com/wrav/oembed/issues/53). ## 1.3.8 - 2021-06-15 ### Updated + - Fixes issue with code changes due to PHP namespacing. - Updates to caching key to support embed options, this resolves issues [#73](https://github.com/wrav/oembed/issues/73). ## 1.3.7 - 2021-06-15 ### Updated + - Updates to OembedModel / GraphQL bugfixes, this resolves issues [#74](https://github.com/wrav/oembed/issues/74) and PR [#75](https://github.com/wrav/oembed/issues/75). Thank you to @joshuabaker, @denisyilmaz and anyone else I missed. - Clean up bugfixes changes ## 1.3.6 - 2020-10-28 ### Added + - Added new render option called `attributes` to allow custom attributes to bet added to iframe element, this resolves issue ([#51](https://github.com/wrav/oembed/issues/51)). ## 1.3.5 - 2020-10-28 ### Updated + - Add settings-input for Facebook/Instagram access token. Thanks Floris aka @FlorisDerks ## 1.3.4 - 2020-06-29 ### Updated + - Fix to normalizeValue function on GraphQL field's `__get()` magic method. Thanks @joshuabaker ## 1.3.3 - 2020-06-29 ### Updated + - Fix to GraphQL bug caused by PHP NULL coalescing operator from issue ([#46](https://github.com/wrav/oembed/issues/46)). ## 1.3.2 - 2020-06-05 ### Updated + - Fixed GraphQL bug `Internal Server Error: GraphQL fails to get oembed fields` ([#46](https://github.com/wrav/oembed/issues/46)). ## 1.3.1 - 2020-05-08 ### Added + - *(NEW FEATURE)* Added GDPR setting to transform URL's for Youtube and Vimeo to their GDPR versions. This happen's without needing to change existing URL's. ## 1.3.0 - 2020-03-05 ### Added + - *(NEW FEATURE)* Added setting to hide preview iframe in the new a collapsable UI component. - *(NEW FEATURE)* Added notification by email for broken URLs which can be set up in plugin settings. This feature is still under development and new feature's like Slack, Microsoft Team notification channels will be added including support to update the notify message copy. ### Updated + - Preview iframe is now rendered into a collapsable component to save space. - Add `overflow:hidden` to iframe to prevent overflow ([#37](https://github.com/wrav/oembed/issues/37)). ## 1.2.5 - 2020-02-10 ### Updated + - Allow users to set width and height on the iframe ([#35](https://github.com/wrav/oembed/issues/35)). ## 1.2.4 - 2020-02-05 ### Updated + - Removed package dependacy to get PHP 7.0-compatible ([#33](https://github.com/wrav/oembed/issues/33)) ## 1.2.3 - 2020-02-05 ### Fixed + - Fixed "Upgrading to 1.2.0+ disables admin UI ([#32](https://github.com/wrav/oembed/issues/32))" bug caused by LibXML rendering self closing `iframe`. ## 1.2.2 - 2020-01-30 ### Updated + - Updated README with usage of new feature. ### Added + - *(NEW FEATURE)* Add new `params` option to allow you to set missing URL query params that are supported by the providers oembed protocol. ([#24](https://github.com/wrav/oembed/issues/24) & [#30](https://github.com/wrav/oembed/issues/30)) ## 1.2.1 - 2020-01-19 ### Updated + - Re-add `rel` feature missing due to merge conflict. ([#24](https://github.com/wrav/oembed/issues/24)) ## 1.2.0 - 2020-01-19 ### Updated + - Support `rel` URL propety via DOM manipulation. ([#24](https://github.com/wrav/oembed/issues/24)) - Added GraphQL support. ([#25](https://github.com/wrav/oembed/issues/25)) - Updated docs ### Fixed + - Fixed "Undefined index: autoplay" warnings. ([#26](https://github.com/wrav/oembed/issues/26)) ## 1.1.8 - 2019-09-16 ### Updated + - Support Youtube and Vimeo `autoplay`, `loop` and `autopause` embed feature via DOM manipulation. ([#14](https://github.com/wrav/oembed/issues/14)) ### Fixed + - Array to string conversion bug due to lack of a recursive function. ([#17](https://github.com/wrav/oembed/issues/17)) ## 1.1.7 - 2019-09-16 ### Updated + - Support custom control panel (`cpTrigger`) configurations. ## 1.1.6 - 2019-04-22 ### Updated + - Caching is now a field you enable in new settings area. ## 1.1.5 - 2019-04-15 ### Updated + - Updated to prevent