Skip to content

Instantly share code, notes, and snippets.

@ryanlunka
ryanlunka / LinkTransformer.java
Created April 8, 2013 12:35
A Sling Rewriter Transformer that replaces all ".html" extensions in links within an HREF attribute of a requested page with "/".
package com.citytechinc.rewriter.linkchecker;
import java.io.IOException;
import org.apache.cocoon.xml.sax.AbstractSAXPipe;
import org.apache.sling.rewriter.ProcessingComponentConfiguration;
import org.apache.sling.rewriter.ProcessingContext;
import org.apache.sling.rewriter.Transformer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ryanlunka
ryanlunka / ga.jsp
Last active December 13, 2015 21:38
This JSP can be included in CQ5 page components to integrate with Google Analytics for browsers that do not allow JavaScript. This code is modified from what Google provides (https://developers.google.com/analytics/devguides/collection/other/mobileWebsites) so that it can be used with Apache Sling. This script hasn't been tested with all Google …
<%@ page language="java"
import="java.io.ByteArrayOutputStream,
java.io.IOException,
java.io.OutputStream,
java.io.UnsupportedEncodingException,
java.math.BigInteger,
java.net.HttpURLConnection,
java.net.URLConnection,
java.net.URL,
java.net.URLEncoder,