You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by dk...@apache.org on 2019/10/19 01:37:11 UTC

[sling-org-apache-sling-app-cms] 06/06: Adds a component to support SLING-8791

This is an automated email from the ASF dual-hosted git repository.

dklco pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-app-cms.git

commit eca378a7093129641b697e67acd6182ed1429de4
Author: Dan Klco <dk...@apache.org>
AuthorDate: Fri Oct 18 21:36:53 2019 -0400

    Adds a component to support SLING-8791
---
 .../reference/components/general/reference.json    |  5 ++++
 .../components/general/reference/edit.json         | 17 +++++++++++++
 .../components/general/reference/reference.jsp     | 28 ++++++++++++++++++++++
 3 files changed, 50 insertions(+)

diff --git a/reference/src/main/resources/jcr_root/apps/reference/components/general/reference.json b/reference/src/main/resources/jcr_root/apps/reference/components/general/reference.json
new file mode 100644
index 0000000..656ded4
--- /dev/null
+++ b/reference/src/main/resources/jcr_root/apps/reference/components/general/reference.json
@@ -0,0 +1,5 @@
+{
+	"jcr:primaryType": "sling:Component",
+    "componentType": "General",
+    "jcr:title": "Reference"
+}
\ No newline at end of file
diff --git a/reference/src/main/resources/jcr_root/apps/reference/components/general/reference/edit.json b/reference/src/main/resources/jcr_root/apps/reference/components/general/reference/edit.json
new file mode 100644
index 0000000..94c5421
--- /dev/null
+++ b/reference/src/main/resources/jcr_root/apps/reference/components/general/reference/edit.json
@@ -0,0 +1,17 @@
+ {
+    "jcr:primaryType": "nt:unstructured",
+    "sling:resourceType": "sling-cms/components/editor/slingform",
+    "button": "Save Reference",
+    "fields": {
+        "jcr:primaryType": "nt:unstructured",
+        "sling:resourceType": "sling-cms/components/general/container",
+        "reference": {
+            "jcr:primaryType": "nt:unstructured",
+            "sling:resourceType": "sling-cms/components/editor/fields/path",
+            "basePath": "/content",
+            "label": "Reference Source",
+            "name": "reference",
+            "required": true
+        }
+    }
+}
\ No newline at end of file
diff --git a/reference/src/main/resources/jcr_root/apps/reference/components/general/reference/reference.jsp b/reference/src/main/resources/jcr_root/apps/reference/components/general/reference/reference.jsp
new file mode 100644
index 0000000..4c1a506
--- /dev/null
+++ b/reference/src/main/resources/jcr_root/apps/reference/components/general/reference/reference.jsp
@@ -0,0 +1,28 @@
+<%-- /*
+ * 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"%>
+<c:if test="${not empty properties.reference}">
+    <c:set var="referenceResource" value="${sling:getResource(resourceResolver,properties.reference)}" />
+    <c:if test="${referenceResource != null}">
+        <c:set var="originalEditEnabled" value="${cmsEditEnabled}"/>
+        <c:set var="cmsEditEnabled" value="false" scope="request" />
+        <sling:include resource="${sling:getResource(resourceResolver,properties.reference)}" />
+        <c:set var="cmsEditEnabled" value="${originalEditEnabled}" scope="request" />
+    </c:if>
+</c:if>
\ No newline at end of file