diff --git a/inc/gen-author.sh b/inc/gen-author.sh index b7541df41..66ea3ddd3 100755 --- a/inc/gen-author.sh +++ b/inc/gen-author.sh @@ -9,7 +9,7 @@ # the final arg will be in yyyy/dir form, and will be called from # the topdir directory under which the yyyy/dir winner directory must be found. # -# Copyright (c) 2023 by Landon Curt Noll. All Rights Reserved. +# Copyright (c) 2023,2024 by Landon Curt Noll. All Rights Reserved. # # Permission to use, copy, modify, and distribute this software and # its documentation for any purpose and without fee is hereby granted, @@ -56,7 +56,7 @@ shopt -s globstar # enable ** to match all files and zero or more directories an # set variables referenced in the usage message # -export VERSION="1.0 2023-12-31" +export VERSION="1.1 2024-01-01" NAME=$(basename "$0") export NAME export V_FLAG=0 @@ -316,7 +316,7 @@ function output_location_code # extract Location Code from the author/author_handle.json file # - grep -F location_code "$AUTHOR_HANDLE_JSON_PATH" | sed -e 's/.*"location_code" : "//' -e 's/",.*//' + grep -F location_code "$AUTHOR_HANDLE_JSON_PATH" | sed -e 's/.*"location_code" : "*//' -e 's/"*,.*//' return 0 } @@ -536,6 +536,7 @@ fi # parameter debugging # if [[ $V_FLAG -ge 3 ]]; then + echo "$0: debug[3]: NAME=$NAME" 1>&2 echo "$0: debug[3]: YEAR_DIR=$YEAR_DIR" 1>&2 echo "$0: debug[3]: WINNER_DIR=$WINNER_DIR" 1>&2 echo "$0: debug[3]: WINNER_ID=$WINNER_ID" 1>&2 @@ -663,14 +664,21 @@ fi # write author header to temporary markdown file # -if [[ -z $NOOP ]]; then - { - echo '# author' - echo - } >> "$TMP_FILE" +{ + echo "" + AUTHOR_COUNT=$(echo "$AUTHOR_HANDLE_SET" | wc -l) + if [[ $AUTHOR_COUNT -gt 1 ]]; then + echo '**Authors:**' + else + echo '**Author:**' + fi + echo +} | if [[ -z $NOOP ]]; then + cat >> "$TMP_FILE" elif [[ $V_FLAG -ge 3 ]]; then - echo "$0: debug[3]: -n disabled write: # author" 1>&2 - echo "$0: debug[3]: -n disabled write:" 1>&2 + sed -e "s;^;$0: debug[3]: -n disabled write: ;" 1>&2 +else + cat >> /dev/null fi # write each author's information to temporary markdown file @@ -701,24 +709,40 @@ for author_handle in $AUTHOR_HANDLE_SET; do # write this author's information # - if [[ -z $NOOP ]]; then - { - echo "[$FULL_NAME](/winners.html#$author_handle)" + { + echo "Name: [$FULL_NAME](/winners.html#$author_handle)
" + if [[ $LOCATION_CODE == null ]]; then + echo "Location: [unknown](/location.html#$LOCATION_CODE)" + else echo "Location: [$LOCATION_CODE](/location.html#$LOCATION_CODE)" - echo - } >> "$TMP_FILE" + fi + echo + } | if [[ -z $NOOP ]]; then + cat >> "$TMP_FILE" elif [[ $V_FLAG -ge 3 ]]; then - echo "$0: debug[3]: -n disabled write: [$FULL_NAME](/winners.html#$author_handle)" 1>&2 - echo "$0: debug[3]: -n disabled write: Location: [$LOCATION_CODE](/location.html#$LOCATION_CODE)" 1>&2 - echo "$0: debug[3]: -n disabled write:" 1>&2 + sed -e "s;^;$0: debug[3]: -n disabled write: ;" 1>&2 + else + cat >> /dev/null fi done +# write END line +# +{ + echo "" +} | if [[ -z $NOOP ]]; then + cat >> "$TMP_FILE" +elif [[ $V_FLAG -ge 3 ]]; then + sed -e "s;^;$0: debug[3]: -n disabled write: ;" 1>&2 +else + cat >> /dev/null +fi + # convert temporary markdown file into HTML # if [[ -z $NOOP ]]; then if [[ $V_FLAG -ge 1 ]]; then - echo "$0: debug[1]: about to execute: $PANDOC_WRAPPER -P $PANDOC_WRAPPER_OPTSTR $TMP_FILE -" 1>&2 + echo "$0: debug[1]: about to execute: $PANDOC_WRAPPER -P \"$PANDOC_WRAPPER_OPTSTR\" $TMP_FILE -" 1>&2 fi "$PANDOC_WRAPPER" -P "$PANDOC_WRAPPER_OPTSTR" "$TMP_FILE" - status="$?" @@ -727,7 +751,7 @@ if [[ -z $NOOP ]]; then exit 118 fi elif [[ $V_FLAG -ge 1 ]]; then - echo "$0: debug[1]: -n disabled execution of: $PANDOC_WRAPPER -P $PANDOC_WRAPPER_OPTSTR $TMP_FILE -" 1>&2 + echo "$0: debug[1]: -n disabled execution of: $PANDOC_WRAPPER -P \"$PANDOC_WRAPPER_OPTSTR\" $TMP_FILE -" 1>&2 fi # All Done!!! -- Jessica Noll, Age 2