From 9684ba302977ad0918c6e29a0e88293a3b3409f4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Fri, 29 May 2020 16:49:44 +0200 Subject: [PATCH] Add Facebook Video Media Provider The resulting HTML intentionally does not use an `` element for the fallback link, because it will prevent the SDK from embedding the video. The SDK generally acts as a blackbox with regard to video embeds, the only thing we can do is asking it nicely to re-parse the DOM for new stuff to embed and hope for the best. Specifically embedding doesn't work for newly posted contents that are loaded via Ajax. Not even if the re-scan is scheduled for the next run of the event loop by using `setTimeout` with a delay of `0`. For whatever reason there might be. Resolves #3242 --- com.woltlab.wcf/mediaProvider.xml | 7 +++++++ .../WoltLabSuite/Core/Wrapper/FacebookSdk.js | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 wcfsetup/install/files/js/WoltLabSuite/Core/Wrapper/FacebookSdk.js diff --git a/com.woltlab.wcf/mediaProvider.xml b/com.woltlab.wcf/mediaProvider.xml index 53e5404597..cb70bfdd3e 100644 --- a/com.woltlab.wcf/mediaProvider.xml +++ b/com.woltlab.wcf/mediaProvider.xml @@ -81,6 +81,13 @@ https?://www.twitch.tv/[a-zA-Z0-9]+/v/(?[0-9]+)]]> https://twitter.com/{$USERNAME}/status/{$ID}/ ]]> + + Facebook Video + https?://(www\.)?facebook\.com/watch/\?v=(?[0-9]+)) +(?https?://(www\.)?facebook\.com/[a-zA-Z0-9_-]+/videos/(?[0-9]+)/)]]> + {$HREF} +]]> + diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Wrapper/FacebookSdk.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Wrapper/FacebookSdk.js new file mode 100644 index 0000000000..4c389b743f --- /dev/null +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Wrapper/FacebookSdk.js @@ -0,0 +1,18 @@ +/** + * Handles loading and initialization of Facebook's JavaScript SDK. + * + * @author Tim Duesterhus + * @copyright 2001-2020 WoltLab GmbH + * @license GNU Lesser General Public License + * @module WoltLabSuite/Core/Wrapper/FacebookSdk + */ +define(['https://connect.facebook.net/en_US/sdk.js'], function(_dummy) { + "use strict"; + + // see: https://developers.facebook.com/docs/javascript/reference/FB.init/v7.0 + FB.init({ + version: 'v7.0' + }); + + return FB; +}); -- 2.20.1