Summary Files Commits Branches @commit @diff @stats
path: root / generate-hooks / make-presentation.sh
blob: d29a14595f007f6462f99ef65f6766d0f410e230 (plain) (blame)
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
#!/bin/bash

# A presentation is just a markdown file, with some added ftags for formatting into a presentation layout.
# This means all presentations will change how they look with changes to the main styles.css. It also means
# that they follow the light/dark mode setting.
# Each slide is the size of a horizontal A4 piece of paper. This makes it easy to print (and there is a dedicated
# print button).
# The whole system is based on flexboxes. The only real way to control how items are aligned is via a row and column
# directed flexboxes. This isn't the most efficient, but it's fine. And if there are performance issues, the
# presentation can always be "printed" to a PDF and consumed that way.

# You really shouldn't have anything before or after a presentation, since it might show up on the print.
# All ftags that have a closing tag, and &&presentation, need one line above and below them (but you don't
# need the first and last line of file to be empty).

# &&presentation    Required. Adds the control panel and JavaScript script. Must be the very first one!
# &&slide           Starts a slide. Slides are the main pages that hold content and are used for navigation.
# &&/slide          Ends (the last started) slide.
# &&flexer          An empty container with flex: 1. Use it for spacing out stuff.
# &&centered        Aligns text to the center.
# &&/centered       Ends (the last started) centered text.
# &&fow             Flexbox, with flex-direction row.
# &&/fow            Ends (the last started) fow.
# &&fol             Flexbox, with flex-direction column.
# &&/fol            Ends (the last started) fol.

if [ -z "$1" ]; then
	echo First parameter must be a path
	exit
fi

presentation='
		<nav id="presentCont">
			<img id="prevSlideBtn" class="unzoomable btn setting-btn icon nodisplay" src="/img/arrow-left-tabler.svg" alt="Previous">
			<img id="nextSlideBtn" class="unzoomable btn setting-btn icon nodisplay" src="/img/arrow-right-tabler.svg" alt="Next">
			<img id="presentBtn" class="unzoomable btn setting-btn icon" src="/img/presentation-tabler.svg" alt="Present">
			<img id="printBtn" class="unzoomable btn setting-btn icon" src="/img/printer-tabler.svg" alt="Print">
		</nav>
		<script type="text/javascript" src="/scripts/presentation.js" integrity="OXI4gdj1EbEP/ocoUONB7xDL8f8XWtAnVsrDIYO9KJQ+mG6N/zJP7LX834s5Q0Oyw3pEA/7XqD9ELTrBnlMeVg==" crossorigin="anonymous"></script>'
presentation=$(echo $presentation | sed 's/\//\\\//g')

# Loop through all HTML files in given directory
for file in $(find "$1" -type f -wholename "*talks/*.html"); do
	sed -i "s/<p>&#38;&#38;presentation<\/p>/$presentation/g;
			s/<p>&#38;&#38;slide<\/p>/<div class=\"slide\">/g;s/<p>&#38;&#38;&#47;slide<\/p>/<\/div>/g;
			s/<p>&#38;&#38;centered<\/p>/<div class=\"centered\">/g;s/<p>&#38;&#38;&#47;centered<\/p>/<\/div>/g;
			s/<p>&#38;&#38;flexer<\/p>/<div class=\"flexer\"><\/div>/g;s/&#38;&#38;flexer/<div class=\"flexer\"><\/div>/g;
			s/<p>&#38;&#38;fow<\/p>/<div class=\"fow\">/g;s/<p>&#38;&#38;&#47;fow<\/p>/<\/div>/g;
			s/<p>&#38;&#38;fol<\/p>/<div class=\"fol\">/g;s/<p>&#38;&#38;&#47;fol<\/p>/<\/div>/g" \
			"$file"
done