Skip to content

Commit

Permalink
add generic snippet component.
Browse files Browse the repository at this point in the history
  • Loading branch information
wildone committed Jun 1, 2021
1 parent 2808f39 commit 53f868a
Show file tree
Hide file tree
Showing 8 changed files with 140 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:granite="http://www.adobe.com/jcr/granite/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:primaryType="cq:Component"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<%@page session="false"
import="com.day.cq.wcm.webservicesupport.Configuration,
com.day.cq.wcm.webservicesupport.ConfigurationManager" %><%
%><%@taglib prefix="cq" uri="http://www.day.com/taglibs/cq/1.0" %><%
%><cq:defineObjects/><%
String[] services = pageProperties.getInherited("cq:cloudserviceconfigs", new String[]{});
ConfigurationManager cfgMgr = resource.getResourceResolver().adaptTo(ConfigurationManager.class);
if(cfgMgr != null) {
String snippetCode = null;
Configuration cfg = cfgMgr.getConfiguration("generic-snippet", services);
if(cfg != null) {
snippetCode = cfg.get("snippetcode", null);
}
if(snippetCode != null) {
%><%= snippetCode %><%
}
}
%>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
cq:defaultView="html"
jcr:primaryType="cq:Component"
sling:resourceSuperType="cq/cloudserviceconfigs/components/configpage"
componentGroup="AEM.Design - Cloud Services"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
jcr:primaryType="nt:unstructured"
jcr:title="Generic Snippet Settings"
sling:resourceType="cq/gui/components/authoring/dialog">
<content
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/container">
<layout
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/layouts/tabs"
type="nav"/>
<items jcr:primaryType="nt:unstructured">
<configTab
jcr:primaryType="nt:unstructured"
jcr:title="Config"
sling:resourceType="granite/ui/components/foundation/section">
<layout
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/layouts/fixedcolumns"
margin="{Boolean}false"/>
<items jcr:primaryType="nt:unstructured">
<column
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/container">
<items jcr:primaryType="nt:unstructured">
<variant
jcr:primaryType="nt:unstructured"
jcr:title="Config"
sling:resourceType="granite/ui/components/coral/foundation/form/fieldset">
<items jcr:primaryType="nt:unstructured">
<snippet
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/textarea"
fieldDescription="Enter snippet code to be added at the bottom of the page. This text will be added as-is to the bottom of the page."
fieldLabel="Snippet Code"
name="./snippetcode"
required="false"/>
</items>
</variant>
</items>
</column>
</items>
</configTab>
</items>
</content>
</jcr:root>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<%@page session="false"%>
<%@page contentType="text/html"
pageEncoding="utf-8"
import="javax.jcr.Node"
%><%@include file="/libs/foundation/global.jsp"
%><%@include file="/libs/wcm/global.jsp"
%><%@include file="/libs/cq/cloudserviceconfigs/components/configpage/init.jsp"
%><% I18n i18n = new I18n(request); %>
<cq:setContentBundle/>
<%
if (currentPage.getParent().getProperties().get("componentReference","") == "") {
log.error("Generic Snippet config is missing componentReference, updating to aemdesign/components/cloudservices/genericsnippet.");
Node contentnode = currentPage.getParent().getContentResource().adaptTo(Node.class);
contentnode.setProperty("componentReference","aemdesign/components/cloudservices/genericsnippet");
Session resourceSession = resource.getResourceResolver().adaptTo(Session.class);
resourceSession.save();
}
%>
<div class="content">
<h3><fmt:message key="Generic Snippet Settings"/></h3>
<ul style="float: left; margin: 0px;">
<li><div class="li-bullet"><strong><fmt:message key="Snippet"/>: </strong><%= xssAPI.encodeForHTML(properties.get("snippetcode", "")).replaceAll("\\&\\#xa;","<br>") %></div></li>
<li class="config-successful-message when-config-successful" style="display: none">
<fmt:message key="Configuration is successful."/><br>
</li>
</ul>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
jcr:primaryType="cq:Dialog"
xtype="dialog">
<items jcr:primaryType="cq:WidgetCollection">
<general
jcr:primaryType="nt:unstructured"
title="Generic Snippet Settings"
xtype="panel">
<items jcr:primaryType="cq:WidgetCollection">
<snippet
jcr:primaryType="cq:Widget"
fieldDescription="This text will be added as-is to the bottom of the page."
fieldLabel="Snippet Code"
name="./snippetcode"
xtype="textarea"/>
</items>
</general>
</items>
</jcr:root>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:granite="http://www.adobe.com/jcr/granite/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:description="Generic Snippet configuration"
jcr:primaryType="cq:Template"
jcr:title="Generic Snippet Configuration"
sling:resourceSuperType="cq/cloudserviceconfigs/templates/configpage"
allowedChildren="[/apps/aemdesign/templates/cloudconfig/genericsnippet]"
allowedPaths="[/etc/cloudservices/generic-snippet(/.*)?]"
ranking="{Long}90">
<jcr:content
cq:cloudservicename="genericsnippet"
jcr:primaryType="cq:PageContent"
sling:resourceType="aemdesign/components/cloudservices/genericsnippetpage"/>
</jcr:root>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 53f868a

Please sign in to comment.