-
Notifications
You must be signed in to change notification settings - Fork 198
/
add_bootstrap.sh
executable file
·67 lines (49 loc) · 2.17 KB
/
add_bootstrap.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
# This script runs through all the html files in notebooks/, and adds in
# bootstrap tags where appropriate.
printf "\nAdding link to bootstrap resources."
# String right before where the new element should go.
before_string=""
# String right after where the new element should go.
after_string="<\/head>"
# String that should be added in.
new_string="<link href='css\/bootstrap.css' rel='stylesheet' media='screen'>\n"
#new_string+="<link href='jumbotron-narrow.css' rel='stylesheet'>\n"
new_string+="<link href='css\/non-responsive.css' rel='stylesheet'>\n"
# Leaving this line in makes for responsive site, but then code blocks get mangled on mobile.
# May put this back in if just code blocks can be made non-responsive.
#new_string+="<meta name='viewport' content='width=device-width, initial-scale=1.0'>\n"
new_string+="<link href='css\/bootstrap_overrides.css' rel='stylesheet'>"
if [ -e "../notebooks/" ]
then
find ../notebooks -iname '*.html' | xargs sed -i "s/$after_string/$new_string\n$after_string\n/"
else
find notebooks -iname '*.html' | xargs sed -i "s/$after_string/$new_string\n$after_string\n/"
fi
printf "\nAdded link to bootsrap resources.\n"
# ----- Add overall bootstrap container to page -----
printf "\nAdding bootstrap to html files..."
# String right before where the new element should go.
before_string="<body>"
# String right after where the new element should go.
after_string=""
# String that should be added in.
new_string="<div class='container'>"
if [ -e "../notebooks/" ]
then
find ../notebooks -iname '*.html' | xargs sed -i "s/$before_string/$before_string\n$new_string/"
else
find notebooks -iname '*.html' | xargs sed -i "s/$before_string/$before_string\n$new_string/"
fi
# String right before where the new element should go.
before_string=""
# String right after where the new element should go.
after_string="<\/body>"
# String that should be added in.
new_string="<\/div>"
if [ -e "../notebooks/" ]
then
find ../notebooks -iname '*.html' | xargs sed -i "s/$after_string/$new_string\n$after_string\n/"
else
find notebooks -iname '*.html' | xargs sed -i "s/$after_string/$new_string\n$after_string\n/"
fi
printf "\nAdded bootstrap.\n\n"