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