Use an export directory rather than project root.

This commit is contained in:
2025-10-23 15:30:03 -07:00
parent bd96a6cdb5
commit 04e43ba524

View File

@@ -12,9 +12,10 @@ date
## Global Variables ## ## Global Variables ##
ebook_prefix="TechnologyAlternatives"
work_dir="$DIR/build"
header="header.md" header="header.md"
work_dir="$DIR/build"
export_dir="$DIR/export"
ebook_prefix="TechnologyAlternatives"
## Functions ## ## Functions ##
@@ -42,20 +43,21 @@ function insert {
# Compile all the snippets into one Markdown file. # Compile all the snippets into one Markdown file.
function combine { function combine {
log "Combining documents based on parameters '`echo $@`'." logs "Combining documents based on parameters '`echo $@`'."
ebook="$1.md" ebook="$1.md"
shift shift
for addition in "$@"; do for addition in "$@"; do
insert "$addition" "$ebook" insert "$addition" "$ebook"
done done
logf "Done!"
} }
# Create the PDF and booklets them move them back to the project directory. # Create the PDF and booklets them move them back to the project directory.
function convert { function convert {
source="$1" source="$1"
version="$2" version="$2"
out_dir="$3"
out_dir="$export_dir"
ebook="${source//.md/.pdf}" ebook="${source//.md/.pdf}"
logs "Creating '$out_dir/$ebook' from '$source'." logs "Creating '$out_dir/$ebook' from '$source'."
@@ -76,18 +78,20 @@ function convert {
log "Compiling '$source' to '$ebook'." log "Compiling '$source' to '$ebook'."
pandoc "$source" \ pandoc "$source" \
-s -N --toc --toc-depth=4 \ -s -N --toc --toc-depth=4 \
-o "$ebook" -o "$ebook" \
>/dev/null
status=$? status=$?
log "Creating booklet of '$ebook'." log "Creating booklet of '$ebook'."
pdfbook2 -n "$ebook" pdfbook2 -n "$ebook" >/dev/null
mv -v "$book" "$booklet" mv -v "$book" "$booklet"
log "Creating rotated booklet of '$ebook'." log "Creating rotated booklet of '$ebook'."
pdfbook2 -ns "$ebook" pdfbook2 -ns "$ebook" >/dev/null
mv -v "$book" "$rotated" mv -v "$book" "$rotated"
log "Moving '$ebook' and its booklets to '$out_dir'." log "Moving '$ebook' and its booklets to '$out_dir'."
mkdir -p "$out_dir"
mv -v *.pdf "$out_dir"/ mv -v *.pdf "$out_dir"/
logf "Complete!" logf "Complete!"
@@ -96,11 +100,9 @@ function convert {
## Cleanup ## ## Cleanup ##
log "Clean PDFs" log "Clean PDFs"
if [[ -e "$DIR/$ebook_prefix.pdf" ]]; then
echo "Old:" echo "Old:"
du -had1 "$DIR"/*.pdf | sort -h find "$DIR" -name "*".pdf -exec du -h {} \; -delete | sort -h
rm -v "$DIR"/*.pdf find "$export_dir" -name "*".pdf -exec du -h {} \; -delete | sort -h
fi
log "Clean working directory '$work_dir'" log "Clean working directory '$work_dir'"
if [[ -e "$work_dir" ]]; then if [[ -e "$work_dir" ]]; then
@@ -117,25 +119,25 @@ sed -i "s/{REVISION_DATE}/`date +'%Y-%m-%d'`/g" "$header"
# Primary, All In One (AIO) # Primary, All In One (AIO)
name="$ebook_prefix""_AllPlatforms" name="$ebook_prefix""_AllPlatforms"
combine "$name" "$header" `ls "$DIR"/content*.md` combine "$name" "$header" `ls "$DIR"/content*.md`
convert "$name.md" "" "$DIR" convert "$name.md" ""
# Secondary, Mobile # Secondary, Mobile
name="$ebook_prefix""_MobileOnly" name="$ebook_prefix""_MobileOnly"
combine "$name" "$header" "$DIR/content00"* "$DIR/content10"* \ combine "$name" "$header" "$DIR/content00"* "$DIR/content10"* \
"$DIR/content70"* "$DIR/content90"* "$DIR/content70"* "$DIR/content90"*
convert "$name.md" "(Mobile Only)" "$DIR" convert "$name.md" "(Mobile Only)"
# Secondary, Desktop # Secondary, Desktop
name="$ebook_prefix""_DesktopOnly" name="$ebook_prefix""_DesktopOnly"
combine "$name" "$header" "$DIR/content00"* "$DIR/content20"* \ combine "$name" "$header" "$DIR/content00"* "$DIR/content20"* \
"$DIR/content70"* "$DIR/content90"* "$DIR/content70"* "$DIR/content90"*
convert "$name.md" "(Desktop Only)" "$DIR" convert "$name.md" "(Desktop Only)"
# Secondary, Server # Secondary, Server
name="$ebook_prefix""_ServerOnly" name="$ebook_prefix""_ServerOnly"
combine "$name" "$header" "$DIR/content00"* "$DIR/content30"* \ combine "$name" "$header" "$DIR/content00"* "$DIR/content30"* \
"$DIR/content70"* "$DIR/content90"* "$DIR/content70"* "$DIR/content90"*
convert "$name.md" "(Server Only)" "$DIR" convert "$name.md" "(Server Only)"
## Finish! ## ## Finish! ##