Modernized command invocations a bit.
[gitmagic/dustin.git] / makeover
blobd527851d29cdb280898c21ade93d58f5bb157833
1 #!/bin/bash
3 # extract table of contents from index.html
4 # and delete preface link
5 BOOKDIR=book
6 gawk '
7 /<div class="toc">/ {
8 print $0
9 getline #TODO: check this is the <ul> line
10 print $0
11 print "<li><a href=\".\">Git Magic</a></li>"
12 getline
13 while (!match($0, "</div>")) {
14 if (match($0, "<li><span class=\"preface\"")) {
15 while (!match($0, "</span>")) {
16 getline
18 getline
20 print $0
21 getline
23 print "</div>"
24 exit
26 ' < $BOOKDIR/index.html > toc.tmp
28 # for every file except the index...
29 for FILE in $BOOKDIR/*.html
31 if [ $FILE != "$BOOKDIR/index.html" ]
32 then
33 # add "Git Magic - " to titles of all pages
34 sed '/<title>/ s/<title>/&Git Magic - /' -i $FILE
35 sed 's/pr01\.html/index.html/g' -i $FILE
36 # paste ToC into beginning
37 # 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 sed '/^<\/body/i </div><div class="footer"><a href="/~blynn/">My Homepage</a></div>' -i $BOOKDIR/*.html
47 mv $BOOKDIR/pr01.html $BOOKDIR/index.html
48 rm toc.tmp