From 19bc38cef6f0c35d9e3b41c85b328f0366ac24ba Mon Sep 17 00:00:00 2001 From: Jon Uhlmann Date: Mon, 1 Feb 2021 15:51:08 +0100 Subject: [PATCH] New: Use own prototype for embeded attributes --- .../Fusion/Component/Attribute.Embed.fusion | 48 +++++++++++++++++++ .../Fusion/Component/Attributes.fusion | 39 +-------------- 2 files changed, 50 insertions(+), 37 deletions(-) create mode 100644 Resources/Private/Fusion/Component/Attribute.Embed.fusion diff --git a/Resources/Private/Fusion/Component/Attribute.Embed.fusion b/Resources/Private/Fusion/Component/Attribute.Embed.fusion new file mode 100644 index 0000000..3a60fd7 --- /dev/null +++ b/Resources/Private/Fusion/Component/Attribute.Embed.fusion @@ -0,0 +1,48 @@ +prototype(Jonnitto.PrettyEmbedVideoPlatforms:Component.Attributes.Embed) < prototype(Neos.Fusion:Component) { + configuration = ${Configuration.setting('Jonnitto.PrettyEmbedVideoPlatforms')} + url = ${this.platform == 'youtube' ? this.configuration.youtube[this.type] : this.configuration[this.platform]} + additionalValues = null + + @of.hasNeededProperties = ${this.platform && this.videoID && Type.isArray(this.url) && Type.isString(this.url.embed)} + + renderer = Neos.Fusion:Case { + isVimeo { + condition = ${props.platform == 'vimeo'} + renderer = Neos.Fusion:Join { + src = ${String.replace(props.url.embed, '%id%', props.videoID)} + connect = ${String.indexOf(props.url.embed, '?') == -1 ? '?' : '&'} + autoplay = 'autoplay=1' + loop = ${props.loop ? '&loop=1' : ''} + color = ${props.color ? '&color=' + String.replace(props.color, '#', '') : ''} + autopause = ${props.autopause ? '' : '&autopause=0'} + background = ${props.background ? '' : '&background=0'} + muted = ${props.muted ? '&muted=1' : ''} + playsinline = ${props.playsinline ? '' : '&playsinline=0'} + transparent = ${props.transparent ? '' : '&transparent=0'} + previewTitle = ${props.previewTitle ? '' : '&title=0'} + previewByline = ${props.previewByline ? '' : '&byline=0'} + previewPortrait = ${props.previewPortrait ? '' : '&portrait=0'} + additionalValues = ${props.additionalValues ? '&' + props.additionalValues : ''} + } + } + isYoutube { + condition = ${props.platform == 'youtube'} + renderer = Neos.Fusion:Join { + src = ${String.replace(props.url.embed, '%id%', props.videoID)} + connect = ${String.indexOf(props.url.embed, '?') == -1 ? '?' : '&'} + autoplay = 'autoplay=1' + modestbranding = '&modestbranding=1' + enableJsApi = ${props.enableJsApi ? '&enablejsapi=1' : ''} + playsinline = ${'&playsinline=' + (props.playsinline ? '1' : '0')} + controls = ${props.controls ? '' : '&controls=0'} + loop = ${props.loop ? '&loop=1' : ''} + muted = ${props.muted ? '&mute=1' : ''} + closedCaptions = ${props.closedCaptions ? '&cc_load_policy=1' : ''} + showRelated = ${props.showRelated ? '&rel=1' : '&rel=0'} + fullscreen = ${props.allowFullScreen ? '' : '&fs=0'} + origin = ${props.origin ? '&origin=' + props.origin : ''} + additionalValues = ${props.additionalValues ? '&' + props.additionalValues : ''} + } + } + } +} diff --git a/Resources/Private/Fusion/Component/Attributes.fusion b/Resources/Private/Fusion/Component/Attributes.fusion index e62f976..0a667bc 100644 --- a/Resources/Private/Fusion/Component/Attributes.fusion +++ b/Resources/Private/Fusion/Component/Attributes.fusion @@ -18,42 +18,7 @@ prototype(Jonnitto.PrettyEmbedVideoPlatforms:Component.Attributes) < prototype(N data-gdpr = ${props.enableGdprMessage && props.gdprMessage ? props.gdprMessage : null} data-ratio = ${props.finalRatio || null} data-fs = ${!!props.allowFullScreen} - data-embed = Neos.Fusion:Case { - isVimeo { - condition = ${props.platform == 'vimeo'} - renderer = Neos.Fusion:Join { - src = ${String.replace(props.url.embed, '%id%', props.videoID)} - connect = ${String.indexOf(props.url.embed, '?') == -1 ? '?' : '&'} - autoplay = 'autoplay=1' - loop = ${props.loop ? '&loop=1' : ''} - color = ${props.color ? '&color=' + String.replace(props.color, '#', '') : ''} - autopause = ${props.autopause ? '' : '&autopause=0'} - background = ${props.background ? '' : '&background=0'} - muted = ${props.muted ? '&muted=1' : ''} - playsinline = ${props.playsinline ? '' : '&playsinline=0'} - transparent = ${props.transparent ? '' : '&transparent=0'} - previewTitle = ${props.previewTitle ? '' : '&title=0'} - previewByline = ${props.previewByline ? '' : '&byline=0'} - previewPortrait = ${props.previewPortrait ? '' : '&portrait=0'} - } - } - isYoutube { - condition = ${props.platform == 'youtube'} - renderer = Neos.Fusion:Join { - src = ${String.replace(props.url.embed, '%id%', props.videoID)} - connect = ${String.indexOf(props.url.embed, '?') == -1 ? '?' : '&'} - autoplay = 'autoplay=1' - modestbranding = '&modestbranding=1' - enableJsApi = ${props.enableJsApi ? '&enablejsapi=1' : ''} - playsinline = ${'&playsinline=' + (props.playsinline ? '1' : '0')} - controls = ${props.controls ? '' : '&controls=0'} - loop = ${props.loop ? '&loop=1' : ''} - closedCaptions = ${props.closedCaptions ? '&cc_load_policy=1' : ''} - showRelated = ${props.showRelated ? '&rel=1' : '&rel=0'} - fullscreen = ${props.allowFullScreen ? '' : '&fs=0'} - origin = ${props.origin ? '&origin=' + props.origin : ''} - } - } + data-embed = Jonnitto.PrettyEmbedVideoPlatforms:Component.Attributes.Embed { + @apply.props = ${props} } - } }