cyberia.club
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

82 lines
3.9 KiB

#!/bin/sh -e
#
# Simple static site builder.
cat <<EOF > /tmp/meow
<!doctype html>
<html lang=en>
<link href='data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAQAABILAAASCwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA2Mt5V9jLebrYy3no2Mt5/9jLef/Yy3no2Mt5utjLeVcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAoIwAwKCMAfSgjAIwoIwCMKCMAjCgjAIwoIwCMKCMAjCgjAIwoIwCMKCMAfSgjADAAAAAAAAAAAAAAAADYy3lX2Mt569jLef/Yy3n/2Mt5/9jLef/Yy3n/2Mt5/9jLef/Yy3n/2Mt5/9jLef/Yy3nr2Mt5VwAAAAAAAAAAKCMAfSgjAIwoIwCMKCMAjCgjAIwoIwCMKCMAjCgjAIwoIwCMKCMAjCgjAIwoIwCMKCMAjCgjAH0AAAAAy6yMQNjLeffYy3n/2Mt5/9jLef/Yy3n/2Mt5/9jLef/Yy3n/2Mt5/9jLef/Yy3n/2Mt5/9jLef/Yy3n/2Mt5V7d8qbrAkpz42Mp5/tjLef/Yy3n/2Mt5/9jLef/Yy3n/2Mt5/9jLef/Yy3n/2Mt5/9jLef/Yy3n/2Mt5/8mnj8K3fKnot3yp/8mmj//Yy3n/2Mt5/9jLef/Yy3n/2Mt5/9jLef/Yy3n/2Mt5/9jLef/Yy3n/2Mt5/9C3hf+4fqjot3yp/7d8qf+8iaH/2Mt5/9jLef/Yy3n/2Mt5/9jKev/Yy3n/2Mt5/9jLef/Yy3n/2Mt5/9TCf/+4f6f/t3yp/7d8qf+3fKn/t3yp/9bFff/Yy3n/2Mt5/8qpjv+4fqj/xJuW/9jLef/Yy3n/2Mt5/9jLef/Bk5v/t3yp/7d8qf+3fKnot3yp/7d8qf/Mr4r/2Mt5/9C5hP+3fKn/t3yp/7d8qf/SvIL/2Mt5/9jLef/Ru4P/t3yp/7d8qf+3fKnot3ypurd8qf+3fKn/u4Wk/8imkP+6hKT/t3yp/7d8qf+3fKn/vYug/9bGfP/Yy3n/wpaZ/7d8qf+3fKn/t3ypurd8qVe3fKn/t3yp/7d8qf+3fKn/t3yp/7d8qf+3fKn/t3yp/7d8qf+7haT/wJCd/7d8qf+3fKn/t3yp/7d8qVcAAAAAt3yp47d8qf+3fKn/t3yp/7d8qf+3fKn/t3yp/7d8qf+3fKn/t3yp/7d8qf+3fKn/t3yp/7d8qeMAAAAAAAAAALd8qVe3fKnrt3yp/7d8qf+3fKn/t3yp/7d8qf+3fKn/t3yp/7d8qf+3fKn/t3yp/7d8qeu3fKlXAAAAAAAAAAAAAAAAt3ypV7d8qeO3fKn/t3yp/7d8qf+3fKn/t3yp/7d8qf+3fKn/t3yp/7d8qeO3fKlXAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAt3ypV7d8qbq3fKnot3yp/7d8qf+3fKnot3ypurd8qVcAAAAAAAAAAAAAAAAAAAAA8A8AAMADAACAAQAAgAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAEAAIABAADAAwAA8A8AAA==' rel=icon>
<title>Cyberia Computer Club</title>
<meta charset=utf-8>
<meta name=viewport content="width=device-width,initial-scale=1.0">
<meta name=Description content="Cyberia Computer Club">
<style>
%%CAPSUL_CSS%%
</style>
<pre>
<a href=/><b>Cyberia</b></a> <a href=/culture>Culture</a> <a href=/blog>Blog</a> <a href=/calendar>Calendar</a> <a href=/donate>Donate</a> <a href=/matrix>Matrix (Chat)</a> <a href=/mumble>Mumble</a>
<a href="https://capsul.org">Capsul -&gt;</a> &nbsp; <a href="https://nullhex.com">Nullhex -&gt;</a> &nbsp; <a href="https://git.cyberia.club">Git -&gt;</a> &nbsp; <a href="https://wiki.cyberia.club">Wiki -&gt;</a> &nbsp; <a href="https://stream.cyberia.club">Stream -&gt;</a>
<pre>
%%CONTENT%%
(c) Attribution-ShareAlike 4.0 International
Cyberia Computer Club 2020-∞
<a href="%%SOURCE%%">View page source</a>
</pre></pre>
EOF
rm -f build/*.txt build/*.html
mkdir -p build
cd build
# Iterate over each file in the source tree under /site/.
(cd ../si*; find . -type f -a -not -path ./templates/\*) |
while read -r page; do
mkdir -p "${page%/*}"
case $page in
*.txt)
sed -E "s|([^=][^\'\"])(https[:]//[^ )]*)|\1<a href='\2'>\2</a>|g" \
"../site/$page" |
# link https
sed -E "s|^(https[:]//[^ )]{32})([^ )]{3,1000})([^ )]{15})|<a href='\0'>\1...\3</a>|g" |
sed -E "s|^(https[:]//[^ )]{1,50})|<a href='\0'>\0</a>|g" |
# link mailto
sed -E "s|mailto:([^ ]*)|<a href='mailto:\1'>\1</a>|g" |
# color hexcodes
sed -E 's|(#[a-f0-9]{6})|<font color="\1">\1</font>|g' |
# color cyberia
sed -E 's@(Cyberia('"'"'s)?n?)([^A-Za-z0-9_/-])@<font color="#b294bb">\1</font>\3@g' |
sed -E 's|CYBERIA|<font color="#b294bb">CYBERIA</font>|g' |
sed '/%%CONTENT%%/r /dev/stdin' /tmp/meow |
sed '/%%CONTENT%%/d' |
sed "s|%%CAPSUL_CSS%%|$(cat ../cyberia.css | tr '\n' ' ')|g" |
sed "s %%SOURCE%% /${page##./} " \
> "${page%%.txt}.html"
ln -f "../site/$page" "$page"
printf '%s\n' "CC $page"
;;
# Copy over any images or non-txt files.
*)
cp "../site/$page" "$page"
printf '%s\n' "CP $page"
;;
esac
done