From c6338dc3c2d3299fdf71c128a7b707d7a69762dd Mon Sep 17 00:00:00 2001 From: Jonathan Blake Date: Thu, 15 Feb 2018 04:15:06 +0000 Subject: [PATCH] added utility scripts to make publishing books easier git-svn-id: https://projectaon.org/data/trunk@2692 f6f3e2d7-ff33-0410-aaf5-b4bee2cdac11 --- common/scripts/copy-all-formats.sh | 20 +++++++++++ common/scripts/copy-ebooks.sh | 36 +++++++++++++++++++ common/scripts/copy-svg.sh | 31 ++++++++++++++++ common/scripts/copy-xhtml.sh | 39 +++++++++++++++++++++ common/scripts/list-bookcodes-all.sh | 12 +++++++ common/scripts/list-bookcodes-by-lang.sh | 28 +++++++++++++++ common/scripts/list-bookcodes-by-series.sh | 28 +++++++++++++++ common/sqlite/bookcodes.db | Bin 0 -> 12288 bytes 8 files changed, 194 insertions(+) create mode 100755 common/scripts/copy-all-formats.sh create mode 100755 common/scripts/copy-ebooks.sh create mode 100755 common/scripts/copy-svg.sh create mode 100755 common/scripts/copy-xhtml.sh create mode 100755 common/scripts/list-bookcodes-all.sh create mode 100755 common/scripts/list-bookcodes-by-lang.sh create mode 100755 common/scripts/list-bookcodes-by-series.sh create mode 100644 common/sqlite/bookcodes.db 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" <4I2Gi{TcpWG(XG-=bh{ZE=SojWs`nV_Imf(xr?EV>X{CUfs(Cb@TR zoO_aK1qFXVyU>kps)(B|R74ko2nt0(M6jT)6vWzPL9|O1LBI2J&qTZEQm|)W$h`0Q zzVDp#-bvueBM+ZyG2dxKov_B7Vrn>LS*g1nCzVPqz`Gyb$;*Nd=|sR!u5a~PNX?C2 z!}PaQADv3kDf;=X8qB&$z$9Q2FbS9hOadkWlYmLUBw!LS377=_%LJa8u(proa@Mo` zthOBZ%Tcsek32utANuZHT0D7r(K&tco>PmCwxy#&J>>}+h-kFKRr0@_H7$m%vq^c+w;%GPXs{pXKNcQ68fw@ z%UM@{Yr ztHG)lG(|&R6jVaruZw~cqM!^L2GW=l#=P%&LCh=galT`|?{lGemiW%bu^W>?QEwh6+H^GvthH=Y)fP02t<%wt=EFhTE~A< zn&fagYiGTPc}gGRTNJ9S8O44(=nfr(E$l*NlM8x)pTAIMjc7UK2H7vF=UK$MTq6gj z*@aR^s+>^85KaWO`$TPlEz8MdQfPNGVsh4Aq4TUB!GU4c9^UOPbeBc<1YdQl@}w|r zT<8k(qLx_SEp(X$kvJ+I6VGy}bk?m41v-XPLUWxHGQC?sT z=mwdQG7jP5(47|5g+}rS`^8pn6RrWPePY#JiTMMDgIQ8H8vF|rbO+%tP8BV2{=bSB z>DTl!F46btoAhOTkUm92dIpcs2k4#HqBH1MIzflfkLWA%2l|*?NAHmD&}-xi^dk8X zF>(pj$t&bJv_v|jMjj$3NuJ~gf&UELz*q4Vd>Oxo-@q^64cx$w-oAh6%*{;#CIORx zNx&pv5-4zr0i3h8u>3sD09jia=1Xdf zrum{YdN^N@Gq&)&t4cJ`=T%9M=uar8hxBuDW6ku()esH!v&zs^Kcftd^~Y!iu-?*K zKTR^g^;QD*Q#M>JYi%L>qgjX~YyAuDj|^u3?X4c$AC?>S;QkPXjciNN{Xuz`EqH%G zHE6!yPhcc8D8P4=RD_>X9sR)&Ut zlo$#152=v~`v=uGE8+eDRjgf literal 0 HcmV?d00001 -- 2.17.1