homepageTheme/gen.sh

38 lines
734 B
Bash
Raw Permalink Normal View History

2019-05-11 11:49:33 +00:00
#!/usr/bin/env bash
2019-05-22 07:06:59 +00:00
# Init venv
cd `dirname $0` &&
2019-05-22 08:16:50 +00:00
(
if [ ! -d ./venv ]; then
echo "Create venv" &&
python3 -m venv venv
fi
) &&
2019-05-22 07:06:59 +00:00
source ./venv/bin/activate &&
2019-05-11 11:49:33 +00:00
# Install updates
2019-05-22 07:06:59 +00:00
pip install --upgrade pip &&
pip install --upgrade pelican markdown htmlmin &&
2019-05-11 11:49:33 +00:00
# Clean and generate
(rm -rf output || true) &&
python3 -c "import pelican; pelican.main()" content &&
# Optimize
tools/cssfix.py output/theme/css/* &&
(
for i in `find output -wholename "*.html"`
do
htmlmin -c -s "$i" "$i" || exit 1
done
) &&
# Compress
(
for i in `find output -wholename "*.css" -or -wholename "*.js" -or -wholename "*.html"`
do
(gzip --best --keep "$i" && brotli --best --keep "$i") ||
(echo ERROR in file $i; exit 1) || exit 1
done
)