SLING-10767 - Added integration to the image component to support picking renditions and basic personal rendition authoring
diff --git a/api/src/test/resources/content.json b/api/src/test/resources/content.json
index 36fd389..b7b0f15 100644
--- a/api/src/test/resources/content.json
+++ b/api/src/test/resources/content.json
@@ -60,7 +60,7 @@
"jcr:content": {
"jcr:primaryType": "nt:unstructured",
"jcr:title": "Not Published",
- "sling:template": "/conf/asf/site/templates/base-page",
+ "sling:template": "/conf/global/site/templates/base-page",
"sling:resourceType": "reference/components/pages/base",
"sling:published": false
}
diff --git a/reference/src/main/resources/jcr_root/apps/reference/components/general/image/edit.json b/reference/src/main/resources/jcr_root/apps/reference/components/general/image/edit.json
index 4b3cf95..2e6b356 100644
--- a/reference/src/main/resources/jcr_root/apps/reference/components/general/image/edit.json
+++ b/reference/src/main/resources/jcr_root/apps/reference/components/general/image/edit.json
@@ -34,11 +34,6 @@
"name": "transformationFormat",
"required": false,
"options": {
- "default": {
- "jcr:primaryType": "nt:unstructured",
- "label": "Default Extension",
- "value": "default"
- },
"png": {
"jcr:primaryType": "nt:unstructured",
"label": "PNG",
diff --git a/reference/src/main/resources/jcr_root/apps/reference/components/general/image/image.jsp b/reference/src/main/resources/jcr_root/apps/reference/components/general/image/image.jsp
index 31cb584..320152a 100644
--- a/reference/src/main/resources/jcr_root/apps/reference/components/general/image/image.jsp
+++ b/reference/src/main/resources/jcr_root/apps/reference/components/general/image/image.jsp
@@ -20,7 +20,7 @@
<c:if test="${not empty properties.src}">
<c:if test="${not empty properties.transformation}">
<c:choose>
- <c:when test="${properties.transformationFormat == 'default'}">
+ <c:when test="${fn:indexOf(properties.transformation,'.') != -1}">
<c:set var="transform" value=".transform/${properties.transformation}" />
</c:when>
<c:otherwise>
diff --git a/reference/src/main/resources/jcr_root/apps/reference/components/general/image/transformations.jsp b/reference/src/main/resources/jcr_root/apps/reference/components/general/image/transformations.jsp
index 6f2f03d..b19eb6a 100644
--- a/reference/src/main/resources/jcr_root/apps/reference/components/general/image/transformations.jsp
+++ b/reference/src/main/resources/jcr_root/apps/reference/components/general/image/transformations.jsp
@@ -19,8 +19,20 @@
<%@include file="/libs/sling-cms/global.jsp"%>
<sling:adaptTo adaptable="${slingRequest}" adaptTo="org.apache.sling.thumbnails.RenderedResource" var="rendered" />
<option value=""><fmt:message key="None" /></option>
-<c:forEach var="rendition" items="${rendered.supportedRenditions}">
- <option ${slingRequest.requestPathInfo.suffixResource.valueMap.transformation == rendition ? 'selected' : ''} value="${sling:encode(rendition,'HTML_ATTR')}">
- ${sling:encode(rendition,'HTML')}
- </option>
-</c:forEach>
\ No newline at end of file
+<fmt:message key="Asset-Specific Renditions" var="specificMsg" />
+<optgroup label="${specificMsg}">
+ <c:forEach var="rendition" items="${rendered.supportedRenditions}">
+ <option ${slingRequest.requestPathInfo.suffixResource.valueMap.transformation == rendition ? 'selected' : ''} value="${sling:encode(rendition,'HTML_ATTR')}">
+ ${sling:encode(rendition,'HTML')}
+ </option>
+ </c:forEach>
+</optgroup>
+<fmt:message key="All Renditions" var="allMsg" />
+<optgroup label="${allMsg}">
+ <sling:findResources query="SELECT * FROM [nt:unstructured] WHERE ISDESCENDANTNODE([/conf]) AND [sling:resourceType]='sling/thumbnails/transformation' ORDER BY [name]" language="JCR-SQL2" var="transformations" />
+ <c:forEach var="transformation" items="${transformations}">
+ <option ${slingRequest.requestPathInfo.suffixResource.valueMap.transformation == transformation.name ? 'selected' : ''} value="${sling:encode(transformation.valueMap.name,'HTML_ATTR')}">
+ ${sling:encode(transformation.valueMap.name,'HTML')}
+ </option>
+ </c:forEach>
+</optgroup>
\ No newline at end of file
diff --git a/reference/src/main/resources/jcr_root/conf/asf.json b/reference/src/main/resources/jcr_root/conf/asf.json
index c1bcde6..b18a3d5 100644
--- a/reference/src/main/resources/jcr_root/conf/asf.json
+++ b/reference/src/main/resources/jcr_root/conf/asf.json
@@ -2,7 +2,7 @@
"jcr:primaryType": "sling:OrderedFolder",
"jcr:content": {
"jcr:primaryType": "nt:unstructured",
- "jcr:title": "Global"
+ "jcr:title": "Apache Software Foundation"
},
"site": {
"jcr:primaryType": "sling:OrderedFolder",
@@ -10,6 +10,105 @@
"jcr:primaryType": "nt:unstructured",
"jcr:title": "ASF Site Configuration"
},
+ "policies": {
+ "jcr:primaryType": "sling:Config",
+ "jcr:title": "Default Policy",
+ "sling:resourceType": "sling-cms/components/caconfig/policies",
+ "bootstrap": {
+ "jcr:primaryType": "nt:unstructured",
+ "jcr:title": "Bootstrap CSS Policy",
+ "availableComponentTypes": ["General"],
+ "sling:resourceType": "sling-cms/components/caconfig/policy",
+ "componentConfigurations": {
+ "jcr:primaryType": "nt:unstructured",
+ "component": {
+ "jcr:primaryType": "nt:unstructured",
+ "fieldConfigGroups": "Form Field,General",
+ "checkInputClass": "form-check-input",
+ "fieldGroupClass": "form-group",
+ "checkLabelClass": "form-check-label",
+ "fieldRequiredClass": "text-danger",
+ "type": "reference/components/forms/form",
+ "submitClass": "btn btn-primary",
+ "fieldClass": "form-control",
+ "actionConfigGroups": "Form Action",
+ "providerConfigGroups": "Form Value Provider",
+ "sling:resourceType": "sling-cms/components/caconfig/component",
+ "checkFieldClass": "form-check",
+ "formClass": "form",
+ "alertClass": "alert alert-dark"
+ },
+ "component_1310080869": {
+ "jcr:primaryType": "nt:unstructured",
+ "ctaClasses": ["Primary=btn-primary"],
+ "type": "reference/components/general/cta",
+ "sling:resourceType": "sling-cms/components/caconfig/component"
+ },
+ "component_867209498": {
+ "jcr:primaryType": "nt:unstructured",
+ "type": "reference/components/general/columncontrol",
+ "containerclass": "container",
+ "columns": [
+ "100%=col-md-12",
+ "50% 50%=col-6,col-6",
+ "33% 33% 33%=col-4,col-4,col-4"
+ ],
+ "rowClass": "row",
+ "sling:resourceType": "sling-cms/components/caconfig/component"
+ },
+ "component_1644835788": {
+ "jcr:primaryType": "nt:unstructured",
+ "iframeClass": "frame",
+ "type": "reference/components/general/iframe",
+ "sling:resourceType": "sling-cms/components/caconfig/component",
+ "wrapperClasses": ["Responsive=embed-responsive"]
+ },
+ "component_1264147350": {
+ "jcr:primaryType": "nt:unstructured",
+ "type": "reference/components/general/image",
+ "sling:resourceType": "sling-cms/components/caconfig/component",
+ "imageClasses": ["Responsive=img-responsive"]
+ },
+ "component_2817746": {
+ "jcr:primaryType": "nt:unstructured",
+ "pageItemClass": "page-item",
+ "pageLinkClass": "page-link",
+ "type": "reference/components/general/list",
+ "paginationClass": "pagination",
+ "sling:resourceType": "sling-cms/components/caconfig/component"
+ },
+ "component_55724978": {
+ "jcr:primaryType": "nt:unstructured",
+ "pageItemClass": "page-item",
+ "pageLinkClass": "page-link",
+ "searchClass": "search",
+ "resultClass": "search-result",
+ "type": "reference/components/general/search",
+ "paginationClass": "pagination",
+ "resultHeaderClass": "search-header",
+ "sling:resourceType": "sling-cms/components/caconfig/component"
+ },
+ "component_928101893": {
+ "jcr:primaryType": "nt:unstructured",
+ "buttonClass": "btn btn-primary",
+ "type": "reference/components/general/searchform",
+ "sling:resourceType": "sling-cms/components/caconfig/component",
+ "inputClass": "input",
+ "formClass": "form"
+ },
+ "component_1816434016": {
+ "jcr:primaryType": "nt:unstructured",
+ "tagPage": "",
+ "listClass": "tag-list",
+ "type": "reference/components/general/tags",
+ "listTag": "div",
+ "sling:resourceType": "sling-cms/components/caconfig/component",
+ "itemTag": "div",
+ "itemClass": "tag-item"
+ }
+ }
+ }
+ },
"templates": {
"jcr:primaryType": "sling:Config",
"jcr:title": "Templates",
@@ -45,7 +144,7 @@
"jcr:primaryType": "nt:unstructured",
"sling:resourceType": "sling-cms/components/caconfig/policymapping",
"pathPattern": ".*",
- "policyPath": "/conf/global/site/policies/bootstrap"
+ "policyPath": "/conf/asf/site/policies/bootstrap"
}
}
},
diff --git a/ui/src/main/resources/jcr_root/libs/sling-cms/components/cms/columns/actions/actions.jsp b/ui/src/main/resources/jcr_root/libs/sling-cms/components/cms/columns/actions/actions.jsp
index 13601ac..baffbe5 100644
--- a/ui/src/main/resources/jcr_root/libs/sling-cms/components/cms/columns/actions/actions.jsp
+++ b/ui/src/main/resources/jcr_root/libs/sling-cms/components/cms/columns/actions/actions.jsp
@@ -17,7 +17,7 @@
* under the License.
*/ --%>
<%@include file="/libs/sling-cms/global.jsp"%>
-<td class="${colConfig.valueMap.show ? '' : 'is-vhidden'} cell-actions">
+<td class="${colConfig.valueMap.show ? '' : 'cell-actions is-vhidden'}">
<c:forEach var="ac" items="${sling:listChildren(colConfig)}">
<c:set var="actionConfig" value="${ac}" scope="request" />
<sling:include path="${resource.path}" resourceType="${actionConfig.resourceType}" />
diff --git a/ui/src/main/resources/jcr_root/libs/sling-cms/components/cms/transformationredirect/transformationredirect.jsp b/ui/src/main/resources/jcr_root/libs/sling-cms/components/cms/transformationredirect/transformationredirect.jsp
new file mode 100644
index 0000000..95a2003
--- /dev/null
+++ b/ui/src/main/resources/jcr_root/libs/sling-cms/components/cms/transformationredirect/transformationredirect.jsp
@@ -0,0 +1,21 @@
+<%-- /*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */ --%>
+<%@include file="/libs/sling-cms/global.jsp"%>
+<sling:adaptTo adaptable="${resourceResolver}" adaptTo="org.apache.sling.cms.AuthorizableWrapper" var="auth" />
+<c:redirect url = "/cms/transformations/user.html${auth.authorizable.path}/transformations"/>
\ No newline at end of file
diff --git a/ui/src/main/resources/jcr_root/libs/sling-cms/components/editor/scripts/transformations.jsp b/ui/src/main/resources/jcr_root/libs/sling-cms/components/editor/scripts/transformations.jsp
index 7f9524e..a0b0058 100644
--- a/ui/src/main/resources/jcr_root/libs/sling-cms/components/editor/scripts/transformations.jsp
+++ b/ui/src/main/resources/jcr_root/libs/sling-cms/components/editor/scripts/transformations.jsp
@@ -17,10 +17,11 @@
* under the License.
*/ --%>
<%@include file="/libs/sling-cms/global.jsp"%>
-<sling:adaptTo adaptable="${slingRequest.requestPathInfo.suffixResource}" adaptTo="org.apache.sling.thumbnails.RenderedResource" var="rendered" />
-<option value="">None</option>
-<c:forEach var="transformation" items="${rendered.availableTransformations}">
- <option ${slingRequest.requestPathInfo.suffixResource.valueMap.transformation == transformation.name ? 'selected' : ''} value="${sling:encode(transformation.path,'HTML_ATTR')}">
+ <sling:adaptTo adaptable="${resourceResolver}" adaptTo="org.apache.sling.cms.AuthorizableWrapper" var="auth" />
+<sling:findResources query="SELECT * FROM [nt:unstructured] WHERE (ISDESCENDANTNODE([/conf]) OR ISDESCENDANTNODE([${auth.authorizable.path }])) AND [sling:resourceType]='sling/thumbnails/transformation' ORDER BY [name]" language="JCR-SQL2" var="transformations" />
+<option value=""></option>
+<c:forEach var="transformation" items="${transformations}">
+ <option value="${sling:encode(transformation.path,'HTML_ATTR')}">
${sling:encode(transformation.name,'HTML')}
</option>
</c:forEach>
\ No newline at end of file
diff --git a/ui/src/main/resources/jcr_root/libs/sling-cms/components/pages/base/nav.jsp b/ui/src/main/resources/jcr_root/libs/sling-cms/components/pages/base/nav.jsp
index 1a342e9..4fa2494 100644
--- a/ui/src/main/resources/jcr_root/libs/sling-cms/components/pages/base/nav.jsp
+++ b/ui/src/main/resources/jcr_root/libs/sling-cms/components/pages/base/nav.jsp
@@ -54,6 +54,12 @@
</em>
<fmt:message key="Profile" />
</a>
+ <a class="navbar-item Fetch-Modal" data-title="User Transformations" data-path=".Main-Content form" href="/cms/transformations/user.html${auth.authorizable.path}/transformations">
+ <em class="jam jam-pictures">
+ <span class="is-sr-only">My Transformations</span>
+ </em>
+ <fmt:message key="My Transformations" />
+ </a>
<a class="navbar-item" href="${branding.helpLink}" target="_blank" rel="noopener noreferrer">
<em class="jam jam-help">
<span class="is-sr-only">Help</span>
diff --git a/ui/src/main/resources/jcr_root/libs/sling-cms/content/file/addrendition.json b/ui/src/main/resources/jcr_root/libs/sling-cms/content/file/addrendition.json
index b643215..c740deb 100644
--- a/ui/src/main/resources/jcr_root/libs/sling-cms/content/file/addrendition.json
+++ b/ui/src/main/resources/jcr_root/libs/sling-cms/content/file/addrendition.json
@@ -26,7 +26,11 @@
"jcr:primaryType": "nt:unstructured",
"sling:resourceType": "sling-cms/components/editor/fields/text",
"label": "Rendition Name",
- "name": "renditionName"
+ "name": "renditionName",
+ "events": {
+ "jcr:primaryType": "nt:unstructured",
+ "change": "const renditionNameEl = document.getElementById('renditionName');\nif(renditionNameEl.value.indexOf('.') === -1){\n renditionNameEl.value = renditionNameEl.value+'.'+document.getElementById('format').value\n}"
+ }
},
"transformation": {
"jcr:primaryType": "nt:unstructured",
diff --git a/ui/src/main/resources/jcr_root/libs/sling-cms/content/file/renditions.json b/ui/src/main/resources/jcr_root/libs/sling-cms/content/file/renditions.json
index 65413d7..3c68520 100644
--- a/ui/src/main/resources/jcr_root/libs/sling-cms/content/file/renditions.json
+++ b/ui/src/main/resources/jcr_root/libs/sling-cms/content/file/renditions.json
@@ -12,11 +12,17 @@
"sling:resourceType": "sling-cms/components/cms/contentactions",
"includeSwitcher": false,
"actions": {
- "page": {
+ "rendition": {
"jcr:primaryType": "nt:unstructured",
"label": "Rendition",
"prefix": "/cms/file/addrendition.html/bin/sling/thumbnails/transform?resource=",
"suffix":"/../../"
+ },
+ "my-renditions": {
+ "jcr:primaryType": "nt:unstructured",
+ "label": "My Transformations",
+ "prefix": "/cms/transformations/userredirect.html",
+ "suffix":"/../../"
}
}
},
diff --git a/ui/src/main/resources/jcr_root/libs/sling-cms/content/transformations/user.json b/ui/src/main/resources/jcr_root/libs/sling-cms/content/transformations/user.json
new file mode 100644
index 0000000..6b02135
--- /dev/null
+++ b/ui/src/main/resources/jcr_root/libs/sling-cms/content/transformations/user.json
@@ -0,0 +1,92 @@
+{
+ "jcr:primaryType": "sling:Page",
+ "jcr:content": {
+ "sling:resourceType": "sling-cms/components/pages/modal",
+ "jcr:title": "My Transformations",
+ "jcr:primaryType": "nt:unstructured",
+ "container": {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "sling-cms/components/general/container",
+ "contentactions": {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "sling-cms/components/cms/contentactions",
+ "includeSwitcher": false,
+ "actions": {
+ "transformation": {
+ "jcr:primaryType": "nt:unstructured",
+ "label": "Transformation",
+ "prefix": "/cms/transformations/create.html",
+ "suffix": "/../"
+ }
+ }
+ },
+ "contenttable": {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "sling-cms/components/cms/contenttable",
+ "columns": {
+ "jcr:primaryType": "nt:unstructured",
+ "name": {
+ "jcr:primaryType": "nt:unstructured",
+ "title": "Name"
+ },
+ "title": {
+ "jcr:primaryType": "nt:unstructured",
+ "title": "Transformation Name"
+ },
+ "lastModified": {
+ "jcr:primaryType": "nt:unstructured",
+ "title": "Last Modified"
+ },
+ "transformation-actions": {
+ "jcr:primaryType": "nt:unstructured",
+ "title": "Actions"
+ }
+ },
+ "types": {
+ "jcr:primaryType": "nt:unstructured",
+ "nt:unstructured": {
+ "jcr:primaryType": "nt:unstructured",
+ "columns": {
+ "jcr:primaryType": "nt:unstructured",
+ "name": {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "sling-cms/components/cms/columns/name",
+ "link": false
+ },
+ "transformationName": {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "sling-cms/components/cms/columns/text",
+ "property": "name"
+ },
+ "lastModified": {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "sling-cms/components/cms/columns/lastmodified",
+ "subPath": ""
+ },
+ "transformation-actions": {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "sling-cms/components/cms/columns/actions",
+ "show": true,
+ "edit": {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "sling-cms/components/cms/actions/basic",
+ "new": false,
+ "title": "Edit Transformation",
+ "icon": "pencil-f",
+ "prefix": "/cms/transformations/useredit.html"
+ },
+ "delete": {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "sling-cms/components/cms/actions/modal",
+ "title": "Delete Transformation",
+ "icon": "trash",
+ "prefix": "/cms/shared/delete.html"
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/ui/src/main/resources/jcr_root/libs/sling-cms/content/transformations/useredit.json b/ui/src/main/resources/jcr_root/libs/sling-cms/content/transformations/useredit.json
new file mode 100644
index 0000000..f0fd462
--- /dev/null
+++ b/ui/src/main/resources/jcr_root/libs/sling-cms/content/transformations/useredit.json
@@ -0,0 +1,23 @@
+{
+ "jcr:primaryType": "sling:Page",
+ "jcr:content": {
+ "sling:resourceType": "sling-cms/components/pages/base",
+ "jcr:title": "Edit Transformation",
+ "jcr:primaryType": "nt:unstructured",
+ "container": {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "sling-cms/components/general/container",
+ "richtext": {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "sling-cms/components/general/textelement",
+ "i18n": true,
+ "level": "h2",
+ "text": "Edit Transformation"
+ },
+ "transformationeditor": {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "sling/thumbnails/transformation"
+ }
+ }
+ }
+}
diff --git a/ui/src/main/resources/jcr_root/libs/sling-cms/content/transformations/userredirect.json b/ui/src/main/resources/jcr_root/libs/sling-cms/content/transformations/userredirect.json
new file mode 100644
index 0000000..0d1f7cc
--- /dev/null
+++ b/ui/src/main/resources/jcr_root/libs/sling-cms/content/transformations/userredirect.json
@@ -0,0 +1,4 @@
+{
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "sling-cms/components/cms/transformationredirect"
+}
\ No newline at end of file