#!/bin/bash

ROOT=`dirname $0`

if [ "$1" == "" ]; then
  echo "Usage: ./export <directory>"
  echo "<directory> will be rebuilt!"
  exit 1
fi

if [ ! -d "$1" ]; then
  echo "$1 is not a directory"
  exit 2
fi

rm -rf "$1"/*

# install android source
cp -a $ROOT/android "$1"/android
rm "$1"/android/build-assets "$1"/android/cleanup-assets

# install upstream source
mkdir "$1"/cgi-bin
cp -a $ROOT/source "$1"/source
cp -a $ROOT/ios "$1"/ios

# install config and CSSs
cp $ROOT/cgi-bin/breviar-web.cfg "$1"/cgi-bin/breviar-web.cfg
cp $ROOT/cgi-bin/breviar-android.cfg "$1"/cgi-bin/breviar-android.cfg
cp $ROOT/breviar.css "$1"/breviar.css
cp $ROOT/breviar-invert-colors.css "$1"/breviar-invert-colors.css

cp $ROOT/README "$1"/README

