strip wiki pages from .html if on ~cafe's system path

This commit is contained in:
jan6 2021-11-12 02:57:58 +02:00
parent 31ad177337
commit 025d0459e9
1 changed files with 18 additions and 0 deletions

View File

@ -4,6 +4,16 @@
dir="$(echo "$0"|sed 's|/[^/]\+$||')"
if [ -d "$dir" ];then cd "$dir";fi
# no_ext removes the trailing .html,
# useful to tidy the URL, if you've set up your server to work with that in mind
#server-specific checks to enable stripping suffixes ONLY on system html path, on tilde.cafe
if [ "$(hostname --fqdn)" = "tilde.cafe" ] && [ "$(readlink -f "$dir"|head -c 4)" = "/var" ];then
no_ext=1
else
no_ext=0
fi
TZ=UTC date
echo "updating repo"
@ -39,6 +49,10 @@ for path in . ./wiki;do
echo "building dist/$dir/$filename.html";
mkdir -p "dist/$dir/" && touch "dist/$dir/$filename.html";
markdown "src/$dir/$filename.md" |
if [ "$no_ext" = "1" ];then
sed -e 's|\(<a href="https://tilde.cafe/wiki/[^/]\+\).html">|\1">|g'\
-e 's|\(<a href="[^/]\+\).html">|\1">|g'
fi |
cat inc/header.html - inc/footer.html >"dist/$dir/$filename.html"
# ' \;
done
@ -56,6 +70,10 @@ echo "creating index page.."
echo "creating index page for wiki..."
markdown "$tmpindex" |
if [ "$no_ext" = "1" ];then
sed -e 's|\(<a href="https://tilde.cafe/wiki/[^/]\+\).html">|\1">|g'\
-e 's|\(<a href="[^/]\+\).html">|\1">|g'
fi |
cat inc/header.html - inc/footer.html > dist/wiki/index.html
rm "$tmpindex"