2023-10-03 20:03:53 +02:00
|
|
|
#!/usr/bin/env bash
|
2023-10-03 19:03:44 +02:00
|
|
|
cp html_resources/index_template.html index.html
|
|
|
|
|
|
|
|
function genlinks {
|
2023-12-06 18:11:28 +01:00
|
|
|
for FILE in $(find . -maxdepth 1 -type f -name "??-*.html" | sort); do
|
2024-01-31 20:38:40 +01:00
|
|
|
echo "$FILE" >&2
|
2023-10-03 19:03:44 +02:00
|
|
|
echo -ne " <li><a href=\"$FILE\">\n"
|
2023-12-06 18:59:46 +01:00
|
|
|
echo -n " $(sed -e 's|^\./||;s/-.*//' <<< "$FILE") <span class="'"chapter">'
|
2023-12-06 18:11:28 +01:00
|
|
|
grep -oe "<title>.*</title>" $FILE | sed -e 's/<title> //;s| </title>|</span>|'
|
2023-10-03 19:03:44 +02:00
|
|
|
echo " </a></li>"
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
sed -ne '/ <!-- chapter_list_here -->/q;p' html_resources/index_template.html > index.html
|
|
|
|
# for some fucking reason, there is no way to tell wc to only print the number so we do cat abuse to get rid of the filename
|
|
|
|
LINE_NUMBER=$(("$(cat index.html | wc -l)"+2))
|
|
|
|
genlinks >> index.html
|
|
|
|
tail -n+$LINE_NUMBER html_resources/index_template.html >> index.html
|