--- /dev/null
+#!/bin/bash
+
+set -e -x
+
+export IKIWIKI_PREVIEW_OUTPUT="$1"
+if [ -z "$IKIWIKI_PREVIEW_OUTPUT" ]; then
+ echo "You must call this script as"
+ echo "./generate-preview.sh OUTPUT_DIR [IKIWIKI_INSTALL_ROOT]"
+ exit 1
+fi
+
+srcdir=$(pwd)
+if [ -n "$2" ]; then
+ tmpoutdir="$2"
+else
+ tmpdir=`mktemp -d -t tmp.XXXXXXXXXX`
+ tmpoutdir=`mktemp -d -t tmp.XXXXXXXXXX`
+ echo "Building ikiwiki source in $tmpdir"
+ echo "Building ikiwiki into $tmpoutdir"
+ trap 'rm -rf "$tmpdir"; rm -rf "$tmpoutdir"' 0
+ cd "$tmpdir"
+ (cd "$srcdir/ikiwiki" && tar c .) | (cd "$tmpdir" && tar x)
+ perl ./Makefile.PL INSTALL_BASE="$tmpoutdir" PREFIX=
+ make install --old-file=docwiki
+fi
+cd "$srcdir"
+export IKIWIKI_SHARE="$tmpoutdir/share/ikiwiki"
+perl "$tmpoutdir"/bin/ikiwiki --setup "$srcdir"/ikiwiki.setup