Skip to content
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
wants to merge 39 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
a14f5ec
Updating branch
georgecamilar May 25, 2021
ab50cd1
Contributing to adobe core components:
May 25, 2021
94f5ba7
README corrections
May 25, 2021
2d363fc
Remove unused alt property from video component dialog
May 25, 2021
9b48a79
Fixing .content.xml breaking the build
georgecamilar May 26, 2021
eef102b
feature: Video Component:
May 26, 2021
3382d03
feature(video-component) : Adding Video Component to Adobe Core Compo…
May 31, 2021
58d67d7
feature(Contribute to adobe core components): Video Component
Jun 2, 2021
286abcb
feature(video-component-v1):
Jun 7, 2021
deff7b9
feature(contribute-video-component): Video
Jun 8, 2021
86bd3b8
Joel Commit
Jun 8, 2021
3b9bab0
fixing unit tests and video component
Jun 9, 2021
9242b6b
feature(contribute-video-to-adobe-core-components):
Jun 9, 2021
54efe17
Unit Tests adaption after changes
Jun 9, 2021
1cd14e9
pushing a video sample for the video component
Jun 14, 2021
6bde62c
Merge branch 'development' of https://github.com/georgecamilar/aem-co…
georgecamilar Jun 14, 2021
6343660
Add partial selenium tests for Video Component
gabriel-negrusa Jul 9, 2021
6dc33cc
switcch to preview mode for attributes checks
cosminmmagdas Jul 9, 2021
2b8b976
add video test case
cosminmmagdas Jul 10, 2021
a536238
video not added test case
cosminmmagdas Jul 10, 2021
6c4aafd
code cleanup
cosminmmagdas Jul 11, 2021
6bf3b1c
code cleanup
cosminmmagdas Jul 12, 2021
f19729a
code cleanup
cosminmmagdas Jul 12, 2021
6ac5d40
code cleanup
cosminmmagdas Jul 12, 2021
e9d8ccd
code cleanup
cosminmmagdas Jul 12, 2021
d8823a8
login as administrator in order to allow proper cleanup
cosminmmagdas Jul 12, 2021
b3a0ee1
add selenium tests for video properties
gabriel-negrusa Jul 14, 2021
d3dce3c
Fix Video component selenium tests
gabriel-negrusa Jul 16, 2021
0cee05a
Remove unused Video alt property
gabriel-negrusa Jul 16, 2021
ce6dd8c
Add mute button for video
gabriel-negrusa Jul 20, 2021
dd8604a
fix linting errors
gabriel-negrusa Jul 20, 2021
70575af
Add mute checkbox to video model
gabriel-negrusa Jul 20, 2021
d8d3807
Add video mute button to component examples
gabriel-negrusa Jul 21, 2021
bbb1149
Update video component unit tests to include mute property
gabriel-negrusa Jul 22, 2021
bcd7736
Update video selenium tests to account for mute button
gabriel-negrusa Jul 22, 2021
5672d77
Make video fields descriptions more detailed
gabriel-negrusa Jul 23, 2021
a50b234
Merge branch 'development' of https://github.com/georgecamilar/aem-co…
gabriel-negrusa Jul 23, 2021
98a108a
Change company field in video readme
gabriel-negrusa Jul 23, 2021
eb86fc4
Remove leftover debug command
gabriel-negrusa Jul 28, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,21 @@ Set of standardized Web Content Management (WCM) components for [Adobe Experienc
18. [Experience Fragment](content/src/content/jcr_root/apps/core/wcm/components/experiencefragment/v1/experiencefragment)
19. [Content Fragment](content/src/content/jcr_root/apps/core/wcm/components/contentfragment/v1/contentfragment)
20. [Content Fragment List](content/src/content/jcr_root/apps/core/wcm/components/contentfragmentlist/v1/contentfragmentlist)

21. [Video](content/src/content/jcr_root/apps/core/wcm/components/video/v1/video)
### Container Components

21. [Container](content/src/content/jcr_root/apps/core/wcm/components/container/v1/container)
22. [Carousel](content/src/content/jcr_root/apps/core/wcm/components/carousel/v1/carousel)
23. [Tabs](content/src/content/jcr_root/apps/core/wcm/components/tabs/v1/tabs)
24. [Accordion](content/src/content/jcr_root/apps/core/wcm/components/accordion/v1/accordion)
22. [Container](content/src/content/jcr_root/apps/core/wcm/components/container/v1/container)
23. [Carousel](content/src/content/jcr_root/apps/core/wcm/components/carousel/v1/carousel)
24. [Tabs](content/src/content/jcr_root/apps/core/wcm/components/tabs/v1/tabs)
25. [Accordion](content/src/content/jcr_root/apps/core/wcm/components/accordion/v1/accordion)

### Form Components

25. [Core Form container](content/src/content/jcr_root/apps/core/wcm/components/form/container/v2/container)
26. [Form text field](content/src/content/jcr_root/apps/core/wcm/components/form/text/v2/text)
27. [Form options field](content/src/content/jcr_root/apps/core/wcm/components/form/options/v2/options)
28. [Form hidden field](content/src/content/jcr_root/apps/core/wcm/components/form/hidden/v2/hidden)
29. [Form button](content/src/content/jcr_root/apps/core/wcm/components/form/button/v2/button)
26. [Core Form container](content/src/content/jcr_root/apps/core/wcm/components/form/container/v2/container)
27. [Form text field](content/src/content/jcr_root/apps/core/wcm/components/form/text/v2/text)
28. [Form options field](content/src/content/jcr_root/apps/core/wcm/components/form/options/v2/options)
29. [Form hidden field](content/src/content/jcr_root/apps/core/wcm/components/form/hidden/v2/hidden)
30. [Form button](content/src/content/jcr_root/apps/core/wcm/components/form/button/v2/button)

### Roadmap

Expand Down
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);
}
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;
}
}
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;
}

}
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() {
Copy link
Member

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?

return null;
}
}
Loading