Skip to content

Instantly share code, notes, and snippets.

@kuckmc01
kuckmc01 / Image Touch UI AEM
Created January 10, 2018 19:10
Image Touch UI AEM
<file
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/fileupload"
autoStart="{Boolean}false"
class="cq-droptarget"
fieldLabel="Image asset"
fileNameParameter="./image/fileName"
fileReferenceParameter="./image/fileReference"
mimeTypes="[image]"
multiple="{Boolean}false"
public String[] getValuesAsStringArray(final Resource resource, final String propertyToExtract){
try {
final Node node = resource.adaptTo(Node.class);
final Property property = node.getProperty(propertyToExtract);
final Resource childProperty = resource.getChild(propertyToExtract);
if(property.isMultiple() && childProperty != null){
return childProperty.adaptTo(String[].class);
}else{
return new String[]{ childProperty.adaptTo(String.class) };
}
@kuckmc01
kuckmc01 / gist:e8f0fc4b6ced670b4dcd0f42d28704c8
Created April 10, 2018 19:34
Check AEM registered validators
Granite.UI.Foundation.Registry.get('foundation.validation.validator');
@kuckmc01
kuckmc01 / goto.sh
Created May 10, 2018 19:26
goto script
#!/usr/bin/env bash
#setup
# in bash profile set an alias for goto alias='goto=. ./goto.sh'
# in bash profile set an alias for goback alias goback=$goback
# Usage:
# goto commonpath
#goto script for lazy people who dont want to have a lot of aliases or keep sourcing the bash profile
#Argument handling
@kuckmc01
kuckmc01 / gist:73ce69535cd765a80246042184365b96
Created June 8, 2018 18:40
commons json replacement - jackson
See http://proliferay.com/create-json-by-jackson-api/
ObjectMapper om = new ObjectMapper();
ObjectNode objectNode = om.createObjectNode();
ArrayNode arrayNode = om.createArrayNode();
var tags =$('[data-fieldname="./cq:tags"]’);
var tagList = CUI.Widget.fromElement(CUI.TagList,tags);
tagList.options.values = ['hello','world']
tagList._setValues()
@kuckmc01
kuckmc01 / mutation.js
Created October 15, 2018 20:39
Mutation Observer simple style checker
var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;
var container = document.querySelector('paper-dialog.ytd-popup-container');
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
console.log(mutation);
if(mutation.attributeName === 'style'){
if(!(container.style.display === 'none')){
console.log('triggering click');
var y = document.querySelector('.yt-confirm-dialog-renderer yt-formatted-string[id="text"]');
@kuckmc01
kuckmc01 / gist:dccdcc0367e8cea3a73f7f88f0a46844
Created May 16, 2019 17:06
xpath get PageContent that has child component with sling:resourceType
/jcr:root/content//element(*,cq:PageContent)[*/*/@sling:resourceType="the/resource/type"]
@kuckmc01
kuckmc01 / gist:c4049d18d7e6669ce9ec16c28c2e3445
Created May 24, 2019 17:37
SQL2 dam:Asset query specific sub metadata node has property
SELECT * FROM [dam:Asset] AS s WHERE ISDESCENDANTNODE([/content/dam/abc]) and s.[jcr:content/metadata/thing/textfield1] is not null
select page.* from [cq:Page] as page
inner join [cq:PageContent] as pageContent
on isChildNode(pageContent, page)
inner join [nt:base] as carousel
on isDescendantNode(carousel, pageContent)
inner join [nt:base] as list
on isDescendantNode(list, pageContent)
where isDescendantNode(pageContent, '/content')
and name(pageContent) = 'jcr:content'
and carousel.[sling:resourceType] = 'COMPONENT_ONE'