add title and abstract to .entry.json and index.html files

We add an initial "_title_" and "_abstract_" to all entry `.entry.json` files.

The `bin/csv2entry.sh` tool reads the `summary.csv` file and
loads the "_title_" and "_abstract_" to entry `.entry.json` files.

Changed `bin/csv2entry.sh` VERSION from "1.3 2024-09-23"
to "1.4 2024-09-27".

Perform `make csv2entry` to perform the above and test under macOS.

The `bin/cvt-submission.sh` tool adds "_title_" and "_abstract_" to the
.entry.json based on the `.info.json` file.

Changed `bin/cvt-submission.sh` VERSION from "1.2 2024-09-23"
to "1.3 2024-09-27".

The `bin/entry2csv.sh` tool forms the `summary.csv` file
based on the "_title_" and "_abstract_" fields found in .entry.json files.

Changed `bin/entry2csv.sh` VERSION from "1.3 2024-09-23"
to "1.4 2024-09-27".

Perform `make entry2csv` to perform the above and test under macOS.

Added `-H` and `header=with-header-3` to the `bin/md2html.cfg`
for the configuration entry for `[12][0-9][0-9][0-9]/*/README.md`.

Changed `bin/md2html.sh` VERSION from "1.6 2024-08-17"
to "1.7 2024-09-27".

All entry `index.html` files now list the "_abstract_" in a new
`<h3>abstract</h3>` header.

Changed `bin/subst.entry-index.sh` VERSION from "1.6 2024-09-23"
to "1.7 2024-09-27".

Removed `summary.csv`.

Added `summary.csv` and `summary.numbers` to `.gitignore`.
Sorted the result with `bin/sgi.sh`.

Perform `make quick_www` to perform the above and test under macOS.

Perform `make www` to perform the above and test under macOS.
This commit is contained in:
Landon Curt Noll committed 2024-09-27 23:40:45 -07:00
1 parent 16c5a84b10
commit 0fa01fd744
651 files changed
+1925 -743

No files matched your search

