fix: better scripting to allow folks to make teh html only
This commit is contained in:
parent
9882340b6d
commit
d4869448fb
4 changed files with 103 additions and 34 deletions
|
@ -1,52 +1,104 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
root="$PWD"
|
||||
|
||||
# delete to allow for a full rebuild without any ghost artifacts
|
||||
rm -rf "Minutes_pdf"
|
||||
# make teh html files first
|
||||
function build_html(){
|
||||
# wipe and reset teh old html folder
|
||||
rm -rf Minutes_html
|
||||
mkdir Minutes_html
|
||||
|
||||
cd Minutes
|
||||
# this folder has css and images needed
|
||||
cp -R Minutes/_Templates Minutes_html/
|
||||
|
||||
for year in */ ; do
|
||||
# skip symlinks
|
||||
[ -L "''${year%/}" ] && continue
|
||||
# exclude teh template fodler
|
||||
if [[ $year == *"_Templates"* ]]; then
|
||||
continue
|
||||
fi
|
||||
cd Minutes
|
||||
|
||||
# go into the year folder
|
||||
cd $year
|
||||
# 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
|
||||
|
||||
# convert the Committee ones first
|
||||
# go into the year folder
|
||||
cd $year
|
||||
|
||||
cp ../../_scripts/md_toml/_Minutes-Committee.md.toml ./.md.toml
|
||||
cargo-bfom
|
||||
# convert the Committee ones first
|
||||
cp ../../_scripts/md_toml/_Minutes-Committee.md.toml ./.md.toml
|
||||
cargo-bfom
|
||||
|
||||
cp ../../_scripts/md_toml/_Minutes-Council.md.toml ./.md.toml
|
||||
cargo-bfom
|
||||
# then the council
|
||||
cp ../../_scripts/md_toml/_Minutes-Council.md.toml ./.md.toml
|
||||
cargo-bfom
|
||||
|
||||
mkdir -p "../../Minutes_pdf/$year/Committee"
|
||||
mkdir -p "../../Minutes_pdf/$year/Council"
|
||||
# cleanup
|
||||
rm -f .md.toml
|
||||
|
||||
# iterate the files
|
||||
for file in {Committee,Council}_html/*.html; do
|
||||
# create teh new folders where stuff is going to
|
||||
mkdir -p "../../Minutes_html/$year/Committee"
|
||||
mkdir -p "../../Minutes_html/$year/Council"
|
||||
|
||||
# iterate the files
|
||||
for file in {Committee,Council}_html/*.html; do
|
||||
if [ -f "$file" ]; then
|
||||
stripped=''${file/_html/""}
|
||||
cp $file "../../Minutes_html/$year/$stripped"
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
function build_pdf(){
|
||||
# used to match **
|
||||
shopt -s globstar
|
||||
|
||||
# wipe and reset past runs
|
||||
rm -rf Minutes_pdf
|
||||
mkdir Minutes_pdf
|
||||
|
||||
cd Minutes_html
|
||||
|
||||
for file in **/*.html; do
|
||||
# skip teh template folder
|
||||
if [[ $file == *"_Templates"* ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
# only deal with files
|
||||
if [ -f "$file" ]; then
|
||||
|
||||
# we need teh filename/path
|
||||
stripped=''${file/.html/""}
|
||||
|
||||
output="../../Minutes_pdf/$year${stripped/_html/""}.pdf"
|
||||
# .html => .pdf
|
||||
output="../Minutes_pdf/''${file/.html/".pdf"}"
|
||||
|
||||
echo $output
|
||||
|
||||
wkhtmltopdf -q --enable-local-file-access --no-stop-slow-scripts "$stripped.html" "$output" 2>> ../errors.log
|
||||
# have someplace for it to go
|
||||
mkdir -p $(dirname $output)
|
||||
|
||||
wkhtmltopdf -q --enable-local-file-access --no-stop-slow-scripts "$file" "$output" 2>> ../errors.log &
|
||||
fi
|
||||
done
|
||||
|
||||
# cleanup
|
||||
rm -f .md.toml
|
||||
# the temp folders where teh html was created, leaving these could cause ghost artifacts
|
||||
rm -rf ./*_html
|
||||
done
|
||||
shopt -u globstar
|
||||
cd $root
|
||||
}
|
||||
|
||||
cd ../
|
||||
|
||||
if [[ $1 == "html" ]];
|
||||
then
|
||||
build_html
|
||||
else
|
||||
build_html
|
||||
build_pdf
|
||||
fi
|
Loading…
Add table
Add a link
Reference in a new issue