arcnyxx.net.git
elk.sh
#!/bin/sh
# elk - html packer and compile script
# Copyright (C) 2024 ArcNyxx <me@arcnyxx.net>
# see LICENCE file for licensing information
# minify css and js
cat *.css | tr -d '\n\t' | sed 's/ *{/{/g;s/: */:/g;s/, */,/g;s/%/%%/g' >all.css
echo >>all.css
uglifyjs *.js -c -m | sed 's/%/%%/g' >all.js
# pack html head and foot
cat all.css all.js - >head.html <<EOF
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='utf-8'>
<meta name='viewport' content='width=device-width'>
<meta name='description' content='%s'>
<style>
</style>
<link rel='stylesheet' href='https://fonts.googleapis.com/css2?family=Fredoka:wght@300..700&display=swap'>
<link rel='stylesheet' href='https://fonts.googleapis.com/css2?family=Courier+Prime&display=swap'>
<link rel='icon' href='https://arcnyxx.net/espurr.webp'>
<script src='https://code.jquery.com/jquery-3.7.1.min.js'></script>
<script>
</script>
<title>%s</title>
</head>
<body>
<script>0</script>
<nav>
<a href='https://arcnyxx.net'>home</a>
<a href='https://blog.arcnyxx.net'>blog</a>
<a href='https://git.arcnyxx.net'>code</a>
</nav>
<main>
<header>
<div>
<h1>%s</h1>
<p>%s</p>
%s</div>
<img style='aspect-ratio: 1 / 1;' src='https://arcnyxx.net/espurr.webp' alt='espurr'>
</header>
<section>
EOF
# move concatenated portions to proper section, merge lines
echo '1m9\n1m15\n7,9j\n12,14j\nw' | ed "head.html"
cat >foot.html <<EOF
</section>
</main>
<footer>
<a href='https://arcnyxx.net'>arcnyxx DOT net</a>
<a href='mailto:me@arcnyxx.net'>me AT arcnyxx DOT net</a>
</footer>
</body>
</html>
EOF
# make must include generated head.html and foot.html
make
mkdir -p site
cp stoat site
# generate blog.txt metadata
cat >blog.txt <<EOF
blog dot arcnyxx dot net >;3
rants & %{excited sharing of information about a focused subject or passion in great detail & at length, typically by a neurodivergent person}{infodumps} about anything i've worked on
my blog
EOF
# generate blog.txt article list
ls *.txt | grep -vE '(index.txt|blog.txt)' | while read -r FILE ; do
# sed commands gets title and strips any links or title spans
printf ' $%s|%s|%s|%s\n' "https://blog.arcnyxx.net/${FILE%%.*}" \
"`sed '4q;d' <"$FILE"`" \
"`sed 's|[%@]{.*}{\(.*\)}|\1|g;q' <"$FILE"`" \
"`./snail "\`sed '2q;d' <"$FILE"\`"`"
done >>blog.txt
# compile markdown and latex
# output to site directory
# extra backslashes needed for printf
sed -i 's/\\/\\\\/g' head.html
for FILE in *.txt ; do
./snail.sh <"$FILE" >"site/${FILE%%.*}.html"
done
for FILE in *.tex ; do
pdflatex "$FILE"
rm -f "${FILE%%.*}.aux" "${FILE%%.*}.log"
mv "${FILE%%.*}.pdf" site
done
make clean
cp *.webp *.mp4 *.svg site
rm -f all.css all.js head.html foot.html blog.txt