blood.pet/plugins/logroll.sh
noe 78ecc94d58
All checks were successful
ci/woodpecker/push/build-deploy Pipeline was successful
logroll updates
2025-05-16 21:52:45 -07:00

49 lines
No EOL
905 B
Bash
Executable file

#!/bin/bash
cd log
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_author() {
code=$(echo $1 | sed -E 's/.*\^(.*)$/\1/g')
echo $code
}
echo "<ul>"
files=$(ls ???-*.doll)
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")
echo "<li>"
echo "<a href=\"$link\">$dollcode <b>$heading_name</b></a></br>&nbsp;&nbsp;<i>$description</i>"
echo "</li>"
done
echo "</ul>"