Skip to content

Instantly share code, notes, and snippets.

@cpilsworth
cpilsworth / latest.js
Created May 30, 2024 13:57
CF UE EDS Block
/* eslint-disable no-underscore-dangle */
// eslint-disable-next-line import/no-unresolved
import { html, render } from 'https://unpkg.com/htm/preact/standalone.module.js';
function Latest(props) {
return html`
<h2>Latest Destinations</h2>
<ul data-aue-type="container" data-aue-label="Latest Destinations">
${props.destinations.map((item) => html`<li data-aue-type="reference" data-aue-label=${item.title} data-aue-resource=${`urn:aemconnection:${item._path}/jcr:content/data/master`} >
<div class="latest-card-body">
@cpilsworth
cpilsworth / ImageSignedUrlRedirectServlet.java
Last active June 22, 2023 16:34
Oak Direct Binary Download
package com.chrisp.rde.core.servlets;
import org.apache.commons.lang3.StringUtils;
import org.apache.jackrabbit.api.binary.BinaryDownload;
import org.apache.jackrabbit.api.binary.BinaryDownloadOptions;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.servlets.OptingServlet;
import org.apache.sling.api.servlets.SlingSafeMethodsServlet;
@cpilsworth
cpilsworth / ImageSignedUrlRedirectServlet.java
Last active May 11, 2023 16:19
Cloud Storage Direct Asset Download URL generator
package com.chrisp.rde.core.servlets;
import org.apache.commons.lang3.StringUtils;
import org.apache.jackrabbit.api.binary.BinaryDownload;
import org.apache.jackrabbit.api.binary.BinaryDownloadOptions;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.servlets.OptingServlet;
import org.apache.sling.api.servlets.SlingSafeMethodsServlet;
@cpilsworth
cpilsworth / _teaser.scss
Last active May 11, 2023 15:47
DLG teaser
.cmp-teaser {
}
.cmp-teaser__image {
}
.cmp-teaser__content {
}
.cmp-teaser__pretitle {
}
.cmp-teaser__title {
}
@cpilsworth
cpilsworth / ims-jwt.mjs
Created September 18, 2022 08:05
cli utility to convert an aem service token into a jwt
import { stdin, stdout, exit } from 'node:process';
import { parseArgs } from 'node:util';
import { default as auth } from '@adobe/jwt-auth';
import { default as fs } from 'fs';
const options = {
'file': { type: 'string' },
};
const { values } = parseArgs({ options });
@cpilsworth
cpilsworth / assetpicker.html
Created August 10, 2022 15:19
AEM Asset Picker
<!DOCTYPE html>
<html>
<head>
<script>
const host = 'http://localhost:4503';
const rootPath = '/content/dam/mycompany';
window.addEventListener("message", (event) => {
if (event.origin !== host) {
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import collections
import sys
Point = collections.namedtuple("Point",['x', 'y'])
Command = collections.namedtuple("Command", ['direction', 'magnitude'])
start_pos = Point(0,0)
map = [[]]
@cpilsworth
cpilsworth / RedirectFixFilter.java
Created November 26, 2019 23:23
intercept redirects and rewrite
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.wrappers.SlingHttpServletResponseWrapper;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletResponse;
‪env | grep "$TPL_PREFIX" | while read -r VAR;‬
‪do‬
‪ REPLACE="s/`echo "$VAR" | sed -e s,=,/,`/" ‬
‪ sed -e "$REPLACE" "$SOURCE_FILE" > "$TARGET_FILENAME"‬
‪done‬