fmt: format using shfmt

This commit is contained in:
silver 2024-05-13 23:41:52 +01:00
parent d4869448fb
commit e6969ab164
Signed by untrusted user: silver
GPG key ID: 54E2C71918E93B74
2 changed files with 92 additions and 95 deletions

View file

@ -15,7 +15,7 @@ rm -f .md.toml
# if the user only wants teh html tehn early return # if the user only wants teh html tehn early return
if [[ $1 == "html" ]]; then if [[ $1 == "html" ]]; then
exit 0; exit 0
fi fi
# recursively parse _Handovers_html use wkhtmltopdf to convert to pdf # recursively parse _Handovers_html use wkhtmltopdf to convert to pdf
@ -23,30 +23,30 @@ cd _Handovers_html
out_folder="../_Handovers_pdf" out_folder="../_Handovers_pdf"
rm -rf "$out_folder" rm -rf "$out_folder"
for d in */ ; do for d in */; do
# skip symlinks # skip symlinks
[ -L "''${d%/}" ] && continue [ -L "''${d%/}" ] && continue
# exclude teh template fodler # exclude teh template fodler
if [[ $d == *"_Templates"* ]]; then if [[ $d == *"_Templates"* ]]; then
continue continue
fi fi
# create output folder # create output folder
mkdir -p "$out_folder/$d" mkdir -p "$out_folder/$d"
# iterate the files # iterate the files
for file in $d*.html; do for file in $d*.html; do
if [ -f "$file" ]; then if [ -f "$file" ]; then
# we need teh filename/path # we need teh filename/path
stripped=''${file/.html/""} stripped=''${file/.html/""}
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>> ../errors.log & 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
cd ../ cd ../

View file

@ -3,102 +3,99 @@
root="$PWD" root="$PWD"
# make teh html files first # make teh html files first
function build_html(){ function build_html() {
# wipe and reset teh old html folder # wipe and reset teh old html folder
rm -rf Minutes_html rm -rf Minutes_html
mkdir Minutes_html mkdir Minutes_html
# this folder has css and images needed # this folder has css and images needed
cp -R Minutes/_Templates Minutes_html/ cp -R Minutes/_Templates Minutes_html/
cd Minutes cd Minutes
# loop through each year worth of data # 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
# exclude teh template fodler # exclude teh template fodler
if [[ $year == *"_Templates"* ]]; then if [[ $year == *"_Templates"* ]]; then
continue continue
fi fi
# go into the year folder # go into the year folder
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 # 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
# cleanup # cleanup
rm -f .md.toml rm -f .md.toml
# create teh new folders where stuff is going to # create teh new folders where stuff is going to
mkdir -p "../../Minutes_html/$year/Committee" mkdir -p "../../Minutes_html/$year/Committee"
mkdir -p "../../Minutes_html/$year/Council" 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/""} stripped=''${file/_html/""}
cp $file "../../Minutes_html/$year/$stripped" cp $file "../../Minutes_html/$year/$stripped"
fi fi
done done
# the temp folders where teh html was created, leaving these could cause ghost artifacts # the temp folders where teh html was created, leaving these could cause ghost artifacts
rm -rf ./*_html rm -rf ./*_html
# back up to original folder # back up to original folder
cd ../ cd ../
done done
# return to root # return to root
cd $root cd $root
} }
function build_pdf() {
# used to match **
shopt -s globstar
function build_pdf(){ # wipe and reset past runs
# used to match ** rm -rf Minutes_pdf
shopt -s globstar mkdir Minutes_pdf
# wipe and reset past runs cd Minutes_html
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
for file in **/*.html; do # only deal with files
# skip teh template folder if [ -f "$file" ]; then
if [[ $file == *"_Templates"* ]]; then
continue
fi
# only deal with files # .html => .pdf
if [ -f "$file" ]; then output="../Minutes_pdf/''${file/.html/".pdf"}"
# .html => .pdf echo $output
output="../Minutes_pdf/''${file/.html/".pdf"}"
echo $output # have someplace for it to go
mkdir -p $(dirname $output)
# have someplace for it to go wkhtmltopdf -q --enable-local-file-access --no-stop-slow-scripts "$file" "$output" 2>>../errors.log &
mkdir -p $(dirname $output) fi
done
wkhtmltopdf -q --enable-local-file-access --no-stop-slow-scripts "$file" "$output" 2>> ../errors.log & shopt -u globstar
fi cd $root
done
shopt -u globstar
cd $root
} }
if [[ $1 == "html" ]]; then
if [[ $1 == "html" ]]; build_html
then
build_html
else else
build_html build_html
build_pdf build_pdf
fi fi