doc: handovers are now in a better folder and scripts have been updated to deal with it
This commit is contained in:
parent
af359864d1
commit
1676c6fc25
4 changed files with 96 additions and 44 deletions
|
@ -1,55 +1,107 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
cd Committee
|
||||
root="$PWD"
|
||||
|
||||
# cleanup the last run (if there was one)
|
||||
rm -rf _Handovers_html
|
||||
folder_html="Handovers_html"
|
||||
folder_pdf="Handovers_pdf"
|
||||
|
||||
# copy in teh config for this folder
|
||||
cp ../_scripts/md_toml/_Handovers.md.toml ./.md.toml
|
||||
function build_html() {
|
||||
# used to match **
|
||||
shopt -s globstar
|
||||
|
||||
cargo-bfom
|
||||
# cleanup the last run (if there was one)
|
||||
rm -rf "$folder_html"
|
||||
mkdir "$folder_html"
|
||||
|
||||
## cleanup
|
||||
rm -f .md.toml
|
||||
cd Committee
|
||||
|
||||
# if the user only wants teh html tehn early return
|
||||
if [[ $1 == "html" ]]; then
|
||||
exit 0
|
||||
fi
|
||||
root_html="$PWD"
|
||||
|
||||
# recursively parse _Handovers_html use wkhtmltopdf to convert to pdf
|
||||
cd _Handovers_html
|
||||
# loop through each year worth of data
|
||||
# the globbing is to only get ones that have a handover folder
|
||||
for year in **/Handovers; do
|
||||
# skip symlinks
|
||||
[ -L "''${year%/}" ] && continue
|
||||
|
||||
out_folder="../_Handovers_pdf"
|
||||
rm -rf "$out_folder"
|
||||
for d in */; do
|
||||
# skip symlinks
|
||||
[ -L "''${d%/}" ] && continue
|
||||
# exclude teh template fodler
|
||||
if [[ $d == *"_Templates"* ]]; then
|
||||
continue
|
||||
fi
|
||||
if ! [[ $year =~ [0-9]{4}-[0-9]{4} ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
# create output folder
|
||||
mkdir -p "$out_folder/$d"
|
||||
year_string="${year/\/Handovers/""}"
|
||||
|
||||
# iterate the files
|
||||
for file in $d*.html; do
|
||||
cd "$year_string"
|
||||
|
||||
# copy in teh config for this folder
|
||||
cp ../../_scripts/md_toml/_Handovers.md.toml ./.md.toml
|
||||
|
||||
# convert teh handovers
|
||||
cargo-bfom
|
||||
|
||||
# copy in teh relevent files
|
||||
cp -R ../_Templates/Handovers/* ./Handovers_html
|
||||
# no need to have the template in the output
|
||||
rm -f ./Handovers_html/_template.md
|
||||
rm -f ./Handovers_html/general.html
|
||||
rm -f .md.toml
|
||||
|
||||
# make the final folder
|
||||
mkdir -p "$root/$folder_html/$year_string"
|
||||
|
||||
# copy everything to teh final folder
|
||||
cp -R ./Handovers_html/* "$root/$folder_html/$year_string"
|
||||
|
||||
# remove teh temp folder
|
||||
rm -rf ./Handovers_html
|
||||
|
||||
# return to root
|
||||
cd "$root_html"
|
||||
done
|
||||
|
||||
# undo the globbing
|
||||
shopt -u globstar
|
||||
|
||||
|
||||
# back to root
|
||||
cd $root
|
||||
}
|
||||
|
||||
|
||||
function build_pdf() {
|
||||
# used to match **
|
||||
shopt -s globstar
|
||||
|
||||
# wipe and reset past runs
|
||||
rm -rf "$folder_pdf"
|
||||
mkdir "$folder_pdf"
|
||||
|
||||
cd "$folder_html"
|
||||
|
||||
for file in **/*.html; do
|
||||
# only deal with files
|
||||
if [ -f "$file" ]; then
|
||||
|
||||
# we need teh filename/path
|
||||
stripped=''${file/.html/""}
|
||||
# .html => .pdf
|
||||
output="../$folder_pdf/${file/.html/".pdf"}"
|
||||
|
||||
echo "$out_folder/$stripped.pdf"
|
||||
echo $output
|
||||
|
||||
# convert teh html to pdf
|
||||
wkhtmltopdf -q --enable-local-file-access --no-stop-slow-scripts "$stripped.html" "$out_folder/$stripped.pdf" 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
|
||||
done
|
||||
|
||||
cd ../
|
||||
shopt -u globstar
|
||||
cd $root
|
||||
|
||||
# wait for background tasks to complete
|
||||
wait $(jobs -p)
|
||||
# wait for background tasks to complete
|
||||
wait $(jobs -p)
|
||||
}
|
||||
|
||||
if [[ $1 == "html" ]]; then
|
||||
build_html
|
||||
else
|
||||
build_html
|
||||
build_pdf
|
||||
fi
|
Loading…
Add table
Add a link
Reference in a new issue