forked from adobe/adobe-dx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adobeGH-24 make StyleService responsive
- Loading branch information
Showing
10 changed files
with
313 additions
and
98 deletions.
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
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
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
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
65 changes: 65 additions & 0 deletions
65
bundles/core/src/main/java/com/adobe/dx/utils/RequestUtil.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,65 @@ | ||
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
~ 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.dx.utils; | ||
|
||
import com.adobe.dx.bindings.internal.DxBindingsValueProvider; | ||
import com.adobe.dx.responsive.Breakpoint; | ||
|
||
import java.util.Map; | ||
|
||
import org.apache.sling.api.SlingHttpServletRequest; | ||
import org.apache.sling.api.resource.ValueMap; | ||
import org.apache.sling.api.scripting.SlingBindings; | ||
|
||
/** | ||
* Utility class for fetching utility objects from request | ||
*/ | ||
public class RequestUtil { | ||
private RequestUtil() { | ||
} | ||
|
||
/** | ||
* @param request current request | ||
* @return sling bindings | ||
*/ | ||
public static final SlingBindings getBindings(SlingHttpServletRequest request) { | ||
return (SlingBindings)request.getAttribute(SlingBindings.class.getName()); | ||
} | ||
|
||
/** | ||
* @param request current request | ||
* @return current DX policy | ||
*/ | ||
public static final ValueMap getPolicy(SlingHttpServletRequest request) { | ||
return (ValueMap)getBindings(request).get(DxBindingsValueProvider.POLICY_KEY); | ||
} | ||
|
||
/** | ||
* @param request current request | ||
* @return current set of breakpoints | ||
*/ | ||
public static final Breakpoint[] getBreakpoints(SlingHttpServletRequest request) { | ||
return (Breakpoint[]) getBindings(request).get(DxBindingsValueProvider.BP_KEY); | ||
} | ||
|
||
/** | ||
* @param request current request | ||
* @return current set of responsive properties | ||
*/ | ||
public static final Map<String, Object> getResponsiveProperties(SlingHttpServletRequest request) { | ||
return (Map<String, Object>) getBindings(request).get(DxBindingsValueProvider.RESP_PROPS_KEY); | ||
} | ||
} |
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
42 changes: 42 additions & 0 deletions
42
bundles/core/src/test/java/com/adobe/dx/style/internal/AbstractStyleWorkerTest.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,42 @@ | ||
/******************************************************************************* | ||
* | ||
* ADOBE CONFIDENTIAL | ||
* __________________ | ||
* | ||
* Copyright 2019 Adobe | ||
* All Rights Reserved. | ||
* | ||
* NOTICE: All information contained herein is, and remains | ||
* the property of Adobe and its suppliers, if any. The intellectual | ||
* and technical concepts contained herein are proprietary to Adobe | ||
* and its suppliers and are protected by all applicable intellectual | ||
* property laws, including trade secret and copyright laws. | ||
* Dissemination of this information or reproduction of this material | ||
* is strictly forbidden unless prior written permission is obtained | ||
* from Adobe. | ||
******************************************************************************/ | ||
|
||
package com.adobe.dx.style.internal; | ||
|
||
import com.adobe.dx.bindings.internal.DxBindingsValueProvider; | ||
import com.adobe.dx.responsive.Breakpoint; | ||
import com.adobe.dx.style.StyleWorker; | ||
import com.adobe.dx.testing.AbstractTest; | ||
|
||
import org.apache.sling.api.scripting.SlingBindings; | ||
|
||
public abstract class AbstractStyleWorkerTest extends AbstractTest { | ||
|
||
abstract StyleWorker getWorker(); | ||
|
||
String getDeclaration() { | ||
return getDeclaration(null); | ||
} | ||
|
||
String getDeclaration(Breakpoint breakpoint) { | ||
|
||
SlingBindings bindings = (SlingBindings)context.request().getAttribute(SlingBindings.class.getName()); | ||
bindings.put(DxBindingsValueProvider.POLICY_KEY, getVM(CONTENT_ROOT)); | ||
return getWorker().getDeclaration(breakpoint, context.request()); | ||
} | ||
} |
Oops, something went wrong.