forked from zilongshanren/programmers-guide
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·150 lines (132 loc) · 3.6 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
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#!/bin/bash
### State what we need for this script to run
echo "this script reqires: "
echo ""
echo "mkdocs: http://www.mkdocs.org/"
echo "gpp: brew install gpp"
echo "Bash 4.0: brew install bash"
echo "Pandoc: http://johnmacfarlane.net/pandoc/getting-started.html"
echo "A LaTex Distribution: http://www.tug.org/mactex/downloading.html"
echo "run: sudo /usr/local/texlive/2014/bin/universal-darwin/tlmgr install ec ecc"
echo ""
echo "To Do: Be able to insert a page break at the end of each chapter. right now it is continuous"
echo ""
### Define variables that we need for this script
### These are the chapters are are currently done. Add chapters here.
allDocuments=('blank' 'index' '1' '2' '3' '4' '5' '6' '7' '8' '9' '10' '11'
'12' '13' '14' 'A' 'B' 'C' 'D' 'E' 'F' 'G' 'H' 'I')
misc=('blank' 'index')
chaptersWithFolders=('2' '3' '4' '5' '9' 'B' 'C' 'D' 'F' 'G' 'H' 'I')
chaptersWithOutFolders=('1' '8' '9' '13' 'A' 'E')
foundDirs=()
### Turn on globbing (BASH 4 required)
shopt -s globstar
### We need to move the appropriate sized images to directory each chapter
### is looking for.
echo "building the html version with mkdocs..."
echo "output is in site/..."
echo "copying resources to respective directories..."
rm -rf docs/
mkdir -p docs
mkdir -p print
for i in ${chaptersWithFolders[@]}; do
rsync -a chapters/${i}-web docs/
rsync -a chapters/${i}-print print/
mv docs/${i}-web docs/${i}-img
mv print/${i}-print print/${i}-img
cp chapters/${i}.md docs/${i}.md
cp chapters/${i}.md print/${i}.md
done
for i in ${chaptersWithOutFolders[@]}; do
cp chapters/${i}.md docs/${i}.md
cp chapters/${i}.md print/${i}.md
done
for i in ${misc[@]}; do
cp chapters/${i}.md docs/${i}.md
cp chapters/${i}.md print/${i}.md
done
### Pre-process the markdown files
### for the web = -DWEB
### without -DWEB = print
### Do every chapter, just in case images get added we dont have to modify script
#echo "pre-processing chapters for the web..."
#for i in ${chapters[@]}; do
# gpp -H -DWEB chapters/${i}.md -o docs/${i}.md
# gpp -H chapters/${i}.md -o print/${i}.md
#done
### Now we can use MKDocs to build the static content
echo "MKDocs Build..."
rm -rf site/
mkdocs build
### build the ePub and PDF versions
echo "building the ePUB and PDF versions..."
cp solarized-light.css main.css style.css _layout.html5 print/.
for i in ${allDocuments[@]}; do
pandoc -s --template "_layout" --css "solarized-light.css" -f markdown -t html5 -o print/${i}.html print/${i}.md
done
#mv print/title.html print/intro.html #Silly this is because of a misnamed file I should fix.
echo "building the epub version..."
cd print/
pandoc -S --epub-stylesheet=style.css -o ProgrammersGuide.epub \
index.html \
blank.html \
1.html \
blank.html \
2.html \
blank.html \
3.html \
blank.html \
4.html \
blank.html \
5.html \
#blank.html \
#6.html \
#blank.html \
#7.html \
blank.html \
8.html \
blank.html \
9.html \
#blank.html \
#10.html \
#blank.html \
#11.html \
#blank.html \
#12.html \
blank.html \
13.html \
#blank.html \
#14.html \
blank.html \
A.html \
blank.html \
B.html \
blank.html \
C.html \
blank.html \
D.html \
blank.html \
E.html \
blank.html \
F.html \
blank.html \
G.html \
blank.html \
H.html \
blank.html \
I.html \
blank.html
### Building the PDF version
echo "building the PDF version..."
pandoc -s -o ProgrammersGuide.pdf ProgrammersGuide.epub
cd ..
cp print/ProgrammersGuide.pdf print/ProgrammersGuide.epub site/.
### Copy out to slackmoehrle.github.io
rsync -a site/ ../slackmoehrle.github.io/
cd ../slackmoehrle.github.io
git add .
git commit -m 'published automatically from script'
git push
cd ../programmers-guide
## clean up for next time
rm -rf print/