2024-05-10 02:14:03 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
cd Committee
|
2024-05-12 13:18:05 +00:00
|
|
|
|
2024-05-13 22:35:27 +00:00
|
|
|
# cleanup the last run (if there was one)
|
|
|
|
rm -rf _Handovers_html
|
|
|
|
|
2024-05-12 13:18:05 +00:00
|
|
|
# copy in teh config for this folder
|
|
|
|
cp ../_scripts/md_toml/_Handovers.md.toml ./.md.toml
|
|
|
|
|
2024-05-10 02:14:03 +00:00
|
|
|
cargo-bfom
|
|
|
|
|
2024-05-12 13:18:05 +00:00
|
|
|
## cleanup
|
|
|
|
rm -f .md.toml
|
|
|
|
|
2024-05-13 22:35:27 +00:00
|
|
|
# if the user only wants teh html tehn early return
|
|
|
|
if [[ $1 == "html" ]]; then
|
2024-05-13 22:41:52 +00:00
|
|
|
exit 0
|
2024-05-13 22:35:27 +00:00
|
|
|
fi
|
|
|
|
|
2024-05-10 02:14:03 +00:00
|
|
|
# recursively parse _Handovers_html use wkhtmltopdf to convert to pdf
|
|
|
|
cd _Handovers_html
|
|
|
|
|
|
|
|
out_folder="../_Handovers_pdf"
|
|
|
|
rm -rf "$out_folder"
|
2024-05-13 22:41:52 +00:00
|
|
|
for d in */; do
|
|
|
|
# skip symlinks
|
|
|
|
[ -L "''${d%/}" ] && continue
|
|
|
|
# exclude teh template fodler
|
|
|
|
if [[ $d == *"_Templates"* ]]; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
|
|
|
# create output folder
|
|
|
|
mkdir -p "$out_folder/$d"
|
|
|
|
|
|
|
|
# iterate the files
|
|
|
|
for file in $d*.html; do
|
|
|
|
if [ -f "$file" ]; then
|
|
|
|
|
|
|
|
# we need teh filename/path
|
|
|
|
stripped=''${file/.html/""}
|
|
|
|
|
|
|
|
echo "$out_folder/$stripped.pdf"
|
|
|
|
|
|
|
|
# convert teh html to pdf
|
|
|
|
wkhtmltopdf -q --enable-local-file-access --no-stop-slow-scripts "$stripped.html" "$out_folder/$stripped.pdf" 2>>../errors.log &
|
|
|
|
fi
|
|
|
|
done
|
2024-05-10 02:14:03 +00:00
|
|
|
done
|
|
|
|
|
2024-05-13 22:41:52 +00:00
|
|
|
cd ../
|
2024-05-13 23:15:27 +00:00
|
|
|
|
|
|
|
# wait for background tasks to complete
|
|
|
|
wait $(jobs -p)
|