Skip to content

Commit

Permalink
Renamed guide target filename. Updated exif data
Browse files Browse the repository at this point in the history
  • Loading branch information
stevespringett committed Mar 27, 2024
1 parent 444e01b commit e1c6dbd
Showing 1 changed file with 17 additions and 26 deletions.
43 changes: 17 additions & 26 deletions generate-document.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ case $1 in
exit;;
esac

echo "Task: Generate CycloneDX $BOMTYPE guide"
echo -n "Task: Generate CycloneDX $BOMTYPE guide"

function command_exists () {
command -v $1 >/dev/null 2>&1;
Expand All @@ -38,7 +38,7 @@ generate_docx() {
--toc \
--toc-depth=2 \
-t docx \
-o "../OWASP_CycloneDX-$BOMTYPE-Guide-SNAPSHOT-$LANG.docx" *.md
-o "../OWASP_CycloneDX-Authoritative-Guide-to-$BOMTYPE-SNAPSHOT-$LANG.docx" *.md
echo -n "\nRemoving temporary emf files...\n"
find ../.. -type f -name '*.emf' -print -delete
}
Expand All @@ -47,48 +47,40 @@ generate_pdf() {
BOMTYPE=$1
LANG=$2
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
libreoffice --headless --convert-to pdf "../OWASP_CycloneDX-$BOMTYPE-Guide-SNAPSHOT-$LANG.docx" --outdir ../
libreoffice --headless --convert-to pdf "../OWASP_CycloneDX-Authoritative-Guide-to-$BOMTYPE-SNAPSHOT-$LANG.docx" --outdir ../
#mv "../OWASP_CycloneDX-SBOM-Guide-SNAPSHOT-$1.pdf" "../OWASP_CycloneDX-SBOM-Guide-TEMP-$1.pdf"
else
pyenv local 3.10.8
docx2pdf "../OWASP_CycloneDX-$BOMTYPE-Guide-SNAPSHOT-$LANG.docx" "../OWASP_CycloneDX-$BOMTYPE-Guide-SNAPSHOT-$LANG.pdf"
pdfcli watermark -o "../OWASP_CycloneDX-$BOMTYPE-Guide-SNAPSHOT-$LANG.pdf" "../OWASP_CycloneDX-$BOMTYPE-Guide-SNAPSHOT-$LANG.pdf" "../../templates/watermark.pdf"
docx2pdf "../OWASP_CycloneDX-Authoritative-Guide-to-$BOMTYPE-SNAPSHOT-$LANG.docx" "../OWASP_CycloneDX-Authoritative-Guide-to-$BOMTYPE-SNAPSHOT-$LANG.pdf"
pdfcli watermark -o "../OWASP_CycloneDX-Authoritative-Guide-to-$BOMTYPE-SNAPSHOT-$LANG.pdf" "../OWASP_CycloneDX-Authoritative-Guide-to-$BOMTYPE-SNAPSHOT-$LANG.pdf" "../../templates/watermark.pdf"
fi
pdfcli join "../en/images/cover.pdf" "../OWASP_CycloneDX-$BOMTYPE-Guide-SNAPSHOT-$LANG.pdf" "../../images/back.pdf" -o "../OWASP_CycloneDX-$BOMTYPE-Guide-SNAPSHOT-$LANG.pdf"
exiftool -Title="My Doc Title" -Author="Open Web Application Security Project (OWASP)" -Subject="CycloneDX BOM Standard" "../OWASP_CycloneDX-$BOMTYPE-Guide-SNAPSHOT-$LANG.pdf"
pdfcli join "../en/images/cover.pdf" "../OWASP_CycloneDX-Authoritative-Guide-to-$BOMTYPE-SNAPSHOT-$LANG.pdf" "../../images/back.pdf" -o "../OWASP_CycloneDX-Authoritative-Guide-to-$BOMTYPE-SNAPSHOT-$LANG.pdf"
exiftool -Title="Authoritative Guide to $BOMTYPE" -Author="OWASP Foundation" -Subject="CycloneDX BOM Standard" "../OWASP_CycloneDX-Authoritative-Guide-to-$BOMTYPE-SNAPSHOT-$LANG.pdf"
}

generate_epub() {
cleanup() {
BOMTYPE=$1
LANG=$2
pandoc -s -f gfm --css=../../templates/book.css \
--lua-filter=../../templates/pagebreak.lua \
--columns 10000 \
--metadata title="My Doc Title" --metadata author="OWASP CycloneDX" \
--epub-cover-image=../en/images/cover.jpg \
--toc \
--toc-depth=1 \
-t epub \
-o "../OWASP_CycloneDX-$BOMTYPE-Guide-SNAPSHOT-$LANG.epub" *.md
echo -n "Cleaning up temporary documents\n"
rm -f ../OWASP_CycloneDX-Authoritative-Guide-to-$BOMTYPE-$LANG.docx || true
rm -f ../OWASP_CycloneDX-Authoritative-Guide-to-$BOMTYPE-$LANG.pdf || true
rm -f ../OWASP_CycloneDX-Authoritative-Guide-to-$BOMTYPE-SNAPSHOT-$LANG.docx || true
rm -f ../OWASP_CycloneDX-Authoritative-Guide-to-$BOMTYPE-SNAPSHOT-$LANG.pdf_original || true
}

# generate_html() {
# pandoc -s -f markdown_github -t html5 -o "../OWASP_SCVS-SNAPSHOT-$1.html" *.md
# }

generate() {
BOMTYPE=$1
LANG=$2
echo -n "Generating CycloneDX $BOMTYPE Guide ($LANG)..."
echo -n "Generating CycloneDX Authoritative Guide to $BOMTYPE ($LANG)...\n"
if [ -d "$BOMTYPE/$LANG" ];
then
cd "$BOMTYPE/$LANG"
generate_docx $BOMTYPE $LANG
generate_pdf $BOMTYPE $LANG
generate_epub $BOMTYPE $LANG
# generate_html $1
cleanup $BOMTYPE $LANG
cd ../..
echo " done."
echo "Done"
echo "Generated OWASP CycloneDX Authoritative Guide to $BOMTYPE ($LANG)"
else
echo " No CycloneDX guide found in directory $1"
fi
Expand Down Expand Up @@ -134,4 +126,3 @@ generate $BOMTYPE "en"
#generate $BOMTYPE "ukr"

echo
echo "Generated OWASP CycloneDX $BOMTYPE Guide"

0 comments on commit e1c6dbd

Please sign in to comment.