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
|
@ -34,6 +34,7 @@ handovers:
|
||||||
name: "Handovers"
|
name: "Handovers"
|
||||||
paths:
|
paths:
|
||||||
- Committee/_Handovers_pdf/
|
- Committee/_Handovers_pdf/
|
||||||
|
- Committee/errors.log
|
||||||
|
|
||||||
|
|
||||||
minutes:
|
minutes:
|
||||||
|
@ -45,4 +46,4 @@ minutes:
|
||||||
name: "Minutes"
|
name: "Minutes"
|
||||||
paths:
|
paths:
|
||||||
- Minutes_pdf/
|
- Minutes_pdf/
|
||||||
- Minutes/errors.log
|
- errors.log
|
||||||
|
|
|
@ -2,6 +2,9 @@
|
||||||
|
|
||||||
cd Committee
|
cd Committee
|
||||||
|
|
||||||
|
# cleanup the last run (if there was one)
|
||||||
|
rm -rf _Handovers_html
|
||||||
|
|
||||||
# copy in teh config for this folder
|
# copy in teh config for this folder
|
||||||
cp ../_scripts/md_toml/_Handovers.md.toml ./.md.toml
|
cp ../_scripts/md_toml/_Handovers.md.toml ./.md.toml
|
||||||
|
|
||||||
|
@ -10,6 +13,11 @@ cargo-bfom
|
||||||
## cleanup
|
## cleanup
|
||||||
rm -f .md.toml
|
rm -f .md.toml
|
||||||
|
|
||||||
|
# if the user only wants teh html tehn early return
|
||||||
|
if [[ $1 == "html" ]]; then
|
||||||
|
exit 0;
|
||||||
|
fi
|
||||||
|
|
||||||
# recursively parse _Handovers_html use wkhtmltopdf to convert to pdf
|
# recursively parse _Handovers_html use wkhtmltopdf to convert to pdf
|
||||||
cd _Handovers_html
|
cd _Handovers_html
|
||||||
|
|
||||||
|
@ -36,7 +44,7 @@ for d in */ ; do
|
||||||
echo "$out_folder/$stripped.pdf"
|
echo "$out_folder/$stripped.pdf"
|
||||||
|
|
||||||
# convert teh html to pdf
|
# convert teh html to pdf
|
||||||
wkhtmltopdf -q --enable-local-file-access --no-stop-slow-scripts "$stripped.html" "$out_folder/$stripped.pdf" 2> ./tmp.txt
|
wkhtmltopdf -q --enable-local-file-access --no-stop-slow-scripts "$stripped.html" "$out_folder/$stripped.pdf" 2>> ../errors.log &
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|
|
@ -1,11 +1,19 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
root="$PWD"
|
||||||
|
|
||||||
# delete to allow for a full rebuild without any ghost artifacts
|
# make teh html files first
|
||||||
rm -rf "Minutes_pdf"
|
function build_html(){
|
||||||
|
# wipe and reset teh old html folder
|
||||||
|
rm -rf Minutes_html
|
||||||
|
mkdir Minutes_html
|
||||||
|
|
||||||
|
# this folder has css and images needed
|
||||||
|
cp -R Minutes/_Templates Minutes_html/
|
||||||
|
|
||||||
cd Minutes
|
cd Minutes
|
||||||
|
|
||||||
|
# loop through each year worth of data
|
||||||
for year in */ ; do
|
for year in */ ; do
|
||||||
# skip symlinks
|
# skip symlinks
|
||||||
[ -L "''${year%/}" ] && continue
|
[ -L "''${year%/}" ] && continue
|
||||||
|
@ -18,35 +26,79 @@ for year in */ ; do
|
||||||
cd $year
|
cd $year
|
||||||
|
|
||||||
# convert the Committee ones first
|
# convert the Committee ones first
|
||||||
|
|
||||||
cp ../../_scripts/md_toml/_Minutes-Committee.md.toml ./.md.toml
|
cp ../../_scripts/md_toml/_Minutes-Committee.md.toml ./.md.toml
|
||||||
cargo-bfom
|
cargo-bfom
|
||||||
|
|
||||||
|
# then the council
|
||||||
cp ../../_scripts/md_toml/_Minutes-Council.md.toml ./.md.toml
|
cp ../../_scripts/md_toml/_Minutes-Council.md.toml ./.md.toml
|
||||||
cargo-bfom
|
cargo-bfom
|
||||||
|
|
||||||
mkdir -p "../../Minutes_pdf/$year/Committee"
|
# cleanup
|
||||||
mkdir -p "../../Minutes_pdf/$year/Council"
|
rm -f .md.toml
|
||||||
|
|
||||||
|
# create teh new folders where stuff is going to
|
||||||
|
mkdir -p "../../Minutes_html/$year/Committee"
|
||||||
|
mkdir -p "../../Minutes_html/$year/Council"
|
||||||
|
|
||||||
# iterate the files
|
# iterate the files
|
||||||
for file in {Committee,Council}_html/*.html; do
|
for file in {Committee,Council}_html/*.html; do
|
||||||
if [ -f "$file" ]; then
|
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
|
||||||
|
|
||||||
# we need teh filename/path
|
# back up to original folder
|
||||||
stripped=''${file/.html/""}
|
cd ../
|
||||||
|
done
|
||||||
|
|
||||||
output="../../Minutes_pdf/$year${stripped/_html/""}.pdf"
|
# 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
|
||||||
|
|
||||||
|
# .html => .pdf
|
||||||
|
output="../Minutes_pdf/''${file/.html/".pdf"}"
|
||||||
|
|
||||||
echo $output
|
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
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# cleanup
|
shopt -u globstar
|
||||||
rm -f .md.toml
|
cd $root
|
||||||
# the temp folders where teh html was created, leaving these could cause ghost artifacts
|
}
|
||||||
rm -rf ./*_html
|
|
||||||
done
|
|
||||||
|
|
||||||
cd ../
|
|
||||||
|
if [[ $1 == "html" ]];
|
||||||
|
then
|
||||||
|
build_html
|
||||||
|
else
|
||||||
|
build_html
|
||||||
|
build_pdf
|
||||||
|
fi
|
|
@ -52,11 +52,19 @@
|
||||||
export PATH=${pkgs.lib.makeBinPath [pkgs.wkhtmltopdf bfom.defaultPackage.x86_64-linux]}:$PATH
|
export PATH=${pkgs.lib.makeBinPath [pkgs.wkhtmltopdf bfom.defaultPackage.x86_64-linux]}:$PATH
|
||||||
${./_scripts/format_handovers.sh}
|
${./_scripts/format_handovers.sh}
|
||||||
'';
|
'';
|
||||||
|
handovers_html = pkgs.writeShellScriptBin "format_handovers_html" ''
|
||||||
|
export PATH=${pkgs.lib.makeBinPath [pkgs.wkhtmltopdf bfom.defaultPackage.x86_64-linux]}:$PATH
|
||||||
|
${./_scripts/format_handovers.sh} html
|
||||||
|
'';
|
||||||
|
|
||||||
minutes = pkgs.writeShellScriptBin "format_minutes" ''
|
minutes = pkgs.writeShellScriptBin "format_minutes" ''
|
||||||
export PATH=${pkgs.lib.makeBinPath [pkgs.wkhtmltopdf bfom.defaultPackage.x86_64-linux]}:$PATH
|
export PATH=${pkgs.lib.makeBinPath [pkgs.wkhtmltopdf bfom.defaultPackage.x86_64-linux]}:$PATH
|
||||||
${./_scripts/format_minutes.sh}
|
${./_scripts/format_minutes.sh}
|
||||||
'';
|
'';
|
||||||
|
minutes_html = pkgs.writeShellScriptBin "format_minutes_html" ''
|
||||||
|
export PATH=${pkgs.lib.makeBinPath [pkgs.wkhtmltopdf bfom.defaultPackage.x86_64-linux]}:$PATH
|
||||||
|
${./_scripts/format_minutes.sh} html
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue