forked from rodrigogribeiro/bcc222-material
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-and-run.sh
executable file
·46 lines (37 loc) · 1.62 KB
/
build-and-run.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
#!/bin/bash
# Test Haskell environment
cd /vagrant/aula09
sudo -u vagrant stack exec aula09-exe
if [ ! -d "/vagrant/slides" ]; then
mkdir /vagrant/slides
fi
# Clone org-reveal repository
if [ ! -d "/home/vagrant/.emacs.d/org-reveal" ]; then
git clone https://github.com/yjwen/org-reveal.git /home/vagrant/.emacs.d/org-reveal
fi
# Set up Emacs for org-reveal
sudo -u vagrant echo "(add-to-list 'load-path (expand-file-name \"org-reveal\" \"~/.emacs.d\"))" >> /home/vagrant/.emacs
sudo -u vagrant echo "(require 'ox-reveal)" >> /home/vagrant/.emacs
# Install org-reveal package
sudo -u vagrant emacs --batch -l /home/vagrant/.emacs -eval '(load-library "ox-reveal")'
# Define function to export slides
echo "(defun export-slides (file) (find-file file) (org-reveal-export-to-html))" >> /home/vagrant/export.el
# Loop through directories and export org files as reveal.js slides
for dir in /vagrant/aula* /vagrant/extra*; do
if [ -d "$dir" ]; then
for file in "$dir"/*.org; do
if [ -f "$file" ]; then
# Store REVEAL_ROOT in a variable
reveal_root=$(grep -oP '#\+REVEAL_ROOT: \K.*' "$file")
# Change REVEAL_ROOT to CDN URL
sed -i "s|$reveal_root|https://cdn.jsdelivr.net/npm/[email protected]/|" "$file"
# Export slides
sudo -u vagrant emacs --batch -l /home/vagrant/.emacs -l /home/vagrant/export.el --eval "(export-slides \"$file\")"
# Move slides to slides directory
mv "${file%.org}.html" /vagrant/slides/
# Restore REVEAL_ROOT to original value
sed -i "s|https://cdn.jsdelivr.net/npm/[email protected]/|$reveal_root|" "$file"
fi
done
fi
done