-
Notifications
You must be signed in to change notification settings - Fork 754
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/video v1 #1624
Open
georgecamilar
wants to merge
39
commits into
adobe:main
Choose a base branch
from
georgecamilar:feature/video-v1
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Feature/video v1 #1624
Changes from all commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
a14f5ec
Updating branch
georgecamilar ab50cd1
Contributing to adobe core components:
94f5ba7
README corrections
2d363fc
Remove unused alt property from video component dialog
9b48a79
Fixing .content.xml breaking the build
georgecamilar eef102b
feature: Video Component:
3382d03
feature(video-component) : Adding Video Component to Adobe Core Compo…
58d67d7
feature(Contribute to adobe core components): Video Component
286abcb
feature(video-component-v1):
deff7b9
feature(contribute-video-component): Video
86bd3b8
Joel Commit
3b9bab0
fixing unit tests and video component
9242b6b
feature(contribute-video-to-adobe-core-components):
54efe17
Unit Tests adaption after changes
1cd14e9
pushing a video sample for the video component
6bde62c
Merge branch 'development' of https://github.com/georgecamilar/aem-co…
georgecamilar 6343660
Add partial selenium tests for Video Component
gabriel-negrusa 6dc33cc
switcch to preview mode for attributes checks
cosminmmagdas 2b8b976
add video test case
cosminmmagdas a536238
video not added test case
cosminmmagdas 6c4aafd
code cleanup
cosminmmagdas 6bf3b1c
code cleanup
cosminmmagdas f19729a
code cleanup
cosminmmagdas 6ac5d40
code cleanup
cosminmmagdas e9d8ccd
code cleanup
cosminmmagdas d8823a8
login as administrator in order to allow proper cleanup
cosminmmagdas b3a0ee1
add selenium tests for video properties
gabriel-negrusa d3dce3c
Fix Video component selenium tests
gabriel-negrusa 0cee05a
Remove unused Video alt property
gabriel-negrusa ce6dd8c
Add mute button for video
gabriel-negrusa dd8604a
fix linting errors
gabriel-negrusa 70575af
Add mute checkbox to video model
gabriel-negrusa d8d3807
Add video mute button to component examples
gabriel-negrusa bbb1149
Update video component unit tests to include mute property
gabriel-negrusa bcd7736
Update video selenium tests to account for mute button
gabriel-negrusa 5672d77
Make video fields descriptions more detailed
gabriel-negrusa a50b234
Merge branch 'development' of https://github.com/georgecamilar/aem-co…
gabriel-negrusa 98a108a
Change company field in video readme
gabriel-negrusa eb86fc4
Remove leftover debug command
gabriel-negrusa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
161 changes: 161 additions & 0 deletions
161
...les/core/src/main/java/com/adobe/cq/wcm/core/components/internal/models/v1/VideoImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
~ Copyright 2021 Adobe | ||
~ | ||
~ Licensed under the Apache License, Version 2.0 (the "License"); | ||
~ you may not use this file except in compliance with the License. | ||
~ You may obtain a copy of the License at | ||
~ | ||
~ http://www.apache.org/licenses/LICENSE-2.0 | ||
~ | ||
~ Unless required by applicable law or agreed to in writing, software | ||
~ distributed under the License is distributed on an "AS IS" BASIS, | ||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
~ See the License for the specific language governing permissions and | ||
~ limitations under the License. | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ | ||
package com.adobe.cq.wcm.core.components.internal.models.v1; | ||
|
||
import com.adobe.cq.export.json.ComponentExporter; | ||
import com.adobe.cq.export.json.ExporterConstants; | ||
import com.adobe.cq.wcm.core.components.commons.link.Link; | ||
import com.adobe.cq.wcm.core.components.internal.link.LinkHandler; | ||
import com.adobe.cq.wcm.core.components.models.Video; | ||
import com.adobe.cq.wcm.core.components.models.datalayer.AssetData; | ||
import com.adobe.cq.wcm.core.components.models.datalayer.ComponentData; | ||
import com.adobe.cq.wcm.core.components.models.datalayer.builder.AssetDataBuilder; | ||
import com.adobe.cq.wcm.core.components.models.datalayer.builder.DataLayerBuilder; | ||
import com.day.cq.dam.api.Asset; | ||
import com.day.cq.rewriter.linkchecker.LinkChecker; | ||
import com.day.cq.rewriter.linkchecker.LinkValidity; | ||
import org.apache.sling.api.SlingHttpServletRequest; | ||
import org.apache.sling.api.resource.ValueMap; | ||
import org.apache.sling.models.annotations.Default; | ||
import org.apache.sling.models.annotations.Exporter; | ||
import org.apache.sling.models.annotations.Model; | ||
import org.apache.sling.models.annotations.injectorspecific.*; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import javax.annotation.PostConstruct; | ||
import java.util.Optional; | ||
import java.util.function.Supplier; | ||
|
||
@Model( | ||
adaptables = SlingHttpServletRequest.class, | ||
adapters = {Video.class, ComponentExporter.class}, | ||
resourceType = VideoImpl.RESOURCE_TYPE | ||
) | ||
@Exporter( | ||
name = ExporterConstants.SLING_MODEL_EXPORTER_NAME, | ||
extensions = ExporterConstants.SLING_MODEL_EXTENSION | ||
) | ||
public class VideoImpl extends AbstractComponentImpl implements Video { | ||
|
||
public static final String RESOURCE_TYPE = "core/wcm/components/video/v1/video"; | ||
|
||
@OSGiService | ||
private LinkChecker checker; | ||
|
||
@ValueMapValue(name = "videoFileReference", injectionStrategy = InjectionStrategy.OPTIONAL) | ||
@Nullable | ||
private String fileReference; | ||
|
||
@ValueMapValue(name = "posterImageReference", injectionStrategy = InjectionStrategy.OPTIONAL) | ||
@Nullable | ||
private String posterImageReference; | ||
|
||
@ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL) | ||
@Default(booleanValues = false) | ||
private boolean hideControl; | ||
|
||
@ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL) | ||
@Default(booleanValues = false) | ||
private boolean loopEnabled; | ||
|
||
@ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL) | ||
@Default(booleanValues = false) | ||
private boolean autoplayEnabled; | ||
|
||
@ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL) | ||
@Default(booleanValues = false) | ||
private boolean muted; | ||
|
||
/** | ||
* The current resource properties. | ||
*/ | ||
@ScriptVariable | ||
protected ValueMap properties; | ||
|
||
/** | ||
* Initialize the model. | ||
*/ | ||
@PostConstruct | ||
private void initModel() { | ||
posterImageReference = properties.get(Video.PN_POSTER_REFERENCE, posterImageReference); | ||
hideControl = properties.get(Video.PN_HIDE_CONTROL, hideControl); | ||
loopEnabled = properties.get(Video.PN_LOOP_ENABLED, loopEnabled); | ||
autoplayEnabled = properties.get(Video.PN_AUTOPLAY_ENABLED, autoplayEnabled); | ||
muted = properties.get(Video.PN_MUTED_ENABLED, muted); | ||
} | ||
|
||
@Override | ||
@Nullable | ||
public String getFileReference() { | ||
final LinkValidity validity = checker.getLink(fileReference, checker.createSettings(this.request)).getValidity(); | ||
if (validity.equals(LinkValidity.VALID)) { | ||
return fileReference; | ||
} | ||
return null; | ||
} | ||
|
||
@Override | ||
@Nullable | ||
public String getPosterImageReference() { | ||
return posterImageReference; | ||
} | ||
|
||
@Override | ||
public boolean isHideControl() { | ||
return hideControl; | ||
} | ||
|
||
@Override | ||
public boolean isLoopEnabled() { | ||
return loopEnabled; | ||
} | ||
|
||
@Override | ||
public boolean isAutoplayEnabled() { | ||
return autoplayEnabled; | ||
} | ||
|
||
@Override | ||
public boolean isMuted() { | ||
if (autoplayEnabled) { | ||
return true; | ||
} | ||
return muted; | ||
} | ||
|
||
@Override | ||
@NotNull | ||
protected ComponentData getComponentData() { | ||
return DataLayerBuilder.extending(super.getComponentData()) | ||
.asVideoComponent() | ||
.withAssetData(dataSupplier) | ||
.build(); | ||
} | ||
|
||
@Override | ||
public @NotNull String getExportedType() { | ||
return resource.getResourceType(); | ||
} | ||
|
||
private final Supplier<AssetData> dataSupplier = () -> | ||
Optional.ofNullable(this.fileReference) | ||
.map(reference -> this.request.getResourceResolver().getResource(reference)) | ||
.map(assetResource -> assetResource.adaptTo(Asset.class)) | ||
.map(DataLayerBuilder::forAsset) | ||
.map(AssetDataBuilder::build) | ||
.orElse(null); | ||
} |
55 changes: 55 additions & 0 deletions
55
...ain/java/com/adobe/cq/wcm/core/components/internal/models/v1/datalayer/VideoDataImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
~ Copyright 2020 Adobe | ||
~ | ||
~ Licensed under the Apache License, Version 2.0 (the "License"); | ||
~ you may not use this file except in compliance with the License. | ||
~ You may obtain a copy of the License at | ||
~ | ||
~ http://www.apache.org/licenses/LICENSE-2.0 | ||
~ | ||
~ Unless required by applicable law or agreed to in writing, software | ||
~ distributed under the License is distributed on an "AS IS" BASIS, | ||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
~ See the License for the specific language governing permissions and | ||
~ limitations under the License. | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ | ||
package com.adobe.cq.wcm.core.components.internal.models.v1.datalayer; | ||
|
||
import com.adobe.cq.wcm.core.components.models.datalayer.AssetData; | ||
import com.adobe.cq.wcm.core.components.models.datalayer.VideoData; | ||
import com.adobe.cq.wcm.core.components.models.datalayer.builder.DataLayerSupplier; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.function.Supplier; | ||
|
||
/** | ||
* {@link DataLayerSupplier} backed video component data implementation. | ||
*/ | ||
public class VideoDataImpl extends ComponentDataImpl implements VideoData { | ||
/** | ||
* The asset field value. | ||
*/ | ||
private AssetData assetData; | ||
|
||
/** | ||
* Construct the data layer model. | ||
* | ||
* @param supplier The data layer supplier. | ||
*/ | ||
public VideoDataImpl(@NotNull DataLayerSupplier supplier) { | ||
super(supplier); | ||
} | ||
|
||
@Override | ||
@Nullable | ||
public AssetData getAssetData() { | ||
if (this.assetData == null) { | ||
this.assetData = this.getDataLayerSupplier() | ||
.getAssetData() | ||
.map(Supplier::get) | ||
.orElse(null); | ||
} | ||
return this.assetData; | ||
} | ||
} |
107 changes: 107 additions & 0 deletions
107
bundles/core/src/main/java/com/adobe/cq/wcm/core/components/models/Video.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
~ Copyright 2021 Adobe | ||
~ | ||
~ Licensed under the Apache License, Version 2.0 (the "License"); | ||
~ you may not use this file except in compliance with the License. | ||
~ You may obtain a copy of the License at | ||
~ | ||
~ http://www.apache.org/licenses/LICENSE-2.0 | ||
~ | ||
~ Unless required by applicable law or agreed to in writing, software | ||
~ distributed under the License is distributed on an "AS IS" BASIS, | ||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
~ See the License for the specific language governing permissions and | ||
~ limitations under the License. | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ | ||
package com.adobe.cq.wcm.core.components.models; | ||
|
||
import org.osgi.annotation.versioning.ConsumerType; | ||
|
||
@ConsumerType | ||
public interface Video extends Component { | ||
|
||
/** | ||
* Name of the property that defines the image to be shown while the video is downloading. | ||
* | ||
*/ | ||
String PN_POSTER_REFERENCE = "posterImageReference"; | ||
|
||
/** | ||
* Name of the property that defines if video controls should be hidden. | ||
* | ||
*/ | ||
String PN_HIDE_CONTROL = "hideControl"; | ||
|
||
/** | ||
* Name of the property that defines if video looping is enabled. | ||
* | ||
*/ | ||
String PN_LOOP_ENABLED = "loopEnabled"; | ||
|
||
/** | ||
* Name of the property that defines if video autoplay is enabled. | ||
* | ||
*/ | ||
String PN_AUTOPLAY_ENABLED = "autoplayEnabled"; | ||
|
||
/** | ||
* Name of the property that defines if video autoplay is enabled. | ||
* | ||
*/ | ||
String PN_MUTED_ENABLED = "mutedEnabled"; | ||
|
||
/** | ||
* Returns the file reference of the current video, if one exists. | ||
* | ||
* @return Returns the file reference of the current video, if one exists, or {@code null} otherwise | ||
*/ | ||
default String getFileReference() { | ||
return null; | ||
} | ||
|
||
/** | ||
* Returns the file reference of the image used as a poser for the video | ||
* | ||
* @return Returns the file reference of the image used as a poser for the video, or {@code null} if it doesn't exist | ||
*/ | ||
default String getPosterImageReference() { | ||
return null; | ||
} | ||
|
||
/** | ||
* Returns weather the video controls should be hidden or not | ||
* | ||
* @return Returns true if video controls should be hidden, false otherwise | ||
*/ | ||
default boolean isHideControl() { | ||
return false; | ||
} | ||
|
||
/** | ||
* Returns weather the video loop should be enabled or not | ||
* | ||
* @return Returns true if video loop should be enabled, false otherwise | ||
*/ | ||
default boolean isLoopEnabled() { | ||
return false; | ||
} | ||
|
||
/** | ||
* Returns weather the video autoplay should be enabled or not | ||
* | ||
* @return Returns true if video autoplay should be enabled, false otherwise | ||
*/ | ||
default boolean isAutoplayEnabled() { | ||
return false; | ||
} | ||
|
||
/** | ||
* Returns weather the video is set to be muted or not | ||
* | ||
* @return Returns true if video id set to muted, false otherwise | ||
*/ | ||
default boolean isMuted() { | ||
return false; | ||
} | ||
|
||
} |
32 changes: 32 additions & 0 deletions
32
bundles/core/src/main/java/com/adobe/cq/wcm/core/components/models/datalayer/VideoData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
~ Copyright 2020 Adobe | ||
~ | ||
~ Licensed under the Apache License, Version 2.0 (the "License"); | ||
~ you may not use this file except in compliance with the License. | ||
~ You may obtain a copy of the License at | ||
~ | ||
~ http://www.apache.org/licenses/LICENSE-2.0 | ||
~ | ||
~ Unless required by applicable law or agreed to in writing, software | ||
~ distributed under the License is distributed on an "AS IS" BASIS, | ||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
~ See the License for the specific language governing permissions and | ||
~ limitations under the License. | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ | ||
package com.adobe.cq.wcm.core.components.models.datalayer; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
public interface VideoData extends ComponentData { | ||
/** | ||
* Returns the asset associated with the video. | ||
* | ||
* @return Asset data model | ||
* | ||
* @since com.adobe.cq.wcm.core.components.models.datalayer 1.0.0 | ||
*/ | ||
@JsonProperty("video") | ||
default AssetData getAssetData() { | ||
return null; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to add the poster here as well?