A simple groovy console script to find AEM pages with a certain template then display them in a nice table
copy script to AEM groovy console, change parameters and run!
package com.mycom.core.mcp; | |
import com.adobe.acs.commons.fam.ActionManager; | |
import com.adobe.acs.commons.mcp.ProcessDefinition; | |
import com.adobe.acs.commons.mcp.ProcessInstance; | |
import com.adobe.acs.commons.mcp.form.CheckboxComponent; | |
import com.adobe.acs.commons.mcp.form.FormField; | |
import com.adobe.acs.commons.mcp.form.PathfieldComponent; | |
import com.adobe.acs.commons.mcp.model.GenericReport; | |
import java.io.Serializable; |
/*** | |
* | |
* a trimmed down version (~812 bytes minified, not gzipped) of: https://github.com/matthewhudson/current-device/blob/master/src/index.js | |
* to determine current device is mobile, tablet or desktop | |
* USAGE: | |
* 1. prebuilt property: `window.device.type` returns "mobile", "tablet" or "desktop" | |
* 2. could call `window.device.mobile()` or `window.device.tablet()` or `window.device.desktop()` to check for each | |
* 3. other methods such as `window.device.windows()`, `window.device.windowsPhone()`, `window.device.android()`, `window.device.blackberry()` | |
*/ |
copy script to AEM groovy console, change parameters and run!
download mustache-playground.html
and open with a browser tested only on chrome
you can now use in on my site: http://ahmedmusallam.com/mustache.html
quick templating for strings/html. Made to create multiple templates on the fly for repetitive jira ticket discriptions.
/* JsLint ignore Granite object from validation */ | |
/* globals Granite*/ | |
//define new interaction for dropping assets into fields, this wil copy the Asset's path into the field | |
var customePathbrowserInteraction; | |
(function (Granite, $) { | |
if (Granite && Granite.author && Granite.author.ui && Granite.author.ui.Interaction) { | |
// selector of element we want to drag | |
var DRAGGABLE_SELECTOR = '.cq-draggable.card-asset', |
#!/bin/bash | |
# this script will install ALL zip packages in current directory the AEM instance at 4502 | |
for f in *.zip | |
do | |
echo "installing: $f" | |
curl -u admin:admin -F file=@"$f" -F name="$f" -F force=true -F install=true http://localhost:4502/crx/packmgr/service.jsp | |
echo "done." | |
done |
<!-- | |
I use this setup primarely on jsfiddle where I do not want to open chrome console while testing js code. | |
example: https://jsfiddle.net/wybmxgop/1/ | |
--> | |
<!-- a Mono-spaced font--> | |
<link href="https://fonts.googleapis.com/css?family=Roboto+Mono" rel="stylesheet"> | |
<style> | |
ul#console { | |
list-style-type: none; |
// poll async featch calls in a syncronized fashion, IE do not start the next function call until the previous was resolved. | |
// also allows for throttling :) | |
async function poll(fn, onData, throttle) { | |
const _throttle = throttle || 5000; | |
let lastPollStarted; | |
async function _poll(_fn, _onData) { | |
lastPollStarted = new Date().getTime(); | |
let response = await _fn(); | |
if (response.status === 200) { | |
// Get and show the message |
// this code is the same as the servlet but for grovy console: https://github.com/OlsonDigital/aem-groovy-console | |
// OPTIONS | |
def PATH = '/content/dam/' | |
def query = createQuery([path:PATH, type:'nt:file', 'p.limit':'99999999999999999']) | |
def result = query.getResult(); | |
long totalSizeInKB = 0 | |
result.getHits().each{ | |
def node = it.node |
/** | |
* A simple circular data structure | |
*/ | |
function Circular(arr, startIntex){ | |
this.arr = arr; | |
this.currentIndex = startIntex || 0; | |
} | |
Circular.prototype.next = function(){ | |
var i = this.currentIndex, arr = this.arr; |