-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake-shower-from-googledocs
More file actions
executable file
·86 lines (77 loc) · 3.1 KB
/
make-shower-from-googledocs
File metadata and controls
executable file
·86 lines (77 loc) · 3.1 KB
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
if [ $# -ne 5 ]
then
echo "Usage: `basename $0` <google-docs-title> <title> <header> <theme> <prefix>"
exit
fi
set -e
CSV="./testquiz.csv"
HEADER='<!DOCTYPE HTML><html lang="no-NB"><head>
<title>TITLE</title><meta charset="UTF-8">
<meta name="viewport" content="width=1274, user-scalable=no">
<link rel="stylesheet" href="shower/themes/THEME/styles/screen.css">
<!-- To apply styles to the certain
slides use slide ID to get needed elements -->
<style>
h1 { text-align:center; font-size:55px; }
p {text-align:center; font-size:45px;}
blockquote p {text-align:center; font-size:25px;}
.slide section::before { background: none; }
.slide:after { content: none; }
.slide section {
background: #FFFFFF url(pictures/huset.png)
no-repeat left bottom; margin: 0px 0px 0px 40px;
}
.logo {
height: 25px;
}
</style>
</head><body class="list"><header class="caption"><h1>TITLE</h1>
<p>INFO</p></header>
<div class="slide" id="intro"><div>
<section><header>
<h1>TITLE</h1><br><h1>INFO</h1>
</header></section>
<div style="position: absolute; bottom: 0px; left: 0px; right: 0px; text-align: center;"><img class="logo" src="huset.jpg" /> TITLE - INFO </div>
</div></div>'
FOOTER='<script src="shower/shower.min.js"></script></body></html>'
google docs get "$1" $CSV --format=csv
csvtool col 1-2 $CSV.csv | csvtool drop 1 - | csvtool head 25 - | csvtool readable - > round1.tmp
csvtool col 1-2 $CSV.csv | csvtool drop 27 - | csvtool head 25 - | csvtool readable -> round2.tmp
rm $CSV.csv
TITLE="$2"
INFO="$3"
THEME="$4"
PREFIX="$5"
Q='<div class="slide" id="NUMBER"><div>
<section>
<header>
<h1>Spørsmål NUMBER</h1>
</header>
<p>QUESTION</p>
</section>
<div style="position: absolute; bottom: 0px; left: 0px; right: 0px; text-align: center;"><img class="logo" src="huset.jpg" /> TITLE - INFO</div>
</div></div>'
FILENAME="${PREFIX}runde-1.html"
QUESTIONS=""
while read line; do
NUMBER=$(echo "$line" | cut -d ' ' -f 1 | sed -e 's|^ *||g' -e 's| *$||g')
QUESTION=$(echo "$line" | cut -d ' ' -f 2- | sed -e 's|^ *||g' -e 's| *$||g')
HTML=$(echo "$Q" | sed -e "s|NUMBER|$NUMBER|g" -e "s|QUESTION|$QUESTION|g" -e "s|TITLE|$TITLE|g" -e "s|INFO|$INFO|g")
QUESTIONS=$( echo -e "$QUESTIONS\n$HTML")
done < round1.tmp
echo "$HEADER" | sed -e "s|TITLE|$TITLE|g" -e "s|INFO|$INFO|g" -e "s|THEME|$THEME|g" > $FILENAME
echo "$QUESTIONS" >> $FILENAME
echo "$FOOTER" >> $FILENAME
FILENAME="${PREFIX}runde-2.html"
QUESTIONS=""
while read line; do
NUMBER=$(echo "$line" | cut -d ' ' -f 1 | sed -e 's|^ *||g' -e 's| *$||g')
QUESTION=$(echo "$line" | cut -d ' ' -f 2- | sed -e 's|^ *||g' -e 's| *$||g')
HTML=$(echo "$Q" | sed -e "s|NUMBER|$NUMBER|g" -e "s|QUESTION|$QUESTION|g" -e "s|TITLE|$TITLE|g" -e "s|INFO|$INFO|g")
QUESTIONS=$( echo -e "$QUESTIONS\n$HTML")
done < round2.tmp
echo "$HEADER" | sed -e "s|TITLE|$TITLE|g" -e "s|INFO|$INFO|g" -e "s|THEME|$THEME|g" > $FILENAME
echo "$QUESTIONS" >> "$FILENAME"
echo "$FOOTER" >> "$FILENAME"
rm round1.tmp round2.tmp
echo "Finished"