Skip to content

Instantly share code, notes, and snippets.

View nateyolles's full-sized avatar
😄

Nate Yolles nateyolles

😄
View GitHub Profile
@nateyolles
nateyolles / OsgiConfigurationServiceConsumerExampleImpl.java
Last active October 15, 2015 18:57
Example component consuming the custom OsgiConfigurationService service
package com.nateyolles.sling.publick.services.impl;
import java.util.HashMap;
import java.util.Map;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import org.apache.felix.scr.annotations.Properties;
import org.apache.felix.scr.annotations.Property;
@nateyolles
nateyolles / curlDialogCheckboxes.sh
Created November 17, 2015 01:46
cURL simulations of submitted AEM component dialogs using SlingPostServlet suffixes
# Simulated checked checkbox. The value is saved as a Boolean type with the value of true.
curl http://localhost:4502/test -u admin:admin -Fcheck="true" -Fcheck@TypeHint="Boolean"
# Simulated unchecked checkbox. No value for "check" is submitted and the JCR property value remains unchanged.
curl http://localhost:4502/test -u admin:admin -Fcheck@TypeHint="Boolean"
# Simulated unchecked checkbox with Delete suffix. The JCR property is removed.
curl http://localhost:4502/test -u admin:admin -Fcheck@TypeHint="Boolean" -Fcheck@Delete="true"
# Simulated unchecked checkbox with TypeHint, DefaultValue and UseDefaultWhenMissing suffixes.
@nateyolles
nateyolles / AemGetCheckboxValue.java
Last active November 17, 2015 17:46
Get a checkbox value in an AEM/Sling Sightly Java bean
/*
* Sightly classes extending com.adobe.cq.sightly.WCMUse or com.adobe.cq.sightly.WCMUsePojo
*/
Boolean checkbox = getProperties().get("myBooleanCheckbox", Boolean.class);
/*
* Set the default value.
*/
Boolean checkbox = getProperties().get("myBooleanCheckbox", false);
Boolean checkbox = getProperties().get("myBooleanCheckbox", true);
@nateyolles
nateyolles / AkamaiContentBuilder.java
Created January 5, 2016 19:55
AEM custom Akamai Replication Agent ContentBuilder
package com.nateyolles.aem.core.replication;
import java.io.BufferedWriter;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.Map;
import java.nio.file.Files;
import java.nio.file.Path;
@nateyolles
nateyolles / aemGraniteUIAlert.js
Created January 21, 2016 07:37
AEM Granite UI "foundation ui" adapter notification
var ui = $(window).adaptTo('foundation-ui');
ui.alert('Notification', 'This alert was created using the Granite UI "foundation-ui" adapter', 'notice');
@nateyolles
nateyolles / aemMultifieldAdapterExample.js
Created January 21, 2016 08:52
Using the custom AEM Granite UI / Touch UI multifield adapter
var field = $('.coral-Multifield').adaptTo('nateyolles-field');
field.setDisabled(true);
@nateyolles
nateyolles / ConfModel.java
Created March 27, 2016 18:50
AEM com.adobe.granite.confmgr.Conf example by adapting the current page
package com.nateyolles.aem.slashconf.core.models;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.resource.ValueMap;
import org.apache.sling.models.annotations.Model;
import com.adobe.granite.confmgr.Conf;
@nateyolles
nateyolles / ConfServiceModel.java
Created March 27, 2016 18:52
AEM com.adobe.granite.confmgr.Conf example of using the com.adobe.granite.confmgr.ConfMgr service
package com.nateyolles.aem.slashconf.core.models;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ValueMap;
import org.apache.sling.models.annotations.Model;
@nateyolles
nateyolles / ConfOtherModel.java
Created March 27, 2016 18:54
AEM com.adobe.granite.confmgr.Conf examples of getting a specific configuration and getting it's list of inherited settings
package com.nateyolles.aem.slashconf.core.models;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.resource.ValueMap;
@nateyolles
nateyolles / conf.json
Created March 27, 2016 19:06
AEM example slash conf structure
{
"jcr:primaryType": "sling:Folder",
"jcr:mixinTypes": ["rep:AccessControllable"],
"global": {
"jcr:primaryType": "sling:Folder",
"settings": {
"jcr:primaryType": "sling:Folder",
"socialmedia": {
"jcr:primaryType": "cq:Page",
"facebook": {