Skip to content

Commit

Permalink
New: Use own prototype for embeded attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
jonnitto committed Feb 1, 2021
1 parent 567fc5f commit 19bc38c
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 37 deletions.
48 changes: 48 additions & 0 deletions Resources/Private/Fusion/Component/Attribute.Embed.fusion
Original file line number Diff line number Diff line change
@@ -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 : ''}
}
}
}
}
39 changes: 2 additions & 37 deletions Resources/Private/Fusion/Component/Attributes.fusion
Original file line number Diff line number Diff line change
Expand Up @@ -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}
}
}
}

0 comments on commit 19bc38c

Please sign in to comment.