Last active
February 26, 2021 03:08
-
-
Save rogerblanton/dbf21bd3ac9850bdf8c6 to your computer and use it in GitHub Desktop.
AEM IntelliJ Live Templates
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
<templateSet group="Adobe AEM"> | |
<template name="aem-statictemplate" value="<?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" jcr:description="$DESCRIPTION$" jcr:primaryType="cq:Template" jcr:title="$TITLE$" allowedPaths="[$ALLOWED_PATHS$]" ranking="{Long}$RANKING$"> <jcr:content cq:designPath="$DESIGN_PATH$" jcr:primaryType="cq:PageContent" sling:resourceType="$RESOURCE_TYPE$"> </jcr:content> </jcr:root> $END$" description="Create template for Adobe AEM" toReformat="false" toShortenFQNames="true"> | |
<variable name="DESCRIPTION" expression="" defaultValue=""Enter the description"" alwaysStopAt="true" /> | |
<variable name="TITLE" expression="" defaultValue=""Enter the title"" alwaysStopAt="true" /> | |
<variable name="ALLOWED_PATHS" expression="" defaultValue=""Enter the allowed paths"" alwaysStopAt="true" /> | |
<variable name="RANKING" expression="" defaultValue=""100"" alwaysStopAt="true" /> | |
<variable name="DESIGN_PATH" expression="" defaultValue=""/etc/design/example"" alwaysStopAt="true" /> | |
<variable name="RESOURCE_TYPE" expression="" defaultValue=""Enter a resource type: example/component/path"" alwaysStopAt="true" /> | |
<context> | |
<option name="XML" value="true" /> | |
</context> | |
</template> | |
<template name="aem-component" value="<?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" jcr:primaryType="cq:Component" jcr:title="$TITLE$" sling:resourceSuperType="$RESOURCE_SUPER_TYPE$" componentGroup="$COMPONENT_GROUP$" /> $END$" description="Create a component for Adobe AEM" toReformat="false" toShortenFQNames="true"> | |
<variable name="TITLE" expression="" defaultValue=""Enter the title"" alwaysStopAt="true" /> | |
<variable name="RESOURCE_SUPER_TYPE" expression="" defaultValue=""Enter the relative path of the type"" alwaysStopAt="true" /> | |
<variable name="COMPONENT_GROUP" expression="" defaultValue=""Enter the component group"" alwaysStopAt="true" /> | |
<context> | |
<option name="XML" value="true" /> | |
</context> | |
</template> | |
<template name="aem-clientlibrary" value="<?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" jcr:primaryType="cq:ClientLibraryFolder" categories="[$CATEGORIES$]" embed="[$EMBED$]" dependencies="[$DEPENDENCIES$]" /> $END$" description="Create a client library for Adobe AEM" toReformat="false" toShortenFQNames="true"> | |
<variable name="CATEGORIES" expression="" defaultValue=""Enter the categories"" alwaysStopAt="true" /> | |
<variable name="EMBED" expression="" defaultValue=""Enter the embedded categories"" alwaysStopAt="true" /> | |
<variable name="DEPENDENCIES" expression="" defaultValue=""Enter the dependencies"" alwaysStopAt="true" /> | |
<context> | |
<option name="XML" value="true" /> | |
</context> | |
</template> | |
<template name="slingFilter" value="import org.apache.sling.api.SlingHttpServletRequest; import org.apache.sling.api.SlingHttpServletResponse; import org.apache.sling.api.resource.Resource; import org.apache.sling.servlets.annotations.SlingServletFilter; import org.apache.sling.servlets.annotations.SlingServletFilterScope; import org.osgi.service.component.annotations.Component; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import java.io.IOException; @Component // See documentation for the @SlingServletFilter configuration here: https://sling.apache.org/documentation/the-sling-engine/filters.html @SlingServletFilter( scope = {SlingServletFilterScope.REQUEST}, // REQUEST, INCLUDE, FORWARD, ERROR, COMPONENT (REQUEST, INCLUDE, COMPONENT) suffix_pattern = "/suffix/foo", resourceTypes = {"foo/bar"}, pattern = "/content/.*", extensions = {"txt","json"}, selectors = {"foo","bar"}, methods = {"GET","HEAD"} ) public class SampleSlingRequestFilter implements Filter { private static final Logger log = LoggerFactory.getLogger(SampleSlingRequestFilter.class); @Override public void init(FilterConfig filterConfig) throws ServletException { // Usually, do nothing } @Override public final void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { // Since this is a Sling Filter, the request and response objects are guaranteed to be of types // SlingHttpServletRequest and SlingHttpServletResponse. final SlingHttpServletResponse slingResponse = (SlingHttpServletResponse) response; final SlingHttpServletRequest slingRequest = (SlingHttpServletRequest) request; final Resource resource = slingRequest.getResource(); if (resource.getPath().startsWith("/content/redirect-me")) { // Is the SlingFilterScope is REQUEST, redirects can be issued. slingResponse.sendRedirect("/some/redirect.html"); // Stop processing the request chain return; } // Content can be written tot he response before and after the chain execution // Forcing false in this sample so else this will break AEM when installed if (false && response.getContentType().contains("html")) { // In this example, checking for html response type since the comments are HTML format and would break // binary, json, etc. responses // Write some more content to the response before this chain has executed //response.getWriter().write("<!-- Written from the Sample Sling Filter BEFORE the next include -->"); // Proceed with the rest of the Filter chain chain.doFilter(request, response); // Write some more content to the response after this chain has executed //response.getWriter().write("<!-- Written from the Sample Sling Filter AFTER the next include -->"); } else { chain.doFilter(request, response); } } @Override public void destroy() { // Usually, do nothing } } $END$" description="Create a new Sling Filter Java Class" toReformat="false" toShortenFQNames="true"> | |
<context> | |
<option name="JAVA_CODE" value="true" /> | |
</context> | |
</template> | |
<template name="dialog__fileupload" value="<$TAG_NAME$ jcr:primaryType="nt:unstructured" sling:resourceType="cq/gui/components/authoring/dialog/fileupload" autoStart="{Boolean}false" class="cq-droptarget" fileNameParameter="./$FILE_NAME_PARAMETER$" fileReferenceParameter="./$FILE_NAME_REFERENCE_PARAMETER$" mimeTypes="[image/gif,image/jpeg,image/png,image/tiff,image/svg+xml]" multiple="{Boolean}$ALLOW_MULTIPLE$" name="./$TAG_NAME$" title="$TITLE$" allowUpload="{Boolean}$ALOW_UPLOAD$" useHTML5="{Boolean}true"/> $END$" description="Granite UI File Upload Widget" toReformat="false" toShortenFQNames="true"> | |
<variable name="TAG_NAME" expression="" defaultValue="" alwaysStopAt="true" /> | |
<variable name="FILE_NAME_PARAMETER" expression="" defaultValue="" alwaysStopAt="true" /> | |
<variable name="FILE_NAME_REFERENCE_PARAMETER" expression="" defaultValue="" alwaysStopAt="true" /> | |
<variable name="ALLOW_MULTIPLE" expression="enum("true", "false")" defaultValue="" alwaysStopAt="true" /> | |
<variable name="TITLE" expression="" defaultValue="" alwaysStopAt="true" /> | |
<variable name="ALOW_UPLOAD" expression="enum("true", "false")" defaultValue="" alwaysStopAt="true" /> | |
<context> | |
<option name="XML" value="true" /> | |
</context> | |
</template> | |
<template name="dialog__textfield" value="<$TAG_NAME$ granite:class="" jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/coral/foundation/form/textfield" fieldDescription="$DESCRIPTION$" fieldLabel="$LABEL$" name="./$JCR_PROPERTY_NAME$" required="{Boolean}$REQUIRED$"/> $END$" description="Granite UI Text Field Widget" toReformat="false" toShortenFQNames="true"> | |
<variable name="TAG_NAME" expression="" defaultValue="" alwaysStopAt="true" /> | |
<variable name="DESCRIPTION" expression="" defaultValue="" alwaysStopAt="true" /> | |
<variable name="LABEL" expression="" defaultValue="" alwaysStopAt="true" /> | |
<variable name="JCR_PROPERTY_NAME" expression="" defaultValue="" alwaysStopAt="true" /> | |
<variable name="REQUIRED" expression="enum("false", "true")" defaultValue="" alwaysStopAt="true" /> | |
<context> | |
<option name="XML" value="true" /> | |
</context> | |
</template> | |
<template name="dialog__pathfield" value="<$TAG_NAME$ jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/coral/foundation/form/pathfield" fieldDescription="$FIELD_DESCRIPTION$" fieldLabel="$FIELD_LABEL$" nodeTypes="$NODE_TYPES$" name="./$TAG_NAME$" rootPath="$ROOT_PATH$"/> $END$" description="Granite UI Path Field Widget" toReformat="false" toShortenFQNames="true"> | |
<variable name="TAG_NAME" expression="" defaultValue="" alwaysStopAt="true" /> | |
<variable name="FIELD_DESCRIPTION" expression="" defaultValue="" alwaysStopAt="true" /> | |
<variable name="FIELD_LABEL" expression="" defaultValue="" alwaysStopAt="true" /> | |
<variable name="NODE_TYPES" expression="enum("dam:Asset", "nt:file", "nt:resource", "cq:Page", "nt:unstructured")" defaultValue="" alwaysStopAt="true" /> | |
<variable name="ROOT_PATH" expression="" defaultValue="" alwaysStopAt="true" /> | |
<context> | |
<option name="XML" value="true" /> | |
</context> | |
</template> | |
</templateSet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment