geocation.com/build.sh
2022-04-11 00:30:58 -04:00

42 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
set -euxo pipefail
cd "${BASH_SOURCE[0]%/*}"
rm -rf build
mkdir build
./node_modules/.bin/pug ./templates/
mv ./templates/*.html build/
# (
# echo "Building HTML"
# shopt -s extglob
# while IFS= read -r -d '' || [[ "${REPLY}" ]]; do
# cat header.html "${REPLY}" footer.html >"./build/${REPLY}"
# done < <(find . -maxdepth 1 -type f -name '*.html' -not -name 'header.html' -and -not -name 'footer.html' -print0)
# )
cp -vr css/ images/ build/
render_image() {
local SIZE="${1}" FILENAME="${2}" EXTRA_OPTIONS=(-auto-orient)
EXTENSION="${FILENAME##*.}"
shift 2
if [[ "${1-}" == "--square" ]]; then
EXTRA_OPTIONS+=(-background none -gravity center -extent "${SIZE}")
fi
convert -resize "${SIZE}^" "${EXTRA_OPTIONS[@]}" "orig/${FILENAME}" "build/images/${FILENAME%.*}-${SIZE}.${EXTENSION}"
}
render_image 200x200 "5._Elementary_GLOBE_Climate_Book_Cover.jpg" --square
render_image 200x200 "Diane_Student_Scammon_Bay.png" --square
render_image 200x200 "earth-small.png" --square
render_image 1000x1000 "earth-huge.png" --square
render_image 1000x1000 "Diane_Student_Scammon_Bay.png"
echo "Stripping metadata"
exiftool -overwrite_original -all= -- build/images/*.*
echo "Website built $(date)"