2021-03-21 11:40:01 +00:00
|
|
|
#!/bin/bash
|
|
|
|
shopt -s globstar
|
|
|
|
|
2021-03-21 16:27:10 +00:00
|
|
|
include_after=$(mktemp "/tmp/$USER.XXXXXXXXXX")
|
|
|
|
tree_file=$(mktemp "/tmp/$USER.XXXXXXXXXX")
|
|
|
|
trap "rm \"$include_after\" \"$tree_file\"" EXIT
|
|
|
|
|
2021-03-21 11:40:01 +00:00
|
|
|
# Preprocess include-after.html
|
2021-03-21 16:27:10 +00:00
|
|
|
sed "s/{{ now }}/$(date --iso-8601=seconds)/g;s/{{ generator }}/$(pandoc --version | head -n1)/g" include-after.html > "$include_after"
|
2021-03-21 11:40:01 +00:00
|
|
|
|
2021-03-21 16:27:10 +00:00
|
|
|
function convert {
|
2021-03-21 11:40:01 +00:00
|
|
|
pandoc \
|
|
|
|
--read markdown \
|
|
|
|
--write html \
|
|
|
|
--standalone \
|
|
|
|
--include-in-header include-header.html \
|
|
|
|
--include-before-body include-before.html \
|
2021-03-21 16:27:10 +00:00
|
|
|
--include-after-body "$include_after" \
|
2021-03-21 18:39:05 +00:00
|
|
|
--highlight-style zenburn \
|
2021-03-21 16:27:10 +00:00
|
|
|
--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"
|
2021-03-21 11:40:01 +00:00
|
|
|
done
|
|
|
|
|
2021-03-23 21:27:11 +00:00
|
|
|
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
|
2021-03-23 22:37:00 +00:00
|
|
|
|
|
|
|
# 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"
|
|
|
|
|
|
|
|
# Build an RSS feed
|
|
|
|
echo '<?xml version="1.0"?>
|
|
|
|
<rss
|
|
|
|
version="2.0"
|
|
|
|
xmlns:admin="http://webns.net/mvcb/"
|
|
|
|
xmlns:atom="http://www.w3.org/2005/Atom"
|
|
|
|
xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule"
|
|
|
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
|
|
|
>
|
|
|
|
<channel>
|
|
|
|
<title>~lucidiot'"'"'s wiki</title>
|
|
|
|
<link>https://envs.net/~lucidiot/</link>
|
|
|
|
<description>latest articles on ~lucidiot'"'"'s personal wiki</description>
|
|
|
|
<language>en-FR</language>
|
|
|
|
<copyright>Creative Commons BY 4.0 International, ~lucidiot</copyright>
|
|
|
|
<managingEditor>lucidiot@envs.net (lucidiot)</managingEditor>
|
|
|
|
<webMaster>lucidiot@envs.net (lucidiot)</webMaster>
|
|
|
|
<generator>/bin/bash</generator>
|
|
|
|
<docs>https://www.rssboard.org/rss-specification</docs>
|
|
|
|
<admin:errorReportsTo rdf:resource="mailto:lucidiot@envs.net" />
|
|
|
|
<admin:generatorAgent rdf:resource="https://tildegit.org/lucidiot/wiki/" />
|
|
|
|
<atom:link rel="self" type="application/rss+xml" href="https://envs.net/~lucidiot/rss.xml" />
|
|
|
|
' > html/rss.xml
|
|
|
|
|
|
|
|
for file in content/**/*.md; do
|
2021-03-24 08:23:11 +00:00
|
|
|
link="${file##content/}"
|
2021-03-23 22:37:00 +00:00
|
|
|
link="https://envs.net/~lucidiot/${link/%.md/.html}"
|
|
|
|
echo '<item>
|
2021-03-24 08:23:11 +00:00
|
|
|
<title>'"$(sed -n 's|\s*title:\s*\(.*\)$|\1|p' "$file")"'</title>
|
2021-03-23 22:37:00 +00:00
|
|
|
<pubDate>'"$(date -Rd "@$(stat -c%Y "$file")")"'</pubDate>
|
|
|
|
<link>'"$link"'</link>
|
|
|
|
<guid>'"$link"'</guid>
|
|
|
|
</item>' >> html/rss.xml
|
|
|
|
done
|
|
|
|
echo ' </channel>
|
|
|
|
</rss>' >> html/rss.xml
|
|
|
|
chmod 644 html/rss.xml
|