forked from openenglishbible/USFM-Tools
-
Notifications
You must be signed in to change notification settings - Fork 14
/
buildUTB.sh
executable file
·114 lines (101 loc) · 3.12 KB
/
buildUTB.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/usr/bin/env bash
# -*- coding: utf8 -*-
#
# Copyright (c) 2014 unfoldingWord
# http://creativecommons.org/licenses/MIT/
# See LICENSE file for details.
#
# Contributors:
# Jesse Griffin <[email protected]>
PROGNAME="${0##*/}"
EXPORT=0
TOOLS=/var/www/vhosts/door43.org/tools
USFMSRC=/tmp/UTB-USFM
TEX2UP=bible-2up.tex
TEXPDF=bible-pdf.tex
help() {
echo
echo "Publish unfoldingWord Bible"
echo
echo "Usage:"
echo " $PROGNAME -v <version> -l <language> [-e <exportfromd43first>]"
echo " $PROGNAME --help"
echo
exit 1
}
if [ $# -lt 1 ]; then
help
fi
while test -n "$1"; do
case "$1" in
--help|-h)
help
;;
--version|-v)
VER=$2
shift
;;
--language|-l)
LANG=$2
shift
;;
--export|-e)
EXPORT=1
shift
;;
*)
echo "Unknown argument: $1"
help
;;
esac
shift
done
if [ $EXPORT -eq 1 ]; then
echo "Exporting USFM from DokuWiki..."
$TOOLS/uwb/dw2usfm_assembled.sh
RET=$?
if [ $RET -ne 0 ]; then
echo "--> Export failed, bailing..."
exit 1
fi
fi
NAME="UDB-$LANG-v$VER-`date +%F`"
USFMPUBDIR="/tmp/UDB-$LANG-v$VER"
buildPDF () {
# $1 == source dir, $2 source filename, $3 == output filename
echo 'Building PDF..'
. /opt/context/tex/setuptex
WORKING="$1/working/tex-working/"
[ -d "$WORKING" ] && rm -rf "$WORKING"
mkdir -p "$WORKING"
cd "$WORKING"
context "../tex/$2"
cp "$WORKING/${2%%.tex}.pdf" "$1/$3"
cd -
}
buildMD () {
# $1 == source dir, $2 source filename, $3 == output filename
echo " Building Markdown from $2"
pandoc +RTS -K128m -RTS -s "$1/$2" -o "$USFMPUBDIR/$3"
}
# Must run before PDF build below
python transform.py --target=context --usfmDir=$USFMSRC --builtDir=$USFMPUBDIR --name=$NAME
cp -f support/introTeXt-2up.tex "$USFMPUBDIR/working/tex/$TEX2UP"
cp -f support/introTeXt-pdf.tex "$USFMPUBDIR/working/tex/$TEXPDF"
cat "$USFMPUBDIR/working/tex/bible.tex" >> "$USFMPUBDIR/working/tex/$TEX2UP"
cat "$USFMPUBDIR/working/tex/bible.tex" >> "$USFMPUBDIR/working/tex/$TEXPDF"
sed -i "s/UTBVERSUB/$VER/" "$USFMPUBDIR/working/tex/$TEX2UP"
sed -i "s/UTBVERSUB/$VER/" "$USFMPUBDIR/working/tex/$TEXPDF"
buildPDF "$USFMPUBDIR" "$TEX2UP" "$NAME-2up.pdf"
#buildPDF "$USFMPUBDIR" "$TEXPDF" "$NAME.pdf"
#buildMD "$USFMPUBDIR" "$TEXPDF" "$NAME.md"
#python transform.py --target=md --usfmDir=$USFMSRC --builtDir=$USFMPUBDIR --name=$NAME
# maybe pandoc for these formats too?
#python transform.py --target=html --usfmDir=$USFMSRC --builtDir=$USFMPUBDIR --name=$NAME
#python transform.py --target=singlehtml --usfmDir=$USFMSRC --builtDir=$USFMPUBDIR --name=$NAME
#python transform.py --target=csv --usfmDir=$USFMSRC --builtDir=$USFMPUBDIR --name=$NAME
#python transform.py --target=ascii --usfmDir=$USFMSRC --builtDir=$USFMPUBDIR --name=$NAME
###python transform.py --target=reader --usfmDir=$USFMSRC --builtDir=$USFMPUBDIR --name=$NAME
# Build each book individually
#for
echo "See $USFMPUBDIR"