Skip to content

Instantly share code, notes, and snippets.

@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) {
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‬
@cpilsworth
cpilsworth / pom.xml
Created September 12, 2018 22:47
Maven POM for content sync - empty package creation | source upload | source build | source download | target install
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<!-- ====================================================================== -->
<!-- P R O J E C T D E S C R I P T I O N -->
<!-- ====================================================================== -->
<groupId>uk.co.diffa.contentsync</groupId>
<artifactId>sync</artifactId>