mistype
[gitmagic.git] / makeover
blob84a164555a2546fac686b1f591bd3699eaef298b
1 #!/bin/bash
3 # Extract table of contents from index.html and delete preface link.
4 BOOKDIR=book-$1
5 TITLE="Git Magic"
6 case $1 in
7 ru)
8 TITLE="Волшебство Git"
9 ;;
10 esac
12 gawk '
13 /<div class="toc">/ {
14 print $0
15 getline
16 print $0
17 print "<li><b>'"$TITLE"'</b></li>"
18 getline
19 while (!match($0, "</div>")) {
20 gsub("pr01.html", "index.html")
21 print $0
22 getline
24 print $0
25 exit
27 ' < $BOOKDIR/index.html > toc.tmp
29 # For every file except the index...
30 for FILE in $BOOKDIR/*.html
32 if [ $FILE != "$BOOKDIR/index.html" ]
33 then
34 # Prepend "Git Magic - " to titles of all pages.
35 sed '/<title>/ s/<title>/&'"$TITLE"' - /' -i $FILE
36 sed 's/pr01\.html/index.html/g' -i $FILE
37 # Paste ToC into beginning and add div section with class content for CSS.
38 sed '/<body/{n; r toc.tmp
39 a <div class="content">
40 }' -i $FILE
41 sed '/^<\/body/i </div>' -i $FILE
43 done
45 # Originally this link was "My Homepage". Since it appears on translations of
46 # the guide, I changed it to my name so it doesn't have to be translated.
47 sed '/^<\/body/i </div><div class="footer"><a href="/~blynn/">Ben Lynn</a></div>' -i $BOOKDIR/*.html
49 cp $BOOKDIR/pr01.html $BOOKDIR/index.html
50 rm toc.tmp