Skip to content

Instantly share code, notes, and snippets.

View nateyolles's full-sized avatar
😄

Nate Yolles nateyolles

😄
View GitHub Profile
@nateyolles
nateyolles / OsgiServlet.java
Created May 25, 2017 20:54
Sample OSGi servlet in AEM
@Component(
immediate = true,
service = Servlet.class,
property = {
"sling.servlet.resourceTypes=project/components/component"
}
)
@Designate(ocd = SampleOsgiServlet.Configuration.class)
public class SampleOsgiServlet extends SlingSafeMethodsServlet {
@nateyolles
nateyolles / OsgiServletAnnotation.java
Last active June 23, 2020 07:06
A sample OSGi Declarative Services Servlet Annotation
@Component(
service = Servlet.class,
property = {
"sling.servlet.extensions=html",
"sling.servlet.selectors=foo",
"sling.servlet.paths=/bin/foo",
"sling.servlet.paths=/bin/bar",
"sling.servlet.methods=get",
"sling.servlet.resourceTypes=nt:file",
"sling.servlet.resourceTypes=project/components/component"
@nateyolles
nateyolles / SlingServletAnnotation.java
Created May 25, 2017 20:51
A sample AEM SlingServlet Felix SCR Annotation
@SlingServlet(
metatype = true,
paths = {
"/bin/foo",
"/bin/bar"
},
extensions = {"html"},
selectors = {"foo"},
resourceTypes = {"nt:file", "project/components/component"}
methods = "GET",
@nateyolles
nateyolles / Configuration.java
Created May 25, 2017 20:36
OSGi Declarative Services Annotations
package com.nateyolles.aem.osgiannotationdemo.core.services.impl;
import org.apache.commons.lang3.StringUtils;
import org.osgi.service.metatype.annotations.AttributeDefinition;
import org.osgi.service.metatype.annotations.AttributeType;
import org.osgi.service.metatype.annotations.ObjectClassDefinition;
import org.osgi.service.metatype.annotations.Option;
@ObjectClassDefinition(name = "Annotation Demo Service - OSGi")
public @interface Configuration {
$.ajax({
url: 'https://scheduler.bookedin.com/api/v1/companies/nurtured-by-nature/dayAvailability?from=2017-01-01&to=2018-01-31',
dataType: 'jsonp',
success: function(data) {
for (var x = 0; x < data.months.length; x++) {
if (data.months[x].availability.length > 0) {
alert('opening found');
}
}
},
@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;"
@nateyolles
nateyolles / .content.xml
Created July 13, 2016 05:14
AEM using Granite Custom Render Condition
<widgetCustomRenderConditionHasProperty
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/textfield"
fieldLabel="This only shows if &quot;/content/renderconditiondemo/en/jcr:content/par/text&quot; has property &quot;text&quot;"
name="./widgetCustomRenderConditionHasProperty">
<granite:rendercondition
jcr:primaryType="nt:unstructured"
sling:resourceType="renderconditiondemo/components/renderconditions/hasProperty"
resourcePath="${requestPathInfo.suffix}"
propertyName="text"/>
@nateyolles
nateyolles / hasProperty.jsp
Created July 13, 2016 05:14
AEM Granite Custom Render Condition
<%--
==============================================================================
has property render condition
A condition that takes a resource path and property name and makes the
rendering decision based on whether that resource has the property.
/**
* The resource path of the resource to evaluate.
*/
- resourcePath (String)
/**
@nateyolles
nateyolles / .content.xml
Created July 13, 2016 05:13
AEM Expression Language
<cancel
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/hyperlink"
text="Cancel"
href="/content/geo${granite:encodeURIPath(requestPathInfo.suffix)}"/>