Skip to content

Instantly share code, notes, and snippets.

@knennigtri
knennigtri / jcr-locations.md
Last active May 8, 2023 09:15
Useful JCR Locations for AEM Templates and components
<alignment jcr:primaryType="nt:unstructured"
name="./alignChildren"
fieldLabel="Alignment of components"
required="{Boolean}true"
selectionMode="single"
sling:resourceType="granite/ui/components/coral/foundation/form/buttongroup">
<items jcr:primaryType="nt:unstructured">
<default jcr:primaryType="nt:unstructured"
name="./default"
@mickleroy
mickleroy / CORSFilter.java
Created February 4, 2017 22:18
Sets Access-Control headers in AEM for Cross Origin Resource Sharing
package com.github.mickleroy.models;
import org.apache.felix.scr.annotations.sling.SlingFilter;
import org.apache.felix.scr.annotations.sling.SlingFilterScope;
import org.apache.sling.api.SlingHttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.servlet.*;
import java.io.IOException;
@mickleroy
mickleroy / org.apache.sling.jcr.resource.internal.JcrResourceResolverFactoryImpl.xml
Last active November 4, 2024 15:04
JcrResourceResolverFactory configuration for We.Retail
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:primaryType="sling:OsgiConfig"
resource.resolver.searchpath="[/apps,/libs,/apps/foundation/components/primary,/libs/foundation/components/primary]"
resource.resolver.manglenamespaces="{Boolean}true"
resource.resolver.allowDirect="{Boolean}true"
resource.resolver.required.providers="[org.apache.sling.jcr.resource.internal.helper.jcr.JcrResourceProviderFactory]"
resource.resolver.virtual="[/:/]"
resource.resolver.mapping="[/-/,/content/we-retail/us/en/-/]"
resource.resolver.map.location="/etc/map"
@nateyolles
nateyolles / .content.xml
Created July 13, 2016 05:23
AEM Expression Language
<granite:rendercondition
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/renderconditions/simple"
expression="${param.biz == 'baz'}"
expression="${empty param.foo}"
expression="${not empty param.foo and not empty param.bar}"
expression="${param['foo'] not eq 'bar'}"
expression="${cookie.cookiename.value eq 'foo'}"
expression="${requestPathInfo.selectorString == 'edit'}"
expression="${requestPathInfo.suffix != '/foo/bar')}"
@nateyolles
nateyolles / .content.xml
Created July 13, 2016 05:15
AEM using Granite Render Conditions
<items jcr:primaryType="nt:unstructured">
<widgetAlways
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/textfield"
fieldLabel="This always shows"
name="./widgetAlways"/>
<widgetHeaderChrome
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/textfield"
fieldLabel="This only shows when header &quot;User-Agent&quot; contains &quot;chrome&quot;"
anonymous
anonymous / DamRemoveUnreferenced.java
Created March 21, 2015 02:32
Dam - Remove Unreferenced Images
package cq;
/*
* This Java Quick Start uses the jackrabbit-standalone-2.4.0.jar
* file. See the previous section for the location of this JAR file
*/
import javax.jcr.AccessDeniedException;
import javax.jcr.InvalidItemStateException;
import javax.jcr.ItemExistsException;
@toodooleedoo
toodooleedoo / README.md
Last active June 23, 2017 13:38
#AEM #Sightly #SSJS Server Side JavaScript Use-API Breadcrumbs

###Description Retrieve a Page Object from all pages which are in the Site root then build a breadcrumb component and display the current pages title in a submenu.

###Use case Display a bar under eg a menu which displays the current pages title and functional breadcrumb components o the right.

##Requirements

  • Responsive and which works on all mobile devices and desktop.
  • Current pages title on the left
  • Breadcrumbs on the right
@floriankraft
floriankraft / JcrQueryLibrary.md
Last active July 28, 2025 14:45
Some useful JCR queries (XPATH, SQL2) for AEM/CQ development.

SQL2

All nodes with a specific name

SELECT * FROM [nt:unstructured] AS node
WHERE ISDESCENDANTNODE(node, "/search/in/path")
AND NAME() = "nodeName"

All pages below content path

@planetoftheweb
planetoftheweb / hello.js
Created March 27, 2014 20:58
Simple Node.js Hello World
var http = require('http'); //add the http module
//Create a server
var myServer = http.createServer(function (request, response) {
// Return something from server
response.writeHead(200, {"Content-Type": "text/plain"});
response.end("Hello Node\n");
}); //create a server
Bind server to a port