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