87 lines
No EOL
1.6 KiB
Bash
Executable file
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 & #6";;
|
|
a) names="$names & aki";;
|
|
au) names="$names & aurelia";;
|
|
e) names="$names & erisa";;
|
|
f) names="$names & fusa";;
|
|
j) names="$names & junko";;
|
|
n) names="$names & noe";;
|
|
r0) names="$names & ring-0";;
|
|
s) names="$names & sayaka";;
|
|
esac
|
|
|
|
done
|
|
IFS=$oifs
|
|
|
|
# strip the loading " & "
|
|
names=$(echo "$names" | sed -E 's/^ & //')
|
|
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/> "
|
|
echo "<i>$description</i>"
|
|
echo "</li>"
|
|
done
|
|
|
|
echo "</ul>"
|
|
|
|
echo '
|
|
<style>
|
|
li {
|
|
margin-bottom: 1.6rem;
|
|
}
|
|
</style>
|
|
' |