From c14aabfd17c85632bd68db60867edb3fb662c7e7 Mon Sep 17 00:00:00 2001 From: Johannes Herman Date: Thu, 11 Dec 2025 06:49:19 +0100 Subject: initial commit --- bin/make_html_table.sh | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100755 bin/make_html_table.sh (limited to 'bin/make_html_table.sh') diff --git a/bin/make_html_table.sh b/bin/make_html_table.sh new file mode 100755 index 0000000..c820f27 --- /dev/null +++ b/bin/make_html_table.sh @@ -0,0 +1,89 @@ +#!/bin/bash + +CSV_FILE="${1:-tricks.csv}" + +make_video_cell() { + local field="$1" + if [[ -n "$field" ]]; then + echo " " + IFS=';' read -ra files <<< "$field" + for f in "${files[@]}"; do + f_trimmed=$(echo "$f" | xargs) + echo " " + done + echo " " + else + echo " " + fi +} + +make_demo_cell() { + local field="$1" + if [[ -n "$field" ]]; then + echo " " + IFS=';' read -ra files <<< "$field" + for f in "${files[@]}"; do + f_trimmed=$(echo "$f" | xargs) + echo " demo
" + done + echo " " + else + echo " " + fi +} + +make_montage_cell() { + local montage="$1" + + if [ -z "$montage" ]; then + echo " " + return + fi + + case "$montage" in + 'Cowboy Teebop') montage_url='https://www.youtube.com/watch?v=eJgiPbio9BY' ;; + 'Tee Jams') montage_url='https://www.youtube.com/watch?v=ReoM0rVXduQ' ;; + 'On Noby Street') montage_url='https://www.youtube.com/watch?v=lxVu5XX9Rmk' ;; + 'Any Trickers') montage_url='https://www.youtube.com/watch?v=u2CbuvmiXCc' ;; + *) echo "ERROR: invalid montage name '$montage'" >&2; exit 1 ;; + esac + echo " $montage" +} + +cat <<'EOF' + + +EOF + +IFS=',' read -r -a headers < "$CSV_FILE" + +for header in "${headers[@]}"; do + echo " " +done + +echo " " + +while IFS=',' read -r name players train_videos ingame_videos demos montage; do + [[ -z "$name" ]] && continue + + echo " " + echo " " + + players_html=$(echo "$players" | sed 's/;/,
/g') + echo " " + + make_video_cell "$train_videos" + make_video_cell "$ingame_videos" + make_demo_cell "$demos" + make_montage_cell "$montage" + + echo " " +done < <(tail -n +2 "$CSV_FILE") + +cat <<'EOF' +
$header
$name$players_html
+EOF + -- cgit v1.2.3