From 80f5dacf988b1cddd04eea6c4a6f70b165376764 Mon Sep 17 00:00:00 2001 From: Steph Enders Date: Thu, 29 Feb 2024 10:40:02 -0500 Subject: Generate index files and fix page generation in build script The previous commit had a partial implementation of this so the build script wouldn't work! --- .gitignore | 3 +- build.sh | 126 ++++++++++++++++++++++++++++++++++++++----------------------- 2 files changed, 81 insertions(+), 48 deletions(-) diff --git a/.gitignore b/.gitignore index 6bada03..dfb90e6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *.sw* *.md.backup -www \ No newline at end of file +www +.build \ No newline at end of file diff --git a/build.sh b/build.sh index 3a2cd6b..20d232b 100755 --- a/build.sh +++ b/build.sh @@ -5,7 +5,6 @@ BUILD=.build/ function extract_metadata() { name=$1 file=$2 - # val=$(grep -oE "^--${name}: .+$" $file | sed -E "s/^--${name}: (.+)$/\1/") val=$(sed -nE "/^--${name}: .+$/s/^--${name}: (.+)$/\1/p" $file) if [ -z "$val" ]; then echo "" @@ -16,19 +15,76 @@ function extract_metadata() { fi } +function mktemp_file() { + name=$1 + var=$(mktemp -p $BUILD "${name}_XXXXXX") + echo "${var}" + return 0 +} + function generate_index() { base_dir=$1 - index_tmp=$(mktemp -p $BUILD "index_${base_dir}_XXXXXX.html") - echo "" >> $index_tmp - page_tmp=$(mktemp -p $BUILD "index_page_XXXXXX.html") - cat _templates/page.html > $page_tmp + echo "Generating index for $base_dir" + page_file=$(mktemp_file "index_page") + content_file=$(mktemp_file "index_content") + title=$(basename ${base_dir}) + echo "
+

${title} index

+ +
" >> $content_file + sed -i "s,${base_dir},.,g" $content_file + + generate_page "index" $content_file $page_file + + # strip out the footer + sed -i '1,/<\/footer>/{/