#!/bin/bash -e shopt -s globstar tree_output=$(mktemp "/tmp/$USER.XXXXXXXXXX") tree_file=$(mktemp "/tmp/$USER.XXXXXXXXXX") trap "rm \"$tree_output\" \"$tree_file\"" EXIT # Variables included in the pandoc template now="$(date -Iseconds)" generator="$(pandoc --version | head -n1)" function convert { pandoc \ --read markdown \ --write html \ --standalone \ --template template.html \ --highlight-style zenburn \ --css "/~$USER/theme.css" \ --variable generator="$generator" \ --variable now="$now" \ -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 function link_assets { for src in "$1"/*; do dest="${src/#assets/html}" if [ ! -h "$dest" ] && [ -d "$dest" ]; then link_assets "$src" else echo "Symlinking $src to $dest" ln -fTs "$(echo "$dest" | sed 's|[^/]*/|../|g;s|/[^/]*$||')/$src" "$dest" fi done } link_assets assets # Build the 'everything' page and CDF feed echo 'Building article list' pushd html >/dev/null tree --du --si -X --prune -P '*.html' > "$tree_output" popd >/dev/null echo "--- title: everything --- " > "$tree_file" xsltproc xsl/tree-html.xsl "$tree_output" >> "$tree_file" convert "$tree_file" "html/everything.html" xsltproc xsl/tree-cdf.xsl "$tree_output" | xmllint --format - > "html/everything.cdf" xmllint --noout --schema "assets/xsd/cdf.xsd" "html/everything.cdf" chmod 644 "html/everything.cdf" # Build an RSS feed echo 'Building RSS feed' echo ' ~lucidiot'"'"'s wiki https://envs.net/~lucidiot/ latest articles on ~lucidiot'"'"'s personal wiki en-FR Creative Commons BY 4.0 International, ~lucidiot lucidiot@envs.net (lucidiot) lucidiot@envs.net (lucidiot) /bin/bash https://www.rssboard.org/rss-specification ' > html/rss.xml for file in content/**/*.md; do link="${file##content/}" link="https://envs.net/~lucidiot/${link/%.md/.html}" echo ' '"$(sed -n 's|\s*title:\s*\(.*\)$|\1|p' "$file")"' '"$(date -Rd "@$(stat -c%Y "$file")")"' '"$link"' '"$link"' ' >> html/rss.xml done echo ' ' >> html/rss.xml chmod 644 html/rss.xml