added new script to list all book info from bookcodes.db
[project-aon.git] / common / scripts / copy-xhtml.sh
1 #!/usr/bin/env bash
2 #
3 # Copy XHTML files for the specified book(s) to a directory structure that's
4 # ready to be pushed to the public website.
5 #
6 # Examples:
7 #
8 #     copy-xhtml.sh 05sots
9 #
10 #     list-bookcodes-by-series.sh gs | xargs copy-xhtml.sh
11
12 if [ ! -d "$AONDIR" ]; then
13     >&2 echo "Please set the AONDIR environment variable"
14     exit 1
15 fi
16 CURR_DIR=`pwd`
17
18 if [ "$AONDIR" -ef "$CURR_DIR" ]; then
19     >&2 echo "Current directory is the same as AONDIR: giving up"
20     exit 1
21 fi
22
23 for book in $@
24 do
25     row=( $($AONDIR/common/scripts/list-book-info.sh $book) )
26
27     lang=${row[1]}
28     series=${row[2]}
29
30     for format in xhtml xhtml-less-simple
31     do
32         source_dir="$AONDIR/$lang/$format/$series/$book"
33         output_dir="$CURR_DIR/$lang/$format/$series/$book"
34         mkdir -p "$output_dir"
35         cp -av "$source_dir"/* "$output_dir"
36     done
37
38     source_dir="$AONDIR/$lang/xhtml-simple/$series"
39     output_dir="$CURR_DIR/$lang/xhtml-simple/$series"
40     mkdir -p "$output_dir"
41     cp -av "$source_dir/$book".* "$output_dir"
42 done