+208 -38
View File
@@ -6,6 +6,7 @@
#
# author_wins.csv - author_handle followed by all their entry_ids
# manifest.csv - information about files under a entry
# summary.csv - year. dir, title and abstract for each entry
# year_prize.csv - entry_id followed by the entry's award
#
# This tool updates .entry.json files for all entries.
@@ -142,7 +143,7 @@ shopt -s lastpipe # explicitly run the last command of the pipe line in the curr
# set variables referenced in the usage message
#
export VERSION="1.3 2024-09-23"
export VERSION="1.4 2024-09-27"
NAME=$(basename "$0")
export NAME
export V_FLAG=0
@@ -171,9 +172,10 @@ export EXIT_CODE="0"
#
export AUTHOR_WINS_CSV="author_wins.csv"
export MANIFEST_CSV="manifest.csv"
export SUMMARY_CSV="summary.csv"
export YEAR_PRIZE_CSV="year_prize.csv"
export DOT_ENTRY_JSON_BASENAME=".entry.json"
export ENTRY_JSON_FORMAT_VERSION="1.1 2024-02-11"
export ENTRY_JSON_FORMAT_VERSION="1.2 2024-09-25"
export NO_COMMENT="mandatory comment: because comments were removed from the original JSON spec"
export AUTHOR_DIR="author"
@@ -288,7 +290,7 @@ function canonicalize_csv
# usage
#
export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-n] [-N]
[author_wins.csv [manifest.csv [year_prize.csv]]]
[author_wins.csv [manifest.csv [summary.csv [year_prize.csv]]]]
-h print help message and exit
-v level set verbosity level (def level: 0)
@@ -300,7 +302,8 @@ export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-n] [-N]
-N do not process anything, just parse arguments (def: process something)
author_wins.csv where to form author_wins.csv (def: $AUTHOR_WINS_CSV)
manifest.csv where to form manifest.csv (def: $MANIFEST_CSV)
manifest.csv where to form manifest.csv (def: $MANIFEST_CSV)k
summary.csv where to form summary.csv (def: $SUMMARY_CSV)
year_prize.csv where to form year_prize.csv (def: $YEAR_PRIZE_CSV)
Exit codes:
@@ -359,14 +362,15 @@ done
#
shift $(( OPTIND - 1 ));
#
if [[ $V_FLAG -ge 5 ]]; then
if [[ $V_FLAG -ge 6 ]]; then
echo "$0: debug[5]: file argument count: $#" 1>&2
fi
case "$#" in
0) ;;
1) AUTHOR_WINS_CSV="$1" ;;
2) AUTHOR_WINS_CSV="$1" ; MANIFEST_CSV="$2" ;;
3) AUTHOR_WINS_CSV="$1" ; MANIFEST_CSV="$2" ; YEAR_PRIZE_CSV="$3" ;;
3) AUTHOR_WINS_CSV="$1" ; MANIFEST_CSV="$2" ; SUMMARY_CSV="$3" ;;
4) AUTHOR_WINS_CSV="$1" ; MANIFEST_CSV="$2" ; SUMMARY_CSV="$3" ; YEAR_PRIZE_CSV="$4" ;;
*) echo "$0: expected 0, 1, 2 or 3 args, found #$" 1>&2
echo 1>*2
echo "$USAGE" 1>&2
@@ -399,6 +403,17 @@ if [[ ! -w $MANIFEST_CSV_DIR ]]; then
exit 8
fi
#
if [[ -z $SUMMARY_CSV ]]; then
echo "$0: ERROR: SUMMARY_CSV is empty" 1>&2
exit 8
fi
SUMMARY_CSV_DIR=$(dirname "$SUMMARY_CSV")
export SUMMARY_CSV_DIR
if [[ ! -w $SUMMARY_CSV_DIR ]]; then
echo "$0: ERROR: SUMMARY_CSV file: $SUMMARY_CSV in a non-writable directory: $SUMMARY_CSV_DIR" 1>&2
exit 8
fi
#
if [[ -z $YEAR_PRIZE_CSV ]]; then
echo "$0: ERROR: YEAR_PRIZE_CSV is empty" 1>&2
exit 8
@@ -499,7 +514,7 @@ if [[ ! -x $JVAL_WRAPPER ]]; then
fi
# verify that the bin/jval-wrapper.sh tool is executable
# verify that the bin/unicode-chk.sh tool is executable
#
export UNICODE_CHK="$BIN_DIR/unicode-chk.sh"
if [[ ! -e $UNICODE_CHK ]]; then
@@ -548,9 +563,11 @@ if [[ $V_FLAG -ge 3 ]]; then
echo "$0: debug[3]: EXIT_CODE=$EXIT_CODE" 1>&2
echo "$0: debug[3]: AUTHOR_WINS_CSV=$AUTHOR_WINS_CSV" 1>&2
echo "$0: debug[3]: MANIFEST_CSV=$MANIFEST_CSV" 1>&2
echo "$0: debug[3]: SUMMARY_CSV=$SUMMARY_CSV" 1>&2
echo "$0: debug[3]: YEAR_PRIZE_CSV=$YEAR_PRIZE_CSV" 1>&2
echo "$0: debug[3]: AUTHOR_WINS_CSV_DIR=$AUTHOR_WINS_CSV_DIR" 1>&2
echo "$0: debug[3]: MANIFEST_CSV_DIR=$MANIFEST_CSV_DIR" 1>&2
echo "$0: debug[3]: SUMMARY_CSV_DIR=$SUMMARY_CSV_DIR" 1>&2
echo "$0: debug[3]: YEAR_PRIZE_CSV_DIR=$YEAR_PRIZE_CSV_DIR" 1>&2
echo "$0: debug[3]: CD_FAILED=$CD_FAILED" 1>&2
echo "$0: debug[3]: TOP_FILE=$TOP_FILE" 1>&2
@@ -616,23 +633,43 @@ if [[ ! -e $TMP_MANIFEST_CSV ]]; then
fi
# create a temporary summary.csv file
#
export TMP_SUMMARY_CSV=".tmp.$NAME.SUMMARY_CSV.$$.tmp"
if [[ $V_FLAG -ge 3 ]]; then
echo "$0: debug[3]: temporary CSV summary.csv file: $TMP_SUMMARY_CSV" 1>&2
fi
trap 'rm -f $TMP_SUMMARY_CSV; exit' 0 1 2 3 15
rm -f "$TMP_SUMMARY_CSV"
if [[ -e $TMP_SUMMARY_CSV ]]; then
echo "$0: ERROR: cannot remove temporary CSV summary.csv file: $TMP_SUMMARY_CSV" 1>&2
exit 14
fi
echo '# year,dir,title,abstract' > \
"$TMP_SUMMARY_CSV"
if [[ ! -e $TMP_SUMMARY_CSV ]]; then
echo "$0: ERROR: cannot create temporary CSV summary.csv file: $TMP_SUMMARY_CSV" 1>&2
exit 15
fi
# create a temporary year_prize.csv file
#
export TMP_YEAR_PRIZE_CSV=".tmp.$NAME.YEAR_PRIZE_CSV.$$.tmp"
if [[ $V_FLAG -ge 3 ]]; then
echo "$0: debug[3]: temporary CSV year_prize.csv file: $TMP_YEAR_PRIZE_CSV" 1>&2
fi
trap 'rm -f $TMP_AUTHOR_WINS_CSV $TMP_MANIFEST_CSV $TMP_YEAR_PRIZE_CSV; exit' 0 1 2 3 15
trap 'rm -f $TMP_AUTHOR_WINS_CSV $TMP_MANIFEST_CSV $TMP_YEAR_PRIZE_CSV $TMP_SUMMARY_CSV $TMP_AUTHOR_WINS_CSV; exit' 0 1 2 3 15
rm -f "$TMP_YEAR_PRIZE_CSV"
if [[ -e $TMP_YEAR_PRIZE_CSV ]]; then
echo "$0: ERROR: cannot remove temporary CSV year_prize.csv file: $TMP_YEAR_PRIZE_CSV" 1>&2
exit 14
exit 16
fi
echo '# year_handle,award name' > \
"$TMP_YEAR_PRIZE_CSV"
if [[ ! -e $TMP_YEAR_PRIZE_CSV ]]; then
echo "$0: ERROR: cannot create temporary CSV year_prize.csv file: $TMP_YEAR_PRIZE_CSV" 1>&2
exit 15
exit 17
fi
@@ -642,16 +679,17 @@ export TMP_YYYY_DIR_INV=".tmp.$NAME.YYYY_DIR_inventory.$$.tmp"
if [[ $V_FLAG -ge 3 ]]; then
echo "$0: debug[3]: temporary CSV temporary YYYY_DIR inventory file: $TMP_YYYY_DIR_INV" 1>&2
fi
trap 'rm -f $TMP_AUTHOR_WINS_CSV $TMP_MANIFEST_CSV $TMP_YEAR_PRIZE_CSV $TMP_YYYY_DIR_INV; exit' 0 1 2 3 15
trap 'rm -f $TMP_AUTHOR_WINS_CSV $TMP_MANIFEST_CSV $TMP_YEAR_PRIZE_CSV $TMP_SUMMARY_CSV $TMP_AUTHOR_WINS_CSV \
$TMP_YYYY_DIR_INV; exit' 0 1 2 3 15
rm -f "$TMP_YYYY_DIR_INV"
if [[ -e $TMP_YYYY_DIR_INV ]]; then
echo "$0: ERROR: cannot remove temporary CSV temporary YYYY_DIR inventory file: $TMP_YYYY_DIR_INV" 1>&2
exit 16
exit 18
fi
: > "$TMP_YYYY_DIR_INV"
if [[ ! -e $TMP_YYYY_DIR_INV ]]; then
echo "$0: ERROR: cannot create temporary CSV temporary YYYY_DIR inventory file: $TMP_YYYY_DIR_INV" 1>&2
exit 17
exit 19
fi
@@ -661,17 +699,17 @@ export TMP_2ND_YYYY_DIR_INV=".tmp.$NAME.YYYY_DIR_inventory.$$.tmp"
if [[ $V_FLAG -ge 3 ]]; then
echo "$0: debug[3]: temporary CSV temporary 2nd YYYY_DIR inventory file: $TMP_2ND_YYYY_DIR_INV" 1>&2
fi
trap 'rm -f $TMP_AUTHOR_WINS_CSV $TMP_MANIFEST_CSV $TMP_YEAR_PRIZE_CSV $TMP_YYYY_DIR_INV \
trap 'rm -f $TMP_AUTHOR_WINS_CSV $TMP_MANIFEST_CSV $TMP_YEAR_PRIZE_CSV $TMP_SUMMARY_CSV $TMP_AUTHOR_WINS_CSV \
$TMP_YYYY_DIR_INV $TMP_2ND_YYYY_DIR_INV; exit' 0 1 2 3 15
rm -f "$TMP_2ND_YYYY_DIR_INV"
if [[ -e $TMP_2ND_YYYY_DIR_INV ]]; then
echo "$0: ERROR: cannot remove temporary CSV temporary 2nd YYYY_DIR inventory file: $TMP_2ND_YYYY_DIR_INV" 1>&2
exit 18
exit 20
fi
: > "$TMP_2ND_YYYY_DIR_INV"
if [[ ! -e $TMP_2ND_YYYY_DIR_INV ]]; then
echo "$0: ERROR: cannot create temporary CSV temporary 2nd YYYY_DIR inventory file: $TMP_2ND_YYYY_DIR_INV" 1>&2
exit 19
exit 21
fi
@@ -681,17 +719,17 @@ export TMP_ENTRY_JSON=".tmp.$NAME.entry.json.$$.tmp"
if [[ $V_FLAG -ge 3 ]]; then
echo "$0: debug[3]: temporary CSV temporary .entry.json file: $TMP_ENTRY_JSON" 1>&2
fi
trap 'rm -f $TMP_AUTHOR_WINS_CSV $TMP_MANIFEST_CSV $TMP_YEAR_PRIZE_CSV $TMP_YYYY_DIR_INV \
trap 'rm -f $TMP_AUTHOR_WINS_CSV $TMP_MANIFEST_CSV $TMP_YEAR_PRIZE_CSV $TMP_SUMMARY_CSV $TMP_AUTHOR_WINS_CSV \
$TMP_YYYY_DIR_INV $TMP_2ND_YYYY_DIR_INV $TMP_ENTRY_JSON; exit' 0 1 2 3 15
rm -f "$TMP_ENTRY_JSON"
if [[ -e $TMP_ENTRY_JSON ]]; then
echo "$0: ERROR: cannot remove temporary CSV temporary .entry.json file: $TMP_ENTRY_JSON" 1>&2
exit 20
exit 22
fi
: > "$TMP_ENTRY_JSON"
if [[ ! -e $TMP_ENTRY_JSON ]]; then
echo "$0: ERROR: cannot create temporary CSV temporary .entry.json file: $TMP_ENTRY_JSON" 1>&2
exit 21
exit 23
fi
@@ -704,17 +742,17 @@ export TMP_EXIT_CODE=".tmp.$NAME.EXIT_CODE.$$.tmp"
if [[ $V_FLAG -ge 3 ]]; then
echo "$0: debug[3]: temporary exit code: $TMP_EXIT_CODE" 1>&2
fi
trap 'rm -f $TMP_AUTHOR_WINS_CSV $TMP_MANIFEST_CSV $TMP_YEAR_PRIZE_CSV $TMP_YYYY_DIR_INV $TMP_YYYY_DIR_INV \
$TMP_2ND_YYYY_DIR_INV $TMP_ENTRY_JSON $TMP_EXIT_CODE; exit' 0 1 2 3 15
trap 'rm -f $TMP_AUTHOR_WINS_CSV $TMP_MANIFEST_CSV $TMP_YEAR_PRIZE_CSV $TMP_SUMMARY_CSV $TMP_AUTHOR_WINS_CSV \
$TMP_YYYY_DIR_INV $TMP_2ND_YYYY_DIR_INV $TMP_ENTRY_JSON $TMP_EXIT_CODE; exit' 0 1 2 3 15
rm -f "$TMP_EXIT_CODE"
if [[ -e $TMP_EXIT_CODE ]]; then
echo "$0: ERROR: cannot remove temporary exit code: $TMP_EXIT_CODE" 1>&2
exit 22
exit 24
fi
echo "$EXIT_CODE" > "$TMP_EXIT_CODE"
if [[ ! -e $TMP_EXIT_CODE ]]; then
echo "$0: ERROR: cannot create temporary exit code: $TMP_EXIT_CODE" 1>&2
exit 23
exit 25
fi
@@ -724,17 +762,18 @@ export TMP_AUTHOR_HANDLE_FROM_FILES=".tmp.$NAME.AUTHOR_HANDLE_FROM_FILES.$$.tmp"
if [[ $V_FLAG -ge 3 ]]; then
echo "$0: debug[3]: temporary sorted list of author_handles: $TMP_AUTHOR_HANDLE_FROM_FILES" 1>&2
fi
trap 'rm -f $TMP_AUTHOR_WINS_CSV $TMP_MANIFEST_CSV $TMP_YEAR_PRIZE_CSV $TMP_YYYY_DIR_INV $TMP_YYYY_DIR_INV \
$TMP_2ND_YYYY_DIR_INV $TMP_ENTRY_JSON $TMP_EXIT_CODE $TMP_AUTHOR_HANDLE_FROM_FILES; exit' 0 1 2 3 15
trap 'rm -f $TMP_AUTHOR_WINS_CSV $TMP_MANIFEST_CSV $TMP_YEAR_PRIZE_CSV $TMP_SUMMARY_CSV $TMP_AUTHOR_WINS_CSV \
$TMP_YYYY_DIR_INV $TMP_2ND_YYYY_DIR_INV $TMP_ENTRY_JSON $TMP_EXIT_CODE \
$TMP_AUTHOR_HANDLE_FROM_FILES; exit' 0 1 2 3 15
rm -f "$TMP_AUTHOR_HANDLE_FROM_FILES"
if [[ -e $TMP_AUTHOR_HANDLE_FROM_FILES ]]; then
echo "$0: ERROR: cannot remove temporary sorted list of author_handles: $TMP_AUTHOR_HANDLE_FROM_FILES" 1>&2
exit 24
exit 26
fi
: > "$TMP_AUTHOR_HANDLE_FROM_FILES"
if [[ ! -e $TMP_AUTHOR_HANDLE_FROM_FILES ]]; then
echo "$0: ERROR: cannot create temporary sorted list of author_handles: $TMP_AUTHOR_HANDLE_FROM_FILES" 1>&2
exit 25
exit 27
fi
@@ -744,17 +783,18 @@ export TMP_AUTHOR_HANDLE_FROM_CSV=".tmp.$NAME.AUTHOR_HANDLE_FROM_CSV.$$.tmp"
if [[ $V_FLAG -ge 3 ]]; then
echo "$0: debug[3]: temporary sorted list of author_handles: $TMP_AUTHOR_HANDLE_FROM_CSV" 1>&2
fi
trap 'rm -f $TMP_AUTHOR_WINS_CSV $TMP_MANIFEST_CSV $TMP_YEAR_PRIZE_CSV $TMP_YYYY_DIR_INV $TMP_YYYY_DIR_INV \
$TMP_2ND_YYYY_DIR_INV $TMP_ENTRY_JSON $TMP_EXIT_CODE $TMP_AUTHOR_HANDLE_FROM_CSV; exit' 0 1 2 3 15
trap 'rm -f $TMP_AUTHOR_WINS_CSV $TMP_MANIFEST_CSV $TMP_YEAR_PRIZE_CSV $TMP_SUMMARY_CSV $TMP_AUTHOR_WINS_CSV \
$TMP_YYYY_DIR_INV $TMP_2ND_YYYY_DIR_INV $TMP_ENTRY_JSON $TMP_EXIT_CODE \
$TMP_AUTHOR_HANDLE_FROM_FILES $TMP_AUTHOR_HANDLE_FROM_CSV; exit' 0 1 2 3 15
rm -f "$TMP_AUTHOR_HANDLE_FROM_CSV"
if [[ -e $TMP_AUTHOR_HANDLE_FROM_CSV ]]; then
echo "$0: ERROR: cannot remove temporary sorted list of author_handles: $TMP_AUTHOR_HANDLE_FROM_CSV" 1>&2
exit 26
exit 28
fi
: > "$TMP_AUTHOR_HANDLE_FROM_CSV"
if [[ ! -e $TMP_AUTHOR_HANDLE_FROM_CSV ]]; then
echo "$0: ERROR: cannot create temporary sorted list of author_handles: $TMP_AUTHOR_HANDLE_FROM_CSV" 1>&2
exit 26
exit 29
fi
@@ -999,6 +1039,93 @@ elif [[ $V_FLAG -ge 3 ]]; then
fi
# canonicalize summary.csv into temporary summary.csv file
#
if [[ -z $NOOP ]]; then
if [[ $V_FLAG -ge 1 ]]; then
echo "$0: debug[1]: about to: canonicalize $SUMMARY_CSV" 1>&2
fi
canonicalize_csv "$SUMMARY_CSV" "$TMP_SUMMARY_CSV"
status="$?"
if [[ $status -ne 0 ]]; then
echo "$0: ERROR: canonicalize_csv $SUMMARY_CSV $TMP_SUMMARY_CSV failed," \
"error code: $status" 1>&2
exit 8
elif [[ $V_FLAG -ge 3 ]]; then
echo "$0: debug[3]: sorted temporary summary.csv file: $TMP_SUMMARY_CSV" 1>&2
fi
elif [[ $V_FLAG -ge 3 ]]; then
echo "$0: debug[3]: because of -n, will not canonicalize: $SUMMARY_CSV"
fi
# sort the temporary summary.csv file
#
if [[ -z $NOOP ]]; then
if [[ $V_FLAG -ge 5 ]]; then
echo "$0: debug[5]: about to: LC_ALL=C sort -t, -k1,1 -k2d,4 $TMP_SUMMARY_CSV -o $TMP_SUMMARY_CSV" 1>&2
fi
LC_ALL=C sort -t, -k1,1 -k2d,4 "$TMP_SUMMARY_CSV" -o "$TMP_SUMMARY_CSV"
status="$?"
if [[ $status -ne 0 ]]; then
echo "$0: ERROR: LC_ALL=C sort -t, -k1d,1 -k2d,2 $TMP_SUMMARY_CSV -o $TMP_SUMMARY_CSV," \
"error code: $status" 1>&2
exit 8
elif [[ $V_FLAG -ge 3 ]]; then
echo "$0: debug[3]: sorted temporary summary.csv file: $TMP_SUMMARY_CSV" 1>&2
fi
elif [[ $V_FLAG -ge 3 ]]; then
echo "$0: debug[3]: because of -n, will not sort: $TMP_SUMMARY_CSV"
fi
# replace summary.csv file with the temporary file if summary.csv is missing or different
#
if [[ -z $NOOP ]]; then
if cmp -s "$TMP_SUMMARY_CSV" "$SUMMARY_CSV"; then
# case: summary.csv did not change
#
if [[ $V_FLAG -ge 5 ]]; then
echo "$0: debug[5]: summary.csv file did not change: $SUMMARY_CSV" 1>&2
fi
else
# case: summary.csv file changed, update the file
#
if [[ $V_FLAG -ge 5 ]]; then
echo "$0: debug[5]: about to: mv -f -- $TMP_SUMMARY_CSV $SUMMARY_CSV" 1>&2
fi
if [[ $V_FLAG -ge 3 ]]; then
mv -f -v -- "$TMP_SUMMARY_CSV" "$SUMMARY_CSV"
status="$?"
else
mv -f -- "$TMP_SUMMARY_CSV" "$SUMMARY_CSV"
status="$?"
fi
if [[ $status -ne 0 ]]; then
echo "$0: ERROR: mv -f -- $TMP_SUMMARY_CSV $SUMMARY_CSV filed," \
"error code: $status" 1>&2
exit 8
elif [[ $V_FLAG -ge 1 ]]; then
echo "$0: debug[1]: replaced summary.csv file: $SUMMARY_CSV" 1>&2
fi
if [[ ! -s $SUMMARY_CSV ]]; then
echo "$0: ERROR: not a non-empty summary.csv file: $SUMMARY_CSV" 1>&2
exit 8
fi
fi
elif [[ $V_FLAG -ge 3 ]]; then
echo "$0: debug[3]: because of -n, will not update $SUMMARY_CSV"
fi
# canonicalize year_prize.csv into temporary year_prize.csv file
#
if [[ -z $NOOP ]]; then
@@ -1259,7 +1386,7 @@ done
#
if [[ ! -s $TMP_YYYY_DIR_INV ]]; then
echo "$0: ERROR: arg: YYYY_DIR inventory file is not a non-empty file: $TMP_YYYY_DIR_INV" 1>&2
exit 26
exit 30
fi
#
if [[ $V_FLAG -ge 5 ]]; then
@@ -1288,7 +1415,7 @@ status_codes=("${PIPESTATUS[@]}")
if [[ ${status_codes[*]} =~ [1-9] ]]; then
echo "$0: ERROR: sed .. $AUTHOR_WINS_CSV | LC_ALL=C sort -t/ -d > $TMP_2ND_YYYY_DIR_INV failed," \
"error codes: ${status_codes[*]}" 1>&2
exit 27
exit 31
fi
@@ -1302,7 +1429,7 @@ if ! cmp -s "$TMP_YEAR_PRIZE_CSV" "$YEAR_PRIZE_CSV"; then
echo "$0: Warning: difference between YYYY/dir tree and author_wins.csv entries starts below: $AUTHOR_WINS_CSV" 1>&2
diff -u "$TMP_YEAR_PRIZE_CSV" "$YEAR_PRIZE_CSV" 1>&2
echo "$0: Warning: difference between YYYY/dir tree and author_wins.csv entries ends above" 1>&2
exit 28
exit 32
elif [[ $V_FLAG -ge 5 ]]; then
echo "$0: debug[5]: author_wins.csv entry inventory is correct" 1>&2
@@ -1319,7 +1446,7 @@ status_codes=("${PIPESTATUS[@]}")
if [[ ${status_codes[*]} =~ [1-9] ]]; then
echo "$0: ERROR: sed .. $MANIFEST_CSV | LC_ALL=C sort -t/ -d | uniq > $TMP_2ND_YYYY_DIR_INV failed," \
"error codes: ${status_codes[*]}" 1>&2
exit 29
exit 33
fi
@@ -1333,7 +1460,7 @@ if ! cmp -s "$TMP_YEAR_PRIZE_CSV" "$YEAR_PRIZE_CSV"; then
echo "$0: Warning: difference between YYYY/dir tree and manifest.csv entries starts below: $MANIFEST_CSV" 1>&2
diff -u "$TMP_YEAR_PRIZE_CSV" "$YEAR_PRIZE_CSV" 1>&2
echo "$0: Warning: difference between YYYY/dir tree and manifest.csv entries ends above" 1>&2
exit 30
exit 34
elif [[ $V_FLAG -ge 5 ]]; then
echo "$0: debug[5]: manifest.csv.csv entry inventory is correct" 1>&2
@@ -1350,7 +1477,7 @@ status_codes=("${PIPESTATUS[@]}")
if [[ ${status_codes[*]} =~ [1-9] ]]; then
echo "$0: ERROR: sed .. $YEAR_PRIZE_CSV | LC_ALL=C sort -t/ -d > $TMP_2ND_YYYY_DIR_INV failed," \
"error codes: ${status_codes[*]}" 1>&2
exit 31
exit 35
fi
@@ -1364,7 +1491,7 @@ if ! cmp -s "$TMP_YEAR_PRIZE_CSV" "$YEAR_PRIZE_CSV"; then
echo "$0: Warning: difference between YYYY/dir tree and year_prize.csv entries starts below: $YEAR_PRIZE_CSV" 1>&2
diff -u "$TMP_YEAR_PRIZE_CSV" "$YEAR_PRIZE_CSV" 1>&2
echo "$0: Warning: difference between YYYY/dir tree and year_prize.csv entries ends above" 1>&2
exit 32
exit 36
elif [[ $V_FLAG -ge 5 ]]; then
echo "$0: debug[5]: year_prize.csv entry inventory is correct" 1>&2
@@ -1519,6 +1646,47 @@ sed -e '/^#/d' -e 's/,/ /g' "$MANIFEST_CSV" |
exit 1
fi
# obtain the entry's line form summary.csv
#
SUMMARY_LINE_FOUND=$(grep -c "^${YEAR},${DIR}," "$SUMMARY_CSV")
if [[ $SUMMARY_LINE_FOUND -le 0 ]]; then
echo "$0: ERROR: unable to find ^${YEAR},${DIR}, in $SUMMARY_CSV" 1>&2
exit 1
elif [[ $SUMMARY_LINE_FOUND -ge 2 ]]; then
echo "$0: ERROR: found more then 1 line of the form ^${YEAR},${DIR}, in $SUMMARY_CSV" 1>&2
exit 1
fi
SUMMARY_LINE=$(grep "^${YEAR},${DIR}," "$SUMMARY_CSV" | tr , ' ')
# obtain title and abstract from the entry's line in summary.csv
#
export YEAR_FOUND DIR_FOUND TITLE ABSTRACT
read -r YEAR_FOUND DIR_FOUND TITLE ABSTRACT <<< "$SUMMARY_LINE"
if [[ $YEAR != "$YEAR_FOUND" ]]; then
echo "$0: ERROR: year $YEAR != found year: $YEAR_FOUND for ^${YEAR},${DIR}, in $SUMMARY_CSV" 1>&2
exit 1
fi
if [[ $DIR != "$DIR_FOUND" ]]; then
echo "$0: ERROR: year $DIR != found year: $DIR_FOUND for ^${YEAR},${DIR}, in $SUMMARY_CSV" 1>&2
exit 1
fi
if [[ -z $TITLE ]]; then
TITLE="${DIR}.${YEAR}"
echo "$0: Warning empty title for ^${YEAR},${DIR}, in $SUMMARY_CSV, will use $TITLE" 1>&2
fi
if [[ -z $ABSTRACT ]]; then
ABSTRACT="default abstract for ${YEAR}/${DIR}"
echo "$0: Warning empty abstract for ^${YEAR},${DIR}, in $SUMMARY_CSV, will use $TITLE" 1>&2
fi
if [[ ${#ABSTRACT} -ge 65 ]]; then
echo "$0: ERROR: abstract length ${#ABSTRACT} >= 65 for $YEAR_FOUND/$DIR_FOUND" 1>&2
exit 1
fi
if [[ $ABSTRACT =~ [\;$,] ]]; then
echo "$0: ERROR: abstract contains ; or & or , for $YEAR_FOUND/$DIR_FOUND" 1>&2
exit 1
fi
# append top level lines to the temporary .entry.file
#
{
@@ -1541,6 +1709,8 @@ sed -e '/^#/d' -e 's/,/ /g' "$MANIFEST_CSV" |
printf " \"year\" : %s,\n" "$YEAR"
printf " \"dir\" : \"%s\",\n" "$DIR"
printf " \"entry_id\" : \"%s\",\n" "$ENTRY_ID"
printf " \"title\" : \"%s\",\n" "$TITLE"
printf " \"abstract\" : \"%s\",\n" "$ABSTRACT"
} >> "$TMP_ENTRY_JSON"
# write the start of the author_set JSON array to the temporary .entry.file
+61 -31
View File
@@ -94,7 +94,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.2 2024-09-23"
export VERSION="1.3 2024-09-27"
NAME=$(basename "$0")
export NAME
export V_FLAG=0
@@ -149,7 +149,7 @@ export MKIOCCCENTRY_REPO="https://github.com/ioccc-src/mkiocccentry"
export INPUT_DATA_FILE
#
export NO_COMMENT="mandatory comment: because comments were removed from the original JSON spec"
export ENTRY_JSON_FORMAT_VERSION="1.1 2024-02-11"
export ENTRY_JSON_FORMAT_VERSION="1.2 2024-09-25"
export AUTHOR_JSON_FORMAT_VERSION="1.1 2024-02-11"
#
export NOOP=
@@ -601,49 +601,49 @@ function write_author_handle_file
printf "{\n"
printf " \"no_comment\" : \"%s\",\n" "${AUTH_INFO[no_comment]}"
printf " \"author_JSON_format_version\" : \"%s\",\n" "${AUTH_INFO[author_JSON_format_version]}"
printf " \"author_handle\" : %s,\n" "${AUTH_INFO[author_handle]}"
printf " \"full_name\" : %s,\n" "${AUTH_INFO[name]}"
printf " \"sort_word\" : %s,\n" "${AUTH_INFO[sort_word]}"
printf " \"location_code\" : %s,\n" "${AUTH_INFO[location_code]}"
printf " \"author_handle\" : \"%s\",\n" "${AUTH_INFO[author_handle]}"
printf " \"full_name\" : \"%s\",\n" "${AUTH_INFO[name]}"
printf " \"sort_word\" : \"%s\",\n" "${AUTH_INFO[sort_word]}"
printf " \"location_code\" : \"%s\",\n" "${AUTH_INFO[location_code]}"
if [[ ${AUTH_INFO[email]} == null || -z ${AUTH_INFO[email]} ]]; then
printf " \"email\" : %s,\n" "null"
printf " \"email\" : null,\n"
else
printf " \"email\" : %s,\n" "${AUTH_INFO[email]}"
printf " \"email\" : \"%s\",\n" "${AUTH_INFO[email]}"
fi
if [[ ${AUTH_INFO[url]} == null || -z ${AUTH_INFO[url]} ]]; then
printf " \"url\" : %s,\n" "null"
printf " \"url\" : null,\n"
else
printf " \"url\" : %s,\n" "${AUTH_INFO[url]}"
printf " \"url\" : \"%s\",\n" "${AUTH_INFO[url]}"
fi
if [[ ${AUTH_INFO[alt_url]} == null || -z ${AUTH_INFO[alt_url]} ]]; then
printf " \"alt_url\" : %s,\n" "null"
printf " \"alt_url\" : null,\n"
else
printf " \"alt_url\" : %s,\n" "${AUTH_INFO[alt_url]}"
printf " \"alt_url\" : \"%s\",\n" "${AUTH_INFO[alt_url]}"
fi
if [[ ${AUTH_INFO[deprecated_twitter_handle]} == null || -z ${AUTH_INFO[deprecated_twitter_handle]} ]]; then
printf " \"deprecated_twitter_handle\" : %s,\n" "null"
printf " \"deprecated_twitter_handle\" : null,\n"
else
printf " \"deprecated_twitter_handle\" : %s,\n" "${AUTH_INFO[deprecated_twitter_handle]}"
printf " \"deprecated_twitter_handle\" : \"%s\",\n" "${AUTH_INFO[deprecated_twitter_handle]}"
fi
if [[ ${AUTH_INFO[mastodon]} == null || -z ${AUTH_INFO[mastodon]} ]]; then
printf " \"mastodon\" : %s,\n" "null"
printf " \"mastodon\" : null,\n"
else
printf " \"mastodon\" : %s,\n" "${AUTH_INFO[mastodon]}"
printf " \"mastodon\" : \"%s\",\n" "${AUTH_INFO[mastodon]}"
fi
if [[ ${AUTH_INFO[mastodon_url]} == null || -z ${AUTH_INFO[mastodon_url]} ]]; then
printf " \"mastodon_url\" : %s,\n" "null"
printf " \"mastodon_url\" : null,\n"
else
printf " \"mastodon_url\" : \"%s\",\n" "${AUTH_INFO[mastodon_url]}"
fi
if [[ ${AUTH_INFO[github]} == null || -z ${AUTH_INFO[github]} ]]; then
printf " \"github\" : %s,\n" "null"
printf " \"github\" : null,\n"
else
printf " \"github\" : %s,\n" "${AUTH_INFO[github]}"
printf " \"github\" : \"%s\",\n" "${AUTH_INFO[github]}"
fi
if [[ ${AUTH_INFO[affiliation]} == null || -z ${AUTH_INFO[affiliation]} ]]; then
printf " \"affiliation\" : %s,\n" "null"
printf " \"affiliation\" : null,\n"
else
printf " \"affiliation\" : %s,\n" "${AUTH_INFO[affiliation]}"
printf " \"affiliation\" : \"%s\",\n" "${AUTH_INFO[affiliation]}"
fi
# write the winning_entry_set array to the temporary author_handle JSON file
@@ -1318,7 +1318,7 @@ elif [[ $V_FLAG -ge 3 ]]; then
fi
# create a temporary author_handle file
# create a temporary author_handle JSON file
#
export TMP_AUTHOR_HANDLE_JSON=".tmp.$NAME.AUTHOR_HANDLE_JSON.$$.tmp"
if [[ $V_FLAG -ge 3 ]]; then
@@ -1341,7 +1341,7 @@ elif [[ $V_FLAG -ge 3 ]]; then
fi
# create a temporary author_handle file
# create a temporary manifest.csv file
#
export TMP_MANIFEST_CSV=".tmp.$NAME.MANIFEST_CSV.$$.tmp"
if [[ $V_FLAG -ge 3 ]]; then
@@ -1364,6 +1364,28 @@ elif [[ $V_FLAG -ge 3 ]]; then
fi
# obtain title from .info.json
#
export PATTERN='$..title'
TITLE=$("$JVAL_WRAPPER" -b -q "$INFO_JSON" "$PATTERN")
export TITLE
if [[ -z $TITLE ]]; then
TITLE="${ENTRY_DIR}.${YEAR_DIR}"
echo "$0: Warning empty title for in $INFO_JSON, use $TITLE" 1>&2
fi
# obtain title from .info.json
#
export ABSTRACT='$..abstract'
ABSTRACT=$("$JVAL_WRAPPER" -b -q "$INFO_JSON" "$PATTERN")
export ABSTRACT
if [[ -z $ABSTRACT ]]; then
ABSTRACT="default abstract for ${YEAR_DIR}/${ENTRY_DIR}"
echo "$0: Warning empty abstreact for in $INFO_JSON, will use $ABSTRACT" 1>&2
fi
# case: without -n
#
export VALUE
@@ -1404,6 +1426,14 @@ if [[ -z $NOOP ]]; then
#
echo " \"entry_id\" : \"${ENTRY_ID}\","
# write title to the temporary .entry.json file
#
echo " \"title\" : \"${TITLE}\","
# write abstract to the temporary .entry.json file
#
echo " \"abstract\" : \"${ABSTRACT}\","
# start the author_set JSON array
#
echo " \"author_set\" : ["
@@ -1441,10 +1471,10 @@ if [[ -z $NOOP ]]; then
echo "$0: debug[5]: about to run: $JVAL_WRAPPER -b -q -- $AUTH_JSON '$PATTERN'" 1>&2
fi
export AUTHOR_DATA
AUTHOR_DATA=$("$JVAL_WRAPPER" -b -q -- "$AUTH_JSON" "$PATTERN")
AUTHOR_DATA=$("$JVAL_WRAPPER" -q -- "$AUTH_JSON" "$PATTERN")
status="$?"
if [[ $status -ne 0 ]]; then
echo "$0: ERROR: $JVAL_WRAPPER -b -q -- $AUTH_JSON '$PATTERN' failed," \
echo "$0: ERROR: $JVAL_WRAPPER -q -- $AUTH_JSON '$PATTERN' failed," \
"error code: $status" 1>&2
exit 20
fi
@@ -1491,8 +1521,8 @@ if [[ -z $NOOP ]]; then
AUTHOR_DEFAULT_HANDLE="$VALUE"
;;
author_handle)
if [[ \"$AUTHOR_HANDLE\" != "$VALUE" ]]; then
echo "$0: ERROR: AUTHOR_HANDLE: \"$AUTHOR_HANDLE\" != author_handle value: $VALUE" 1>&2
if [[ $AUTHOR_HANDLE != "$VALUE" ]]; then
echo "$0: ERROR: AUTHOR_HANDLE: $AUTHOR_HANDLE != author_handle value: $VALUE" 1>&2
exit 22
fi
AUTHOR_INFO[author_handle]="$VALUE"
@@ -1544,7 +1574,7 @@ if [[ -z $NOOP ]]; then
[a-z]*) ;;
*) SORT_WORD="z$SORT_WORD" ;; # prepend if the last name does not begin with a letter
esac
AUTHOR_INFO[sort_word]=\""$SORT_WORD"\"
AUTHOR_INFO[sort_word]="$SORT_WORD"
# determine the mastodon_url for non-null mastodon
#
@@ -1612,14 +1642,14 @@ if [[ -z $NOOP ]]; then
#
case "$NAME" in
no_comment)
if [[ $VALUE != \"$NO_COMMENT\" ]]; then
if [[ $VALUE != "$NO_COMMENT" ]]; then
echo "$0: ERROR: author_handle file: $AUTHOR_HANDLE_JSON" \
"invalid no_comment: $VALUE != \"$NO_COMMENT\"" 1>&2
exit 35
fi
;;
author_JSON_format_version)
if [[ $VALUE != \"$AUTHOR_JSON_FORMAT_VERSION\" ]]; then
if [[ $VALUE != "$AUTHOR_JSON_FORMAT_VERSION" ]]; then
echo "$0: ERROR: author_handle file: $AUTHOR_HANDLE_JSON" \
"invalid author_JSON_format_version: $VALUE != \"$AUTHOR_JSON_FORMAT_VERSION\"" 1>&2
exit 36
@@ -1640,7 +1670,7 @@ if [[ -z $NOOP ]]; then
fi
;;
sort_word)
if [[ $VALUE != \""${AUTHOR_INFO[sort_word]}"\" ]]; then
if [[ $VALUE != "${AUTHOR_INFO[sort_word]}" ]]; then
echo "$0: notice: author_handle file: $AUTHOR_HANDLE_JSON" \
"change of sort_word from: $VALUE to: ${AUTHOR_INFO[sort_word]}" 1>&2
echo 1>&2
+262 -15
View File
@@ -118,7 +118,7 @@ shopt -s lastpipe # explicitly run the last command of the pipe line in the curr
# set variables referenced in the usage message
#
export VERSION="1.3 2024-09-23"
export VERSION="1.4 2024-09-27"
NAME=$(basename "$0")
export NAME
export V_FLAG=0
@@ -141,6 +141,7 @@ export EXIT_CODE="0"
#
export AUTHOR_WINS_CSV="author_wins.csv"
export MANIFEST_CSV="manifest.csv"
export SUMMARY_CSV="summary.csv"
export YEAR_PRIZE_CSV="year_prize.csv"
export AUTHOR_DIR="author"
@@ -251,6 +252,129 @@ function output_author_handles
}
# output_title
#
# Write the title name to standard output (stdout)
#
# usage:
# output_title YYYY/dir/.entry.json
#
# returns:
# 0 ==> no errors detected, but output may be empty
# > 0 ==> function error number
#
function output_title
{
local ENTRY_JSON_PATH; # the .entry.json path
local PATTERN; # XPath for JSON pattern
# parse args
#
if [[ $# -ne 1 ]]; then
echo "$0: ERROR: in output_title: expected 1 arg, found $#" 1>&2
return 1
fi
ENTRY_JSON_PATH="$1"
if [[ ! -e $ENTRY_JSON_PATH ]]; then
echo "$0: ERROR: in output_title: .entry.json does not exist: $ENTRY_JSON_PATH" 1>&2
return 2
fi
if [[ ! -f $ENTRY_JSON_PATH ]]; then
echo "$0: ERROR: in output_title: .entry.json is not a file: $ENTRY_JSON_PATH" 1>&2
return 3
fi
if [[ ! -r $ENTRY_JSON_PATH ]]; then
echo "$0: ERROR: in output_title: .entry.json is not a readable file: $ENTRY_JSON_PATH" 1>&2
return 4
fi
# obtain the title string
#
PATTERN='$..title'
if [[ $V_FLAG -ge 5 ]]; then
echo "$0: debug[5]: about to run: $JVAL_WRAPPER -b -q -- $ENTRY_JSON_PATH '$PATTERN'" 1>&2
fi
"$JVAL_WRAPPER" -b -q "$ENTRY_JSON_PATH" "$PATTERN"
status="$?"
if [[ $status -ne 0 ]]; then
echo "$0: ERROR: in output_title: $JVAL_WRAPPER -b -q -- $ENTRY_JSON_PATH '$PATTERN' failed," \
"error code: $status" 1>&2
return 5
fi
return 0
}
# output_abstract
#
# Write the abstract name to standard output (stdout)
#
# usage:
# output_abstract YYYY/dir/.entry.json
#
# returns:
# 0 ==> no errors detected, but output may be empty
# > 0 ==> function error number
#
function output_abstract
{
local ENTRY_JSON_PATH; # the .entry.json path
local PATTERN; # XPath for JSON pattern
local ABSTRACT; # extracted abstract from .entry.json
# parse args
#
if [[ $# -ne 1 ]]; then
echo "$0: ERROR: in output_abstract: expected 1 arg, found $#" 1>&2
return 1
fi
ENTRY_JSON_PATH="$1"
if [[ ! -e $ENTRY_JSON_PATH ]]; then
echo "$0: ERROR: in output_abstract: .entry.json does not exist: $ENTRY_JSON_PATH" 1>&2
return 2
fi
if [[ ! -f $ENTRY_JSON_PATH ]]; then
echo "$0: ERROR: in output_abstract: .entry.json is not a file: $ENTRY_JSON_PATH" 1>&2
return 3
fi
if [[ ! -r $ENTRY_JSON_PATH ]]; then
echo "$0: ERROR: in output_abstract: .entry.json is not a readable file: $ENTRY_JSON_PATH" 1>&2
return 4
fi
# obtain the abstract string
#
PATTERN='$..abstract'
if [[ $V_FLAG -ge 5 ]]; then
echo "$0: debug[5]: about to run: $JVAL_WRAPPER -b -q -- $ENTRY_JSON_PATH '$PATTERN'" 1>&2
fi
export ABSTRACT
ABSTRACT=$("$JVAL_WRAPPER" -b -q "$ENTRY_JSON_PATH" "$PATTERN")
status="$?"
if [[ $status -ne 0 || -z $ABSTRACT ]]; then
echo "$0: ERROR: in output_abstract: $JVAL_WRAPPER -b -q -- $ENTRY_JSON_PATH '$PATTERN' failed," \
"error code: $status" 1>&2
return 5
fi
if [[ ${#ABSTRACT} -ge 65 ]]; then
echo "$0: ERROR: in output_abstract: abstract length ${#ABSTRACT} >= 65 in $ENTRY_JSON_PATH" 1>&2
return 6
fi
if [[ $ABSTRACT =~ [\;$,] ]]; then
echo "$0: ERROR: in output_abstract: abstract contains ; or & or , in $ENTRY_JSON_PATH" 1>&2
return 7
fi
sed -f "$UNICODE_FIX_SED" -e 's/[;&,]//g' <<< "$ABSTRACT"
status="$?"
if [[ $status -ne 0 ]]; then
echo "$0: ERROR: sed -f $UNICODE_FIX_SED -e ... failed," \
"error code: $status" 1>&2
return 8
fi
return 0
}
# usage
#
export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-n] [-N]
@@ -531,6 +655,7 @@ if [[ $V_FLAG -ge 3 ]]; then
echo "$0: debug[3]: EXIT_CODE=$EXIT_CODE" 1>&2
echo "$0: debug[3]: AUTHOR_WINS_CSV=$AUTHOR_WINS_CSV" 1>&2
echo "$0: debug[3]: MANIFEST_CSV=$MANIFEST_CSV" 1>&2
echo "$0: debug[3]: SUMMARY_CSV=$SUMMARY_CSV" 1>&2
echo "$0: debug[3]: YEAR_PRIZE_CSV=$YEAR_PRIZE_CSV" 1>&2
echo "$0: debug[3]: AUTHOR_WINS_CSV_DIR=$AUTHOR_WINS_CSV_DIR" 1>&2
echo "$0: debug[3]: MANIFEST_WINS_CSV_DIR=$MANIFEST_WINS_CSV_DIR" 1>&2
@@ -572,7 +697,7 @@ echo '# author_handle,entry_id,entry_id,entry_id,…,,,,,,,,,,,,,,,' > \
"$TMP_AUTHOR_WINS_CSV"
if [[ ! -e $TMP_AUTHOR_WINS_CSV ]]; then
echo "$0: ERROR: cannot create temporary CSV author.csv file: $TMP_AUTHOR_WINS_CSV" 1>&2
exit 13
exit 11
fi
@@ -596,23 +721,43 @@ if [[ ! -e $TMP_MANIFEST_CSV ]]; then
fi
# create a temporary summary.csv file
#
export TMP_SUMMARY_CSV=".tmp.$NAME.SUMMARY_CSV.$$.tmp"
if [[ $V_FLAG -ge 3 ]]; then
echo "$0: debug[3]: temporary CSV summary.csv file: $TMP_SUMMARY_CSV" 1>&2
fi
trap 'rm -f $TMP_AUTHOR_WINS_CSV $TMP_MANIFEST_CSV $TMP_SUMMARY_CSV; exit' 0 1 2 3 15
rm -f "$TMP_SUMMARY_CSV"
if [[ -e $TMP_SUMMARY_CSV ]]; then
echo "$0: ERROR: cannot remove temporary CSV summary.csv file: $TMP_SUMMARY_CSV" 1>&2
exit 14
fi
echo '# year,dir,title,abstract' > \
"$TMP_SUMMARY_CSV"
if [[ ! -e $TMP_SUMMARY_CSV ]]; then
echo "$0: ERROR: cannot create temporary CSV summary.csv file: $TMP_SUMMARY_CSV" 1>&2
exit 15
fi
# create a temporary year_prize.csv file
#
export TMP_YEAR_PRIZE_CSV=".tmp.$NAME.YEAR_PRIZE_CSV.$$.tmp"
if [[ $V_FLAG -ge 3 ]]; then
echo "$0: debug[3]: temporary CSV year_prize.csv file: $TMP_YEAR_PRIZE_CSV" 1>&2
fi
trap 'rm -f $TMP_AUTHOR_WINS_CSV $TMP_MANIFEST_CSV $TMP_YEAR_PRIZE_CSV; exit' 0 1 2 3 15
trap 'rm -f $TMP_AUTHOR_WINS_CSV $TMP_MANIFEST_CSV $TMP_SUMMARY_CSV $TMP_YEAR_PRIZE_CSV; exit' 0 1 2 3 15
rm -f "$TMP_YEAR_PRIZE_CSV"
if [[ -e $TMP_YEAR_PRIZE_CSV ]]; then
echo "$0: ERROR: cannot remove temporary CSV year_prize.csv file: $TMP_YEAR_PRIZE_CSV" 1>&2
exit 14
exit 16
fi
echo '# year_handle,award name' > \
"$TMP_YEAR_PRIZE_CSV"
if [[ ! -e $TMP_YEAR_PRIZE_CSV ]]; then
echo "$0: ERROR: cannot create temporary CSV year_prize.csv file: $TMP_YEAR_PRIZE_CSV" 1>&2
exit 15
exit 16
fi
@@ -622,16 +767,17 @@ export TMP_AUTHOR_WIN=".tmp.$NAME.AUTHOR_WIN.$$.tmp"
if [[ $V_FLAG -ge 3 ]]; then
echo "$0: debug[3]: temporary CSV author_win file: $TMP_AUTHOR_WIN" 1>&2
fi
trap 'rm -f $TMP_AUTHOR_WINS_CSV $TMP_MANIFEST_CSV $TMP_YEAR_PRIZE_CSV $TMP_AUTHOR_WIN; exit' 0 1 2 3 15
trap 'rm -f $TMP_AUTHOR_WINS_CSV $TMP_MANIFEST_CSV $TMP_SUMMARY_CSV $TMP_YEAR_PRIZE_CSV \
$TMP_AUTHOR_WIN; exit' 0 1 2 3 15
rm -f "$TMP_AUTHOR_WIN"
if [[ -e $TMP_AUTHOR_WIN ]]; then
echo "$0: ERROR: cannot remove temporary CSV author_win file: $TMP_AUTHOR_WIN" 1>&2
exit 16
exit 18
fi
:> "$TMP_AUTHOR_WIN"
if [[ ! -e $TMP_AUTHOR_WIN ]]; then
echo "$0: ERROR: cannot create temporary CSV author_win file: $TMP_AUTHOR_WIN" 1>&2
exit 17
exit 19
fi
@@ -644,16 +790,17 @@ export TMP_EXIT_CODE=".tmp.$NAME.EXIT_CODE.$$.tmp"
if [[ $V_FLAG -ge 3 ]]; then
echo "$0: debug[3]: temporary exit code: $TMP_EXIT_CODE" 1>&2
fi
trap 'rm -f $TMP_AUTHOR_WINS_CSV $TMP_MANIFEST_CSV $TMP_YEAR_PRIZE_CSV $TMP_AUTHOR_WIN $TMP_EXIT_CODE; exit' 0 1 2 3 15
trap 'rm -f $TMP_AUTHOR_WINS_CSV $TMP_MANIFEST_CSV $TMP_SUMMARY_CSV $TMP_YEAR_PRIZE_CSV \
$TMP_AUTHOR_WIN $TMP_EXIT_CODE; exit' 0 1 2 3 15
rm -f "$TMP_EXIT_CODE"
if [[ -e $TMP_EXIT_CODE ]]; then
echo "$0: ERROR: cannot remove temporary exit code: $TMP_EXIT_CODE" 1>&2
exit 18
exit 20
fi
echo "$EXIT_CODE" > "$TMP_EXIT_CODE"
if [[ ! -e $TMP_EXIT_CODE ]]; then
echo "$0: ERROR: cannot create temporary exit code: $TMP_EXIT_CODE" 1>&2
exit 19
exit 21
fi
@@ -663,17 +810,17 @@ export TMP_AUTHOR_HANDLE_INVENTORY=".tmp.$NAME.AUTHOR_HANDLE_INVENTORY.$$.tmp"
if [[ $V_FLAG -ge 3 ]]; then
echo "$0: debug[3]: temporary author_handle inventory file: $TMP_AUTHOR_HANDLE_INVENTORY" 1>&2
fi
trap 'rm -f $TMP_AUTHOR_WINS_CSV $TMP_MANIFEST_CSV $TMP_YEAR_PRIZE_CSV $TMP_AUTHOR_WIN $TMP_EXIT_CODE \
$TMP_AUTHOR_HANDLE_INVENTORY; exit' 0 1 2 3 15
trap 'rm -f $TMP_AUTHOR_WINS_CSV $TMP_MANIFEST_CSV $TMP_SUMMARY_CSV $TMP_YEAR_PRIZE_CSV \
$TMP_AUTHOR_WIN $TMP_EXIT_CODE $TMP_AUTHOR_HANDLE_INVENTORY; exit' 0 1 2 3 15
rm -f "$TMP_AUTHOR_HANDLE_INVENTORY"
if [[ -e $TMP_AUTHOR_HANDLE_INVENTORY ]]; then
echo "$0: ERROR: cannot remove temporary author_handle inventory file: $TMP_AUTHOR_HANDLE_INVENTORY" 1>&2
exit 20
exit 22
fi
: > "$TMP_AUTHOR_HANDLE_INVENTORY"
if [[ ! -e $TMP_AUTHOR_HANDLE_INVENTORY ]]; then
echo "$0: ERROR: cannot create temporary author_handle inventory file: $TMP_AUTHOR_HANDLE_INVENTORY" 1>&2
exit 21
exit 23
fi
@@ -946,6 +1093,38 @@ for YYYY in $(< "$TOP_FILE"); do
elif [[ $V_FLAG -ge 9 ]]; then
echo "$0: debug[9]: because of -n, did not append to the temporary manifest file" 1>&2
fi
# obtain the title from .entry.json
#
TITLE=$(output_title "$ENTRY_JSON")
export TITLE
if [[ -z $TITLE ]]; then
echo "$0: ERROR: title name empty or not found in: $ENTRY_JSON" 1>&2
EXIT_CODE="1" # exit 1
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
echo "$EXIT_CODE" > "$TMP_EXIT_CODE"
continue
fi
# obtain the abstract from .entry.json
#
ABSTRACT=$(output_abstract "$ENTRY_JSON")
export ABSTRACT
if [[ -z $ABSTRACT ]]; then
echo "$0: ERROR: abstract name empty or not found in: $ENTRY_JSON" 1>&2
EXIT_CODE="1" # exit 1
echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2
echo "$EXIT_CODE" > "$TMP_EXIT_CODE"
continue
fi
# append title and abstract information into the summary.txt file
#
if [[ -z $NOOP ]]; then
echo "$YEAR_DIR,$ENTRY_DIR,$TITLE,$ABSTRACT" >> "$TMP_SUMMARY_CSV"
elif [[ $V_FLAG -ge 7 ]]; then
echo "$0: debug[7]: because of -n, did append to summary.csv: $TMP_SUMMARY_CSV for: $ENTRY_JSON" 1>&2
fi
done
done
@@ -1281,6 +1460,74 @@ elif [[ $V_FLAG -ge 3 ]]; then
fi
# sort the temporary summary.csv file
#
if [[ -z $NOOP ]]; then
if [[ $V_FLAG -ge 1 ]]; then
echo "$0: debug[1]: processing summary.csv file: $SUMMARY_CSV" 1>&2
fi
if [[ $V_FLAG -ge 5 ]]; then
echo "$0: debug[5]: about to: LC_ALL=C sort -t, -k1,1 -k2d,4 $TMP_SUMMARY_CSV -o $TMP_SUMMARY_CSV" 1>&2
fi
LC_ALL=C sort -t, -k1,1 -k2d,4 "$TMP_SUMMARY_CSV" -o "$TMP_SUMMARY_CSV"
status="$?"
if [[ $status -ne 0 ]]; then
echo "$0: ERROR: LC_ALL=C sort -t, -k1,1 -k2d,4 $TMP_SUMMARY_CSV -o $TMP_SUMMARY_CSV failed," \
"error code: $status" 1>&2
exit 8
elif [[ $V_FLAG -ge 3 ]]; then
echo "$0: debug[3]: sorted temporary summary.csv file: $TMP_SUMMARY_CSV" 1>&2
fi
elif [[ $V_FLAG -ge 3 ]]; then
echo "$0: debug[3]: because of -n, will not sort: $TMP_SUMMARY_CSV"
fi
# replace summary.csv file with the temporary file if summary.csv is missing or different
#
if [[ -z $NOOP ]]; then
if cmp -s "$TMP_SUMMARY_CSV" "$SUMMARY_CSV"; then
# case: summary.csv did not change
#
if [[ $V_FLAG -ge 5 ]]; then
echo "$0: debug[5]: summary.csv file did not change: $SUMMARY_CSV" 1>&2
fi
else
# case: summary.csv file changed, update the file
#
if [[ $V_FLAG -ge 5 ]]; then
echo "$0: debug[5]: about to: mv -f -- $TMP_SUMMARY_CSV $SUMMARY_CSV" 1>&2
fi
if [[ $V_FLAG -ge 3 ]]; then
mv -f -v -- "$TMP_SUMMARY_CSV" "$SUMMARY_CSV"
status="$?"
else
mv -f -- "$TMP_SUMMARY_CSV" "$SUMMARY_CSV"
status="$?"
fi
if [[ $status -ne 0 ]]; then
echo "$0: ERROR: mv -f -- $TMP_SUMMARY_CSV $SUMMARY_CSV filed," \
"error code: $status" 1>&2
exit 8
elif [[ $V_FLAG -ge 1 ]]; then
echo "$0: debug[1]: replaced summary.csv file: $SUMMARY_CSV" 1>&2
fi
if [[ ! -s $SUMMARY_CSV ]]; then
echo "$0: ERROR: not a non-empty summary.csv file: $SUMMARY_CSV" 1>&2
exit 8
fi
fi
elif [[ $V_FLAG -ge 3 ]]; then
echo "$0: debug[3]: because of -n, will not update $SUMMARY_CSV"
fi
# sort the temporary year_prize.csv file
#
if [[ -z $NOOP ]]; then
+2
View File
@@ -482,6 +482,8 @@ years.md
bin/output-index-author.sh
-a
bin/output-index-inventory.sh
-H
header=with-header-3
# Entry markdown files other than README.md files
#
+12 -6
View File
@@ -145,7 +145,7 @@ shopt -s lastpipe # run last command of a pipeline not executed in the backgroun
# set variables referenced in the usage message
#
export VERSION="1.6 2024-08-17"
export VERSION="1.7 2024-09-27"
NAME=$(basename "$0")
export NAME
export V_FLAG=0
@@ -217,7 +217,7 @@ export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-D docroot/] [-n] [-N]
-s token=value substitute %%token%% with value except in HTML phase numbers 20-29 (def: do not substitute any tokens)
NOTE: The 'token' string may not contain a ; (semicolon), a = (equal), or a % (percent).
NOTE: The 'value' string may not contain a ; (semicolon).
NOTE: The 'value' string may not contain a ; (semicolon), nor & (ampersand).
NOTE: A later '-s token=value' will override an earlier '-s token=value' for the same 'token'.
NOTE: Multiple '-s token=value' are cumulative for the unique set of 'token's.
-S Failure to replace a %%token%% is not an error (def: exit non-zero for non-substituted tokens)
@@ -482,13 +482,13 @@ function parse_command_line
#
case "$NAME" in
*=*)
echo "$0: ERROR: in -H phase=name, the phase may not contain a = character: $NAME" 1>&2
echo "$0: ERROR: in -H phase=name, the phase may not contain an = (equal) character: $NAME" 1>&2
echo 1>&2
print_usage 1>&2
exit 3
;;
*/*)
echo "$0: ERROR: in -H phase=name, the phase may not contain a / character: $NAME" 1>&2
echo "$0: ERROR: in -H phase=name, the phase may not contain a / (slash) character: $NAME" 1>&2
echo 1>&2
print_usage 1>&2
exit 3
@@ -510,7 +510,7 @@ function parse_command_line
#
case "$VALUE" in
*=*)
echo "$0: ERROR: in -H phase=name, the name may not contain a = character: $VALUE" 1>&2
echo "$0: ERROR: in -H phase=name, the name may not contain a = (equal) character: $VALUE" 1>&2
echo 1>&2
print_usage 1>&2
exit 3
@@ -589,7 +589,7 @@ function parse_command_line
exit 3
;;
*=*)
echo "$0: ERROR: in -s token=value, the token may not contain a = (equal) character: $NAME" 1>&2
echo "$0: ERROR: in -s token=value, the token may not contain an = (equal) character: $NAME" 1>&2
echo 1>&2
print_usage 1>&2
exit 3
@@ -610,6 +610,12 @@ function parse_command_line
print_usage 1>&2
exit 3
;;
*\&*)
echo "$0: ERROR: in -s token=value, the value may not contain an & (ampersand) character: $NAME" 1>&2
echo 1>&2
print_usage 1>&2
exit 3
;;
*) ;;
esac
#
+70 -1
View File
@@ -106,7 +106,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.6 2024-09-23"
export VERSION="1.7 2024-09-27"
NAME=$(basename "$0")
export NAME
export V_FLAG=0
@@ -220,6 +220,58 @@ function output_award
}
# Write the abstract name to standard output (stdout)
#
# usage:
# output_abstract YYYY/dir/.entry.json
#
# returns:
# 0 ==> no errors detected, but output may be empty
# > 0 ==> function error number
#
function output_abstract
{
local ENTRY_JSON_PATH; # the .entry.json path
local PATTERN; # XPath for JSON pattern
# parse args
#
if [[ $# -ne 1 ]]; then
echo "$0: ERROR: in output_abstract: expected 1 arg, found $#" 1>&2
return 1
fi
ENTRY_JSON_PATH="$1"
if [[ ! -e $ENTRY_JSON_PATH ]]; then
echo "$0: ERROR: in output_abstract: .entry.json does not exist: $ENTRY_JSON_PATH" 1>&2
return 2
fi
if [[ ! -f $ENTRY_JSON_PATH ]]; then
echo "$0: ERROR: in output_abstract: .entry.json is not a file: $ENTRY_JSON_PATH" 1>&2
return 3
fi
if [[ ! -r $ENTRY_JSON_PATH ]]; then
echo "$0: ERROR: in output_abstract: .entry.json is not a readable file: $ENTRY_JSON_PATH" 1>&2
return 4
fi
# obtain the abstract string
#
PATTERN='$..abstract'
if [[ $V_FLAG -ge 5 ]]; then
echo "$0: debug[5]: about to run: $JVAL_WRAPPER -b -q -- $ENTRY_JSON_PATH '$PATTERN' | sed ..." 1>&2
fi
"$JVAL_WRAPPER" -b -q "$ENTRY_JSON_PATH" "$PATTERN" | sed -f "$UNICODE_FIX_SED"
status="$?"
status_codes=("${PIPESTATUS[@]}")
if [[ ${status_codes[*]} =~ [1-9] ]]; then
echo "$0: ERROR: in output_abstract: $JVAL_WRAPPER -b -q -- $ENTRY_JSON_PATH '$PATTERN | sed ... failed," \
"error codes: ${status_codes[*]}" 1>&2
return 5
fi
return 0
}
# setup
#
export NOOP=
@@ -511,6 +563,16 @@ if [[ -z $AWARD ]]; then
fi
# determine abstract
#
ABSTRACT=$(output_abstract "$ENTRY_JSON")
export ABSTRACT
if [[ -z $ABSTRACT ]]; then
echo "$0: ERROR: cannot determine abstract for $YEAR_DIR from: $ENTRY_JSON" 1>&2
exit 1
fi
# parameter debugging
#
if [[ $V_FLAG -ge 3 ]]; then
@@ -546,6 +608,7 @@ if [[ $V_FLAG -ge 3 ]]; then
echo "$0: debug[3]: DOT_PATH_CONTENT=$DOT_PATH_CONTENT" 1>&2
echo "$0: debug[3]: ENTRY_NAVBAR_AWK=$ENTRY_NAVBAR_AWK" 1>&2
echo "$0: debug[3]: AWARD=$AWARD" 1>&2
echo "$0: debug[3]: ABSTRACT=$ABSTRACT" 1>&2
fi
@@ -583,6 +646,12 @@ echo "-s"
echo "HEADER_2=$YYYY_DIR - $AWARD"
# output HEADER_3 substitution
#
echo "-s"
echo "HEADER_3=$ABSTRACT"
# output navbar left hand side links
#
awk -v entry_path="$YYYY_DIR" -f "$ENTRY_NAVBAR_AWK" "$DOT_ALLYEAR"