blood.pet/plugins/logroll.sh
noe e705644997
All checks were successful
ci/woodpecker/push/build-deploy Pipeline was successful
logroll updates
2025-05-16 22:11:56 -07:00

87 lines
No EOL
1.6 KiB
Bash
Executable file

#!/bin/bash
cd $1
get_frontmatter() {
key=$1
file=$2
keyLine=$(grep -e "^$key: " $file || echo "")
sed "s/.*: //" <<<$keyLine | xargs
}
get_heading() {
file=$1
grep -i '^&' $file
}
get_heading_date() {
echo $1 | sed -E 's/^.*\(([A-Z0-9]+)\) \^.*$/\1/g'
}
get_heading_name() {
echo $1 | sed -E 's/^.*\] (.*) \(.*$/\1/g'
}
get_serial() {
echo $1 | sed -E 's/([0-9]+)-.*/\1/'
}
get_author() {
code=$(echo $1 | sed -E 's/.*\^(.*)$/\1/g')
names=""
oifs=$IFS
IFS="+"
for tag in $code; do
case $tag in
6) names="$names &amp; #6";;
a) names="$names &amp; aki";;
au) names="$names &amp; aurelia";;
e) names="$names &amp; erisa";;
f) names="$names &amp; fusa";;
j) names="$names &amp; junko";;
n) names="$names &amp; noe";;
r0) names="$names &amp; ring-0";;
s) names="$names &amp; sayaka";;
esac
done
IFS=$oifs
# strip the loading " &amp; "
names=$(echo "$names" | sed -E 's/^ &amp; //')
echo $names
}
echo "<ul>"
files=$(ls ???-*.doll | tac)
for file in $files; do
title=$(get_frontmatter title $file)
description=$(get_frontmatter description $file)
link=${file//.doll/.html}
heading=$(get_heading $file)
heading_name=$(get_heading_name "$heading")
heading_date=$(get_heading_date "$heading")
author=$(get_author "$heading")
serial=$(get_serial $file)
echo "<li>"
echo "<a href=\"$link\">[$serial] <b>$heading_name</b></a>"
echo "by $author ($heading_date)"
echo "<br/>&nbsp;&nbsp;"
echo "<i>$description</i>"
echo "</li>"
done
echo "</ul>"
echo '
<style>
li {
margin-bottom: 1.6rem;
}
</style>
'