#!/bin/bash # This script is executed by make in the parent directory [ "$HOSTNAME" != lime2 ] || exit 1 main() { replace_header_and_footer_lines cp ~/src/flytex2html/src/style.css ./procedures/procedure.css for folder in ~/src/procedures/*; do if [ -d "$folder" ]; then process "$folder" fi done remove_procedure_placeholder } process() { folder="$1" name=$(basename "$folder") name_without_date=$(echo "$name" | sed -E 's/procedure_//g; s/_202.+//g') display_name=$(echo "$name_without_date" | sed -E 's/-/ /g; s/_/ /g') verbose -n "Pulling ${name}... " mkdir -p ./procedures/"$name_without_date" flytex2html -c '../procedure.css' --origin-paths -t "$display_name" "$folder"/main.tex > ./procedures/"$name_without_date"/index.html sed -i '/' ./procedures/"$name_without_date"/index.html cp -r "$folder"/img ./procedures/"$name_without_date"/img # copy pdf #cp "$folder"/procedure*.pdf ./procedures/procedure_"$name".pdf && echo "Updated $name" replace_procedure_line "$name" "$display_name" } replace_header_and_footer_lines() { awk -v header="$(<./header.html)" '{sub(/===HEADER===/,header)} 1' ./procedures/index.template.html | awk -v footer="$(<./footer.html)" '{sub(/===FOOTER===/,footer)} 1' > ./procedures/index.tmp.html } replace_procedure_line() { name="$1" display_name="$2" sed -i "s@===PROCEDURE===@
  • ${display_name}

  • \n===PROCEDURE===@g" ./procedures/index.tmp.html } remove_procedure_placeholder() { chmod 644 ./procedures/index.html sed 's/===PROCEDURE===//g' ./procedures/index.tmp.html > ./procedures/index.html && rm ./procedures/index.tmp.html chmod 444 ./procedures/index.html } verbose() { if [ "$VERBOSE" = true ]; then echo "$@" fi } main