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 2018/05/26 18:42:11 UTC

[sling-whiteboard] 03/03: Updating tags to be a configurable component

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-whiteboard.git

commit ffc75824c36ccbeeb4bd88e8257e2c795296ac6c
Author: Dan Klco <dk...@apache.org>
AuthorDate: Sat May 26 14:42:01 2018 -0400

    Updating tags to be a configurable component
---
 .../apps/reference/components/general/tags.json    |  5 ++++
 .../reference/components/general/tags/config.json  | 34 ++++++++++++++++++++++
 .../reference/components/general/tags/edit.json    |  9 ++++++
 .../reference/components/general/tags/tags.jsp     | 21 ++++++++-----
 4 files changed, 62 insertions(+), 7 deletions(-)

diff --git a/cms/reference/src/main/resources/jcr_root/apps/reference/components/general/tags.json b/cms/reference/src/main/resources/jcr_root/apps/reference/components/general/tags.json
new file mode 100644
index 0000000..80df40a
--- /dev/null
+++ b/cms/reference/src/main/resources/jcr_root/apps/reference/components/general/tags.json
@@ -0,0 +1,5 @@
+{
+	"jcr:primaryType": "sling:Component",
+    "componentType": "General",
+    "jcr:title": "Tags"
+}
\ No newline at end of file
diff --git a/cms/reference/src/main/resources/jcr_root/apps/reference/components/general/tags/config.json b/cms/reference/src/main/resources/jcr_root/apps/reference/components/general/tags/config.json
new file mode 100644
index 0000000..7111792
--- /dev/null
+++ b/cms/reference/src/main/resources/jcr_root/apps/reference/components/general/tags/config.json
@@ -0,0 +1,34 @@
+ {
+	"jcr:primaryType": "nt:unstructured",
+	"sling:resourceType": "sling-cms/components/general/container",
+	"tagPage": {
+		"jcr:primaryType": "nt:unstructured",
+		"sling:resourceType": "sling-cms/components/editor/fields/path",
+		"label": "Tag Page",
+		"name": "tagPage"
+	},
+	"listTag": {
+		"jcr:primaryType": "nt:unstructured",
+		"sling:resourceType": "sling-cms/components/editor/fields/text",
+		"label": "List Tag",
+		"name": "listTag"
+	},
+	"listClass": {
+		"jcr:primaryType": "nt:unstructured",
+		"sling:resourceType": "sling-cms/components/editor/fields/text",
+		"label": "List Class",
+		"name": "listClass"
+	},
+	"itemTag": {
+		"jcr:primaryType": "nt:unstructured",
+		"sling:resourceType": "sling-cms/components/editor/fields/text",
+		"label": "Item Tag",
+		"name": "itemTag"
+	},
+	"itemClass": {
+		"jcr:primaryType": "nt:unstructured",
+		"sling:resourceType": "sling-cms/components/editor/fields/text",
+		"label": "Item Class",
+		"name": "itemClass"
+	}
+}
\ No newline at end of file
diff --git a/cms/reference/src/main/resources/jcr_root/apps/reference/components/general/tags/edit.json b/cms/reference/src/main/resources/jcr_root/apps/reference/components/general/tags/edit.json
new file mode 100644
index 0000000..67a9d32
--- /dev/null
+++ b/cms/reference/src/main/resources/jcr_root/apps/reference/components/general/tags/edit.json
@@ -0,0 +1,9 @@
+ {
+	"jcr:primaryType": "nt:unstructured",
+	"sling:resourceType": "sling-cms/components/editor/slingform",
+	"button": "No Need to Edit",
+	"fields": {
+		"jcr:primaryType": "nt:unstructured",
+		"sling:resourceType": "sling-cms/components/general/container"
+	}
+}
\ No newline at end of file
diff --git a/cms/reference/src/main/resources/jcr_root/apps/reference/components/general/tags/tags.jsp b/cms/reference/src/main/resources/jcr_root/apps/reference/components/general/tags/tags.jsp
index 51dcd52..cd0ee3b 100644
--- a/cms/reference/src/main/resources/jcr_root/apps/reference/components/general/tags/tags.jsp
+++ b/cms/reference/src/main/resources/jcr_root/apps/reference/components/general/tags/tags.jsp
@@ -17,11 +17,18 @@
  * under the License.
  */ --%>
  <%@include file="/libs/sling-cms/global.jsp"%>
- <sling:adaptTo adaptable="${resource}" adaptTo="org.apache.sling.cms.core.models.PageManager" var="pageMgr" />
+<sling:adaptTo adaptable="${resource}" adaptTo="org.apache.sling.cms.core.models.PageManager" var="pageMgr" />
+<c:set var="config" value="${pageMgr.page.template.componentConfigs['reference/components/general/tags']}" scope="request" />
 <c:set var="contentResource" value="${sling:getRelativeResource(page.resource,'jcr:content')}" />
-<c:forEach var="tagPath" items="${contentResource.valueMap['keywords']}">
-	<c:set var="tag" value="${sling:getResource(resourceResolver,tagPath)}" />
-	<a href="/tags.html${tag.path}.html" class="label">
-		<sling:encode value="${tag.valueMap['jcr:title']}" default="${tag.name}" mode="HTML" />
-	</a>
-</c:forEach>
+<c:set var="listTag" value="${config.listTag}" default="div" />
+<c:set var="itemTag" value="${config.itemTag}" default="span" />
+<${listTag} class="${config.listClass}">
+	<c:forEach var="tagPath" items="${contentResource.valueMap['keywords']}">
+		<c:set var="tag" value="${sling:getResource(resourceResolver,tagPath)}" />
+		<${itemTag} class="${config.itemClass}">
+			<a href="${config.tagPage}.html${tag.path}.html">
+				<sling:encode value="${tag.valueMap['jcr:title']}" default="${tag.name}" mode="HTML" />
+			</a>
+		</${itemTag}>
+	</c:forEach>
+</${listTag}>
\ No newline at end of file

-- 
To stop receiving notification emails like this one, please contact
dklco@apache.org.