2024-05-12 14:53:06 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2024-05-13 22:35:27 +00:00
|
|
|
root="$PWD"
|
|
|
|
|
2024-08-10 22:38:21 +00:00
|
|
|
folder_html="html_minutes"
|
2024-08-10 22:40:35 +00:00
|
|
|
folder_pdf="pdf_minutes"
|
2024-05-19 20:35:02 +00:00
|
|
|
|
2024-05-13 22:35:27 +00:00
|
|
|
# make teh html files first
|
2024-05-13 22:41:52 +00:00
|
|
|
function build_html() {
|
|
|
|
# wipe and reset teh old html folder
|
2024-05-19 20:35:02 +00:00
|
|
|
rm -rf "$folder_html"
|
|
|
|
mkdir "$folder_html"
|
2024-05-13 22:41:52 +00:00
|
|
|
|
|
|
|
# this folder has css and images needed
|
2024-05-19 20:35:02 +00:00
|
|
|
cp -R Minutes/_Templates "$folder_html/"
|
2024-05-13 22:41:52 +00:00
|
|
|
|
|
|
|
cd Minutes
|
|
|
|
|
|
|
|
# loop through each year worth of data
|
|
|
|
for year in */; do
|
|
|
|
# skip symlinks
|
|
|
|
[ -L "''${year%/}" ] && continue
|
|
|
|
# exclude teh template fodler
|
|
|
|
if [[ $year == *"_Templates"* ]]; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
|
|
|
# go into the year folder
|
|
|
|
cd $year
|
|
|
|
|
|
|
|
# convert the Committee ones first
|
|
|
|
cp ../../_scripts/md_toml/_Minutes-Committee.md.toml ./.md.toml
|
|
|
|
cargo-bfom
|
|
|
|
|
|
|
|
# then the council
|
|
|
|
cp ../../_scripts/md_toml/_Minutes-Council.md.toml ./.md.toml
|
|
|
|
cargo-bfom
|
|
|
|
|
|
|
|
# cleanup
|
|
|
|
rm -f .md.toml
|
|
|
|
|
|
|
|
# create teh new folders where stuff is going to
|
2024-05-19 20:35:02 +00:00
|
|
|
mkdir -p "../../$folder_html/$year/Committee"
|
|
|
|
mkdir -p "../../$folder_html/$year/Council"
|
2024-05-13 22:41:52 +00:00
|
|
|
|
|
|
|
# iterate the files
|
2024-08-10 22:40:35 +00:00
|
|
|
for file in {committee,council}_html/*.html; do
|
2024-05-13 22:41:52 +00:00
|
|
|
if [ -f "$file" ]; then
|
|
|
|
stripped=''${file/_html/""}
|
2024-08-10 22:40:35 +00:00
|
|
|
echo $stripped
|
|
|
|
echo $year
|
2024-05-19 20:35:02 +00:00
|
|
|
cp $file "../../$folder_html/$year/$stripped"
|
2024-05-13 22:41:52 +00:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
# the temp folders where teh html was created, leaving these could cause ghost artifacts
|
|
|
|
rm -rf ./*_html
|
|
|
|
|
|
|
|
# back up to original folder
|
|
|
|
cd ../
|
|
|
|
done
|
|
|
|
|
|
|
|
# return to root
|
|
|
|
cd $root
|
2024-05-13 22:35:27 +00:00
|
|
|
}
|
2024-05-12 14:53:06 +00:00
|
|
|
|
2024-05-13 22:41:52 +00:00
|
|
|
function build_pdf() {
|
|
|
|
# used to match **
|
|
|
|
shopt -s globstar
|
2024-05-12 14:53:06 +00:00
|
|
|
|
2024-05-13 22:41:52 +00:00
|
|
|
# wipe and reset past runs
|
2024-05-19 20:35:02 +00:00
|
|
|
rm -rf "$folder_pdf"
|
|
|
|
mkdir "$folder_pdf"
|
2024-05-13 22:35:27 +00:00
|
|
|
|
2024-05-19 20:35:02 +00:00
|
|
|
cd "$folder_html"
|
2024-05-13 22:35:27 +00:00
|
|
|
|
2024-05-13 22:41:52 +00:00
|
|
|
for file in **/*.html; do
|
2024-05-19 20:41:57 +00:00
|
|
|
# skip teh template folder
|
|
|
|
if [[ $file == *"_Templates"* ]]; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
2024-05-13 22:41:52 +00:00
|
|
|
# only deal with files
|
|
|
|
if [ -f "$file" ]; then
|
2024-05-13 22:35:27 +00:00
|
|
|
|
2024-05-13 22:41:52 +00:00
|
|
|
# .html => .pdf
|
2024-05-19 20:35:02 +00:00
|
|
|
output="../$folder_pdf/${file/.html/".pdf"}"
|
2024-05-12 14:53:06 +00:00
|
|
|
|
2024-05-13 22:41:52 +00:00
|
|
|
echo $output
|
2024-05-12 14:53:06 +00:00
|
|
|
|
2024-05-13 22:41:52 +00:00
|
|
|
# have someplace for it to go
|
|
|
|
mkdir -p $(dirname $output)
|
2024-05-12 14:53:06 +00:00
|
|
|
|
2024-05-13 22:41:52 +00:00
|
|
|
wkhtmltopdf -q --enable-local-file-access --no-stop-slow-scripts "$file" "$output" 2>>../errors.log &
|
|
|
|
fi
|
|
|
|
done
|
2024-05-13 22:35:27 +00:00
|
|
|
|
2024-05-13 22:41:52 +00:00
|
|
|
shopt -u globstar
|
|
|
|
cd $root
|
2024-05-13 23:15:27 +00:00
|
|
|
|
|
|
|
# wait for background tasks to complete
|
|
|
|
wait $(jobs -p)
|
2024-05-13 22:35:27 +00:00
|
|
|
}
|
|
|
|
|
2024-05-13 22:41:52 +00:00
|
|
|
if [[ $1 == "html" ]]; then
|
|
|
|
build_html
|
2024-05-13 22:35:27 +00:00
|
|
|
else
|
2024-05-13 22:41:52 +00:00
|
|
|
build_html
|
|
|
|
build_pdf
|
|
|
|
fi
|