sitoctt/Scripts/Redirects.sh

53 lines
1.2 KiB
Bash
Raw Normal View History

2024-08-25 17:18:20 +02:00
#!/bin/sh
. "$(dirname "$(realpath "$0")")/Lib/Globals.sh"
cd "${swd}/.."
2024-08-27 01:06:25 +02:00
# TODO handle new capitalization of folders
# TODO handle un-nested pages
# TODO handle 0000- posts
# TODO handle miscellanea
# FUTURE: old yyyy-mm-dd to new yyyy/mm/dd
#cd ./build/public/it
#find . -type f -name index.html -exec sh -c '
#set -e
#cp "{}" "../it.tmp/{}"
#'
#cd ../../..
#cd ./build/public
#cp -r ./it ./it.tmp
#cd ./it.tmp
2024-08-25 17:18:20 +02:00
cd ./build/public
find . -type f -name index.html -exec sh -c '
2024-08-27 01:06:25 +02:00
set -e
2024-08-25 17:18:20 +02:00
nicepath="$(echo "{}" | rev | cut -d/ -f2- | rev)"
2024-08-27 01:06:25 +02:00
nicename="$(echo "${nicepath}" | rev | cut -d/ -f1 | rev)"
#extrapaths=""
#for replace in \
# "note Posts/Notes/Linux" \
# "note Posts/Notes" \
# "post Posts" \
#; do
# set $replace
# newpath="$(echo "{}" | sed -e "s|/$2/|/$1/|")"
# if [ "${newpath}" != "{}" ]
# then extrapaths="${extrapaths} ${newpath}"
# fi
#done
for path in "${nicepath}" #${extrapaths}
do sed -e "s|{URL}|./${nicename}/|g" ../../redirectTemplate.html > "${path}.html"
done
#if [ "$(echo "{}" | cut -d/ -f2)" = it ]
#then
# destpath="$(echo "${nicepath}" | cut -d/ -f3-).html"
# mkdir -p "${destpath}"
# rm -rf "${destpath}"
# sed -e "s|{URL}|/$(echo "${nicepath}" | cut -d/ -f2-)/|g" ../../redirectTemplate.html > "${destpath}"
#fi
2024-08-25 17:18:20 +02:00
' \;
2024-08-27 01:06:25 +02:00
#cd ../..
2024-08-25 17:18:20 +02:00
cd "${owd}"