-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.sh
executable file
·56 lines (43 loc) · 2 KB
/
build.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
#!/bin/bash
if [ "$1" == "clean" ]; then
find -name *.aux -exec rm {} \;
fi
# PDF version
pdflatex ZWayManual.tex
# Prepare HTML version
rm -R ZWayManual
latex2html -split +1 -no_auto_link -long_titles 20 -use_pdftex -html_version 5.0,math,unicode -no_navigation -no_footnode -info "" ZWayManual.tex
cd ZWayManual
# extract TOC
echo '<div id="TOC"> <div class="toc-open"><div></div>Z-Way Manual</div>' > TOC.html
awk '/^<!--End of Table of Child-Links-->$/ { tocStart = 0 } { if (tocStart) { print } } /^<!--Table of Child-Links-->$/ { tocStart = 1 }' ZWayManual.html >> TOC.html
echo '</div>' >> TOC.html
# delete TOC
awk -i inplace '/^<!--Table of Child-Links-->$/ { tocStart = 1 } !/^<BR><HR>$/ { if (!tocStart) { print } } /^<!--End of Table of Child-Links-->$/ { tocStart = 0 }' ZWayManual.html
# add CSS styles and alter existing
sed -i 's/^\.CENTER { text-align:center; }$/.CENTER { }/' ZWayManual.css
sed -i 's/^\.CENTER > \* { margin:auto; }$/.CENTER > * { }/' ZWayManual.css
cat ../html/ZWayManualAddOn.css >> ZWayManual.css
# copy JS for TOC
cp ../html/ZWayManualAddOn.js ZWayManual.js
for f in `ls -1 *.html`; do
# change meta keywords
sed -i 's/<META NAME="keywords" CONTENT="ZWayManual">/<META NAME="keywords" CONTENT="Z-Way Manual">/' $f
# change title
sed -i 's/<TITLE>/<TITLE>Z-Way Manual — /' $f
# delete subsection TOC
awk -i inplace '/^<!--Table of Child-Links-->$/ { tocStart = 1 } !/^<HR>$/ { if (tocStart == 2) { tocStart = 0 } } { if (!tocStart) { print } } /^<!--End of Table of Child-Links-->$/ { tocStart = 2 }' $f
# add TOC in new format
sed -i '/<BODY >/ r TOC.html' $f
# install JS for TOC
sed -i 's|</HEAD>|<script src="ZWayManual.js" defer></script>\n</HEAD>|' $f
done
ln -s ZWayManual.html index.html
rm TOC.html
cd ..
rm -f TOC.html ZWayManual.css
# Copy to the server
if [ "$DRY_RUN" != "true" ]; then
scp ZWayManual.pdf ZWayManual/* zwm1.z-wave.me:/var/www/z-wave.me/manual/z-way/
scp ZWayManual.pdf ZWayManual/* storage.z-wave.me:/var/www/rus.z-wave.me/files/manual/z-way/
fi