wiki/build.sh

50 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
shopt -s globstar
include_after=$(mktemp "/tmp/$USER.XXXXXXXXXX")
tree_file=$(mktemp "/tmp/$USER.XXXXXXXXXX")
trap "rm \"$include_after\" \"$tree_file\"" EXIT
# Preprocess include-after.html
sed "s/{{ now }}/$(date --iso-8601=seconds)/g;s/{{ generator }}/$(pandoc --version | head -n1)/g" include-after.html > "$include_after"
function convert {
pandoc \
--read markdown \
--write html \
--standalone \
--include-in-header include-header.html \
--include-before-body include-before.html \
--include-after-body "$include_after" \
--highlight-style zenburn \
--css "/~$USER/theme.css" \
-o "$2" \
"$1"
chmod 644 "$2"
}
for file in content/**/*.md; do
output="${file/#content/html}"
output="${output/%.md/.html}"
mkdir -p "$(dirname "$output")"
chmod 711 "$(dirname "$output")"
echo "Building $file to $output"
convert "$file" "$output"
done
# Build the 'everything' page
echo "---
title: everything
---
" > "$tree_file"
pushd html >/dev/null
tree --du --si -X --prune -P '*.html' | xsltproc ../xsl/tree.xsl - >> "$tree_file"
popd >/dev/null
convert "$tree_file" "html/everything.html"
for src in assets/*; do
dest="${src/#assets/html}"
echo "Symlinking $src to $dest"
ln -fTs "../$src" "$dest"
done