wikbook/build.sh

66 lines
2.7 KiB
Bash
Raw Normal View History

2023-11-29 19:13:34 +01:00
#!/bin/sh -e
mkdir -p media/
mkdir -p output/
# Assets
if [[ "$*" == *"--dither"* ]]
then
cp -r media_dither/* media/
fi
if [[ "$*" == *"--hr"* ]]
then
cp -r media_hr/* media/
fi
# Gen
if [[ "$*" == *"--epub"* ]]
then
cat metadata.yaml wiktopher.md > output/assembled.md
pandoc output/assembled.md --from markdown+line_blocks+inline_notes --toc -V toc-title:"Table of Contents" --toc-depth=2 --epub-metadata=metadata.yaml --epub-cover-image=media/cover_epub.jpg --css epub.css -w epub -o output/wiktopher.epub
fi
if [[ "$*" == *"--pdf"* ]]
then
pandoc --variable=geometry:a5paper wiktopher.md --pdf-engine=tectonic --from markdown+line_blocks+inline_notes --toc -V toc-title:"Table of Contents" --toc-depth=2 --include-in-header=titlesec-conf.tex -o output/pdf.pdf
gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=output/final_pdf.pdf output/pdf.pdf
# # # main title page
pandoc --variable=geometry:a5paper wiktopher.md --pdf-engine=tectonic --include-in-header=titlepage.tex -o output/titlepage.pdf
# # # copyright page
pandoc --variable=geometry:a5paper wiktopher.md --pdf-engine=tectonic --include-in-header=copyright.tex -o output/copyright.pdf
# Combine PDFs
gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=output/wiktopher.pdf output/cover.pdf output/titlepage.pdf output/copyright.pdf output/final_pdf.pdf
fi
if [[ "$*" == *"--print"* ]]
then
2023-11-30 06:10:49 +01:00
# convert media/cover.jpg output/cover.pdf
2023-11-29 19:13:34 +01:00
pandoc --variable=geometry:a5paper wiktopher.md --pdf-engine=tectonic --from markdown+line_blocks+inline_notes --toc -V toc-title:"Table of Contents" --toc-depth=2 --include-in-header=titlesec-conf.tex -o output/draft.pdf
2023-11-30 06:10:49 +01:00
gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=output/final_draft.pdf output/draft.pdf
2023-11-29 19:13:34 +01:00
# # # main title page
pandoc --variable=geometry:a5paper wiktopher.md --pdf-engine=tectonic --include-in-header=titlepage.tex -o output/titlepage.pdf
# # # copyright page
pandoc --variable=geometry:a5paper wiktopher.md --pdf-engine=tectonic --include-in-header=copyright.tex -o output/copyright.pdf
# Combine PDFs
# pdfunite output/cover.pdf output/titlepage.pdf output/copyright.pdf output/draft.pdf output/wiktopher_print.pdf
2023-11-30 06:10:49 +01:00
gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=output/wiktopher_print.pdf output/titlepage.pdf output/copyright.pdf output/final_draft.pdf
2023-11-29 19:13:34 +01:00
fi
if [[ "$*" == *"--push"* ]]
then
~/bin/butler push output/wiktopher.pdf hundredrabbits/wiktopher-desert-tales:pdf
~/bin/butler push output/wiktopher.epub hundredrabbits/wiktopher-desert-tales:epub
~/bin/butler push output/wiktopher.mobi hundredrabbits/wiktopher-desert-tales:mobi
~/bin/butler push output/wiktopher.kepub.epub hundredrabbits/wiktopher-desert-tales:kepub.epub
fi
if [[ "$*" == *"--clean"* ]]
then
rm -f output/*
rm -f media/*
fi