53 lines
1.3 KiB
Bash
53 lines
1.3 KiB
Bash
# processes the html and stuff into the serve folder
|
|
|
|
find . | grep '[$]' && exit 1 # prevent XSS
|
|
|
|
process() {
|
|
# this can modify the contents of each html file,
|
|
# e.g. by adding a sed command. the file is piped
|
|
# through this function.
|
|
cat \
|
|
| sed -E 's/<<<(.*)>>>/<br><\1><br>/g' \
|
|
| sed -E 's/(<a.*\/a>)/💖 \1 💖/g' \
|
|
| sed -E 's/israels-prime-minister-benjamin-netanyahu//g' \
|
|
| cat
|
|
}
|
|
|
|
process-md() {
|
|
cat \
|
|
| sed -E 's/\n\n/<br><br>/g' \
|
|
| sed -E 's/\\\n/<br>/g' \
|
|
| sed -E 's/^# (.*)/<h1>\1<\/h1>/g' \
|
|
| sed -E 's/^## (.*)/<h2>\1<\/h2>/g' \
|
|
| sed -E 's/^### (.*)/<h3>\1<\/h3>/g' \
|
|
| sed -E 's/^#### (.*)/<h4>\1<\/h4>/g' \
|
|
| sed -E 's/\*\*(.*?)\*\*/<b>\1<\/b>/g' \
|
|
| sed -E 's/\*(.*?)\*/<i>\1<\/i>/g' \
|
|
| sed -E 's/\[(.*?)\]\(([^)]*?)\)/<a href="\2">\1<\/a>/g' \
|
|
| cat
|
|
}
|
|
|
|
# delete everything on the site rn
|
|
mkdir serve || rm -rf serve/*
|
|
|
|
# transfer directories
|
|
for file in $(find . -type d -not -path '*/.*') ; do
|
|
mkdir serve/"$file"
|
|
done
|
|
|
|
# transfer html
|
|
for file in $(find . | grep .html) ; do
|
|
cat header.html "$file" | process > serve/"$file"
|
|
done
|
|
|
|
# transfer md
|
|
for file in $(find . | grep .md) ; do
|
|
(cat header.html; cat "$file" | process-md) | process > serve/"$file".html
|
|
done
|
|
|
|
# transfer fonts
|
|
for file in $(find . | grep .ttf) ; do
|
|
cp "$file" serve/"$file"
|
|
done
|
|
|
|
echo "hello" > serve/test.html
|