alexkarle.com

Source for alexkarle.com
git clone git://git.alexkarle.com/alexkarle.com.git
Log | Files | Refs | README | LICENSE

commit 1557dabea23a31b9693af4e8f437165c11d8d657 (patch)
parent fe31bedcd341666bc700a066e35067fc947b2a6c
Author: Alex Karle <alex@alexkarle.com>
Date:   Mon,  7 Jun 2021 00:18:24 -0400

jam-tuesday: Replace all-songs listing with by-artist table

I'm really happy with how this turned out, much more readable than
the all-songs-alphabetical view from before!

Diffstat:
Mbin/jam-index.sh | 28++++++++++++++++++++++------
Mstyle.css | 7+++++++
2 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/bin/jam-index.sh b/bin/jam-index.sh @@ -3,6 +3,12 @@ set -e REPO=$(dirname "$(dirname "$0")") DIR="$REPO/jam-tuesday" +# Prep for the by artist listing +ALL=$(mktemp) +for f in "$DIR"/[01][0-9]-*; do + sed '1,/---/d' $f | grep -v '^ *$' | sed 's/ *([^)]*) *//g' +done | sort -f > "$ALL" + cat <<EOM <html lang="en"> <head> @@ -54,15 +60,25 @@ done cat <<EOM </ul> -<h2>All Songs, Alphabetical</h2> +<h2>All Songs, by Artist</h2> <hr> -<ul> +<table class="jam-artists"> +<tr><th>Artist</th><th>Song</th><th>Plays</th></tr> EOM -for f in "$DIR"/[01][0-9]-*; do - sed '1,/---/d' $f | grep -v '^ *$' | sed 's/ *([^)]*) *//g' -done | sort -f | uniq -i -c | sed 's/ *\([0-9]*\) *\(.*\)/<li>\2 (\1)<\/li>/' +sed 's/.*, *//' "$ALL" | sort -u -f | while read artist; do + first="" + grep ", *$artist\$" "$ALL" | sort -f | sed "s#, *$artist *##" | uniq -c -i | \ + while read plays song; do + if [ -z "$first" ]; then + first=1 + echo "<tr><td>$artist</td><td>$song</td><td>$plays</td></tr>" + else + echo "<tr><td></td><td>$song</td><td>$plays</td></tr>" + fi + done +done cat <<EOM -</ul> +</table> <br><br> <p style="font-size: 0.7em">Last Updated: $(date)</p> <p class="foot-license"> diff --git a/style.css b/style.css @@ -71,3 +71,10 @@ td.head-rtitle, td.foot-os { text-align: right; } code.Nm, .Fl, .Cm, .Ic, code.In, .Fd, .Fn, .Cd { font-weight: bold; } + +.jam-artists tr:nth-child(even) { + background-color: #e3e3e3; +} +td.jam-artists, th.jam-artists, table.jam-artists { + border: 1px solid black; +}