#!/bin/sh
#this script modifies an HTML file at certain places. Used to fix up certain
#features on generated Jekyll sites without having to modify the templates

function usage () {
	echo "Usage:"
	echo `basename $0` '<mixin> <place> <file> [href_base]'
}

#If no arguments given, exit.
if [ -z "$1" -o -z "$2" -o -z "$3" ]
then
	usage
	exit 1
fi

#Rename arguments
MIXIN="$1"
PLACE="$2"
TARGET_FILE="$3"
HREF_BASE="$4"

#Make a temporary file for intermediate changes
TMP_MIXIN=`mktemp`
TMP_OUT=`mktemp`

#Update href values
sed "s|href=\"|href=\"$HREF_BASE|g" > $TMP_MIXIN



rm "$TMP_MIXIN"
rm "$TMP_OUT"
