From 6387024f816972f9b965b901448432071fe6ed68 Mon Sep 17 00:00:00 2001 From: Ramon Wenger Date: Wed, 14 Nov 2018 11:53:28 +0100 Subject: [PATCH] Add SRF video embedding --- .../components/content-blocks/VideoBlock.vue | 11 ++++++-- .../components/content-forms/VideoForm.vue | 14 +++++++--- client/src/components/videos/SrfEmbed.vue | 26 +++++++++++++++++++ client/src/helpers/video.js | 7 +++++ 4 files changed, 53 insertions(+), 5 deletions(-) create mode 100644 client/src/components/videos/SrfEmbed.vue diff --git a/client/src/components/content-blocks/VideoBlock.vue b/client/src/components/content-blocks/VideoBlock.vue index 971b88aa..bf6b3e19 100644 --- a/client/src/components/content-blocks/VideoBlock.vue +++ b/client/src/components/content-blocks/VideoBlock.vue @@ -2,20 +2,24 @@
+ +
+ + diff --git a/client/src/helpers/video.js b/client/src/helpers/video.js index 39d3ba9a..b758efed 100644 --- a/client/src/helpers/video.js +++ b/client/src/helpers/video.js @@ -1,5 +1,6 @@ const YOUTUBE = /^(?:https:\/\/)?(?:www.)?(?:youtube.com\/watch\?v=|youtu.be\/)([a-zA-Z0-9_-]{11})(?:.+)?$/; const VIMEO = /^(?:https:\/\/)?(?:www.)?vimeo.com\/([a-zA-Z0-9]*)$/; +const SRF = /^(?:https:\/\/)?(?:www.)?srf.ch\/(?:[\w/-]*)[?&]id=([\w-]+)(?:[&\w=-]*)$/; export function isYoutubeUrl(url) { return YOUTUBE.test(url); @@ -9,11 +10,17 @@ export function isVimeoUrl(url) { return VIMEO.test(url); } +export function isSrfUrl(url) { + return SRF.test(url); +} + export function getVideoId(url) { if (isYoutubeUrl(url)) { return YOUTUBE.exec(url)[1]; } else if (isVimeoUrl(url)) { return VIMEO.exec(url)[1]; + } else if (isSrfUrl(url)) { + return SRF.exec(url)[1]; } else { return ''; }