From fa7faab48f381f517d7cd1b268a7b9fbf3856860 Mon Sep 17 00:00:00 2001 From: Michael Czechowski Date: Tue, 30 Dec 2025 11:30:29 +0100 Subject: [PATCH] add index.html generator script generates styled course overview with pdf links and qr codes --- scripts/generate-index.sh | 161 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 161 insertions(+) create mode 100755 scripts/generate-index.sh diff --git a/scripts/generate-index.sh b/scripts/generate-index.sh new file mode 100755 index 0000000..5d02d36 --- /dev/null +++ b/scripts/generate-index.sh @@ -0,0 +1,161 @@ +#!/usr/bin/env bash +# Generate index.html for slide overview +# Usage: ./generate-index.sh + +COURSE="${1:-223015b}" +BUILD_DIR="${2:-build/$COURSE}" + +# Course-specific configuration +case "$COURSE" in + 223015b) + TITLE="223015b - Dateiformate, Schnittstellen, Speichermedien" + SUBTITLE="Dateiformate, Schnittstellen, Speichermedien & Distributionswege" + REPO_URL="https://git.librete.ch/hdm/223015b" + ;; + 223015c) + TITLE="223015c - Internettechnologien" + SUBTITLE="Internettechnologien" + REPO_URL="https://git.librete.ch/hdm/223015c" + ;; + *) + TITLE="$COURSE - HdM Slides" + SUBTITLE="Lecture Slides" + REPO_URL="https://git.librete.ch/hdm/$COURSE" + ;; +esac + +cat > "$BUILD_DIR/index.html" << HEADER + + + + + + $TITLE + + + +

$COURSE

+

$SUBTITLE
+ HdM Stuttgart - WS 2025/26 - Michael Czechowski

+HEADER + +# Generate links for each termin (sorted) +for html in $(ls "$BUILD_DIR"/2*.html 2>/dev/null | sort); do + filename=$(basename "$html") + + # Extract components from filename + date=$(echo "$filename" | grep -oE '^[0-9]{4}-[0-9]{2}-[0-9]{2}') + termin_num=$(echo "$filename" | grep -oE 'termin-[0-9]+' | grep -oE '[0-9]+') + topic_raw=$(echo "$filename" | sed -E 's/^[0-9]{4}-[0-9]{2}-[0-9]{2}-termin-[0-9]+-//' | sed 's/\.html$//') + + # Format topic: replace - with space, capitalize + topic=$(echo "$topic_raw" | sed 's/-/ /g' | sed 's/.*/\u&/') + + # Format date + if [[ "$date" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then + formatted_date=$(date -d "$date" "+%d.%m.%Y" 2>/dev/null || echo "$date") + else + formatted_date="TBA" + fi + + # Handle termin number + if [[ "$termin_num" == "0" ]]; then + termin_label="Einfuhrung" + else + termin_label="Termin $termin_num" + fi + + pdf_filename="${filename%.html}.pdf" + + # Check if PDF exists + pdf_link="" + if [[ -f "$BUILD_DIR/$pdf_filename" ]]; then + pdf_link="PDF" + fi + + cat >> "$BUILD_DIR/index.html" << LINK + +LINK +done + +# Add QR code if exists +if [[ -f "$BUILD_DIR/qr-$COURSE.png" ]]; then + cat >> "$BUILD_DIR/index.html" << QRSECTION +
+ QR Code +

Scan to open on mobile

+
+QRSECTION +fi + +cat >> "$BUILD_DIR/index.html" << FOOTER + + + +FOOTER + +echo "Generated $BUILD_DIR/index.html"