From: Jonathan Blake Date: Thu, 15 Feb 2018 04:15:06 +0000 (+0000) Subject: added utility scripts to make publishing books easier X-Git-Tag: 20180215~6 X-Git-Url: http://git.projectaon.org/?p=project-aon.git;a=commitdiff_plain;h=c6338dc3c2d3299fdf71c128a7b707d7a69762dd added utility scripts to make publishing books easier git-svn-id: https://projectaon.org/data/trunk@2692 f6f3e2d7-ff33-0410-aaf5-b4bee2cdac11 --- diff --git a/common/scripts/copy-all-formats.sh b/common/scripts/copy-all-formats.sh new file mode 100755 index 0000000..3440ad9 --- /dev/null +++ b/common/scripts/copy-all-formats.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +# +# Copy all formats for the specified book(s) to a directory structure that's +# ready to be pushed to the public website. +# +# Examples: +# +# copy-all-formats.sh 05sots +# +# list-bookcodes-by-series.sh gs | xargs copy-all-formats.sh + +if [ ! -d "$AONDIR" ]; then + >&2 echo "Please set the AONDIR environment variable" + exit +fi +BASE_DIR="$AONDIR/common/scripts" + +"$BASE_DIR/copy-xhtml.sh" "$@" +"$BASE_DIR/copy-svg.sh" "$@" +"$BASE_DIR/copy-ebooks.sh" "$@" diff --git a/common/scripts/copy-ebooks.sh b/common/scripts/copy-ebooks.sh new file mode 100755 index 0000000..3c39738 --- /dev/null +++ b/common/scripts/copy-ebooks.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +# +# Copy ebook files for the specified book(s) to a directory structure that's +# ready to be pushed to the public website. +# +# Examples: +# +# copy-ebooks.sh 05sots +# +# list-bookcodes-by-series.sh gs | xargs copy-ebooks.sh + +if [ ! -d "$AONDIR" ]; then + >&2 echo "Please set the AONDIR environment variable" + exit +fi +CURR_DIR=`pwd` + +BASE_DIR="$AONDIR/common/epub" +book_db="$AONDIR/common/sqlite/bookcodes.db" + +for book in $@ +do + row=($(sqlite3 -separator ' ' $book_db "select lang, series from bookcodes where book = '$book';")) + + lang=${row[0]} + series=${row[1]} + + source_dir="$BASE_DIR/$book" + + for format in epub mobi fb2 pdb lrf + do + output_dir="$CURR_DIR/$lang/$format/$series" + mkdir -p "$output_dir" + cp -av "$source_dir/$book.$format" "$output_dir" + done +done diff --git a/common/scripts/copy-svg.sh b/common/scripts/copy-svg.sh new file mode 100755 index 0000000..f2b7e08 --- /dev/null +++ b/common/scripts/copy-svg.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash +# +# Copy SVG files for the specified book(s) to a directory structure that's +# ready to be pushed to the public website. +# +# Examples: +# +# copy-svg.sh 05sots +# +# list-bookcodes-by-series.sh gs | xargs copy-svg.sh + +if [ ! -d "$AONDIR" ]; then + >&2 echo "Please set the AONDIR environment variable" + exit +fi +CURR_DIR=`pwd` + +book_db="$AONDIR/common/sqlite/bookcodes.db" + +for book in $@ +do + row=($(sqlite3 -separator ' ' $book_db "select lang, series from bookcodes where book = '$book';")) + + lang=${row[0]} + series=${row[1]} + + source_dir="$AONDIR/$lang/svg/$series" + output_dir="$CURR_DIR/$lang/svg/$series" + mkdir -p "$output_dir" + cp -av "$source_dir/$book.svgz" "$output_dir" +done diff --git a/common/scripts/copy-xhtml.sh b/common/scripts/copy-xhtml.sh new file mode 100755 index 0000000..cce7ada --- /dev/null +++ b/common/scripts/copy-xhtml.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash +# +# Copy XHTML files for the specified book(s) to a directory structure that's +# ready to be pushed to the public website. +# +# Examples: +# +# copy-xhtml.sh 05sots +# +# list-bookcodes-by-series.sh gs | xargs copy-xhtml.sh + +if [ ! -d "$AONDIR" ]; then + >&2 echo "Please set the AONDIR environment variable" + exit +fi +CURR_DIR=`pwd` + +book_db="$AONDIR/common/sqlite/bookcodes.db" + +for book in $@ +do + row=($(sqlite3 -separator ' ' $book_db "select lang, series from bookcodes where book = '$book';")) + + lang=${row[0]} + series=${row[1]} + + for format in xhtml xhtml-less-simple + do + source_dir="$AONDIR/$lang/$format/$series/$book" + output_dir="$CURR_DIR/$lang/$format/$series/$book" + mkdir -p "$output_dir" + cp -av "$source_dir"/* "$output_dir" + done + + source_dir="$AONDIR/$lang/xhtml-simple/$series" + output_dir="$CURR_DIR/$lang/xhtml-simple/$series" + mkdir -p "$output_dir" + cp -av "$source_dir/$book".* "$output_dir" +done diff --git a/common/scripts/list-bookcodes-all.sh b/common/scripts/list-bookcodes-all.sh new file mode 100755 index 0000000..043835b --- /dev/null +++ b/common/scripts/list-bookcodes-all.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +# +# List all bookcodes. + +if [ ! -d "$AONDIR" ]; then + >&2 echo "Please set the AONDIR environment variable" + exit +fi + +book_db="$AONDIR/common/sqlite/bookcodes.db" + +sqlite3 -column -noheader "$book_db" "select book from bookcodes order by book" diff --git a/common/scripts/list-bookcodes-by-lang.sh b/common/scripts/list-bookcodes-by-lang.sh new file mode 100755 index 0000000..edf62bf --- /dev/null +++ b/common/scripts/list-bookcodes-by-lang.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +# +# List all bookcodes that match given language. +# +# Example: +# list-bookcodes-by-lang.sh en es + +if [ ! -d "$AONDIR" ]; then + >&2 echo "Please set the AONDIR environment variable" + exit +fi + +book_db="$AONDIR/common/sqlite/bookcodes.db" + +for lang in $@ +do + if [[ ! $lang =~ ^[a-z][a-z]$ ]]; then + >&2 echo "invalid language" + exit + fi + + sqlite3 -column -noheader "$book_db" <&2 echo "Please set the AONDIR environment variable" + exit +fi + +book_db="$AONDIR/common/sqlite/bookcodes.db" + +for series in $@ +do + if [[ ! $series =~ ^[a-z][a-z]$ ]]; then + >&2 echo "invalid series" + exit + fi + + sqlite3 -column -noheader "$book_db" <