You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
76 lines
1.6 KiB
Bash
76 lines
1.6 KiB
Bash
2 years ago
|
#!/bin/bash
|
||
|
|
||
|
print-slide-top() {
|
||
|
declare title="$1"
|
||
|
|
||
|
cat <<EOF
|
||
|
<!DOCTYPE HTML>
|
||
|
<html>
|
||
|
<head>
|
||
|
<title>${title}</title>
|
||
|
<link rel="stylesheet" type="text/css" href="style.css">
|
||
|
<meta charset="UTF-8">
|
||
|
</head>
|
||
|
<body>
|
||
|
<script src="main.js"></script>
|
||
|
<main>
|
||
|
<article>
|
||
|
EOF
|
||
|
}
|
||
|
|
||
|
print-slide-bottom() {
|
||
|
declare previous="$1"
|
||
|
declare next="$2"
|
||
|
|
||
|
echo '
|
||
|
</article>
|
||
|
</main>
|
||
|
<nav>
|
||
|
<a id="previous" href='"$previous"'>← previous</a>
|
||
|
<a id="next" href='"$next"'>next →</a>
|
||
|
</nav>
|
||
|
</body>
|
||
|
</html>'
|
||
|
}
|
||
|
|
||
|
|
||
|
# Determine script directory (requires GNU readlink)
|
||
|
here="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
|
||
|
publish_dir="$here/publish"
|
||
|
|
||
|
printf 'Changing directory: '
|
||
|
pushd "$here" || exit $?
|
||
|
|
||
|
mkdir -p "$publish_dir" || exit $?
|
||
|
|
||
|
publish_file="$here/publish.txt"
|
||
|
|
||
|
declare -a slides=()
|
||
|
mapfile -t slides < "$publish_file"
|
||
|
|
||
|
for i in "${!slides[@]}"; do
|
||
|
declare previous="${slides[i == 0 ? 0 : i -1]}"
|
||
|
declare next="${slides[i + 1 >= ${#slides[@]} ? i : i + 1]}"
|
||
|
declare slide="${slides[i]}"
|
||
|
|
||
|
destination="$publish_dir/$(basename "$slide")"
|
||
|
previous="$(basename "$previous")" || exit $?
|
||
|
next="$(basename "$next")" || exit $?
|
||
|
|
||
|
if ((i == 0)); then
|
||
|
destination="$publish_dir/index.html"
|
||
|
fi
|
||
|
|
||
|
if ((i == 0)) || ((i == 1)); then
|
||
|
previous="index.html"
|
||
|
fi
|
||
|
|
||
|
print-slide-top 'ROR Presentatie' > "$destination"
|
||
|
cat "$slide" >> "$destination"
|
||
|
print-slide-bottom "$previous" "$next" >> "$destination"
|
||
|
done
|
||
|
|
||
|
cp -v style.css "$publish_dir/style.css"
|
||
|
cp -v main.js "$publish_dir/main.js"
|
||
|
cp -rv assets "$publish_dir/"
|