epiphoque-affiches/generate.sh
2024-12-13 17:56:39 +01:00

30 lines
832 B
Bash
Executable file

#!/usr/bin/bash
set -e
cd "$(realpath "$(dirname "$0")")"
rm -fr './out'
mkdir -p './out'
(cd phoques; ls) | while read file
do
infos="$(echo "$file" | cut -d '.' -f 1)"
nam="$(echo "$infos" | cut -d '_' -f 1)"
ori="$(echo "$infos" | cut -d '_' -f 2)"
row="$(echo "$infos" | cut -d '_' -f 3)"
col="$(echo "$infos" | cut -d '_' -f 4)"
msg="$(echo "$infos" | cut -d '_' -f 5)"
echo "nam: '$nam', file: '$file', ori: '$ori', row: '$row', col: '$col', msg: '$msg'"
cat src/index.html \
| sed "s/FILE/$file/g" \
| sed "s/NAM/$nam/g" \
| sed "s/ORI/$ori/g" \
| sed "s/COL/$col/g" \
| sed "s/ROW/$row/g" \
| sed "s/MSG/$msg/g" \
> "out/$nam.html"
chromium --headless --print-to-pdf="out/$nam.pdf" "out/$nam.html"
done