Skip to content

Commit

Permalink
use jstrdecode -N w/o bin/jval-wrapper.sh -T
Browse files Browse the repository at this point in the history
We now use `jstrdecode -N` without the need for
using `-T` with `bin/jval-wrapper.sh`.

Now depending on `jstrdecode(1)` with a minimum version
of "1.2.3" (was "1.2.0").

Added information about bin tools missing from `bin/README.md`.

Changed `bin/entry2csv.sh` VERSION from "1.5 2024-10-08"
to "1.5.1 2024-10-10".

Changed `bin/gen-authors.sh` VERSION from "1.14 2024-10-08"
to "1.14.1 2024-10-10".

Changed `bin/gen-location.sh` VERSION from "1.8 2024-10-08"
to "1.8.1 2024-10-10".

Changed `bin/gen-years.sh` VERSION from "1.6 2024-10-08"
to "1.6.1 2024-10-10".

Changed `bin/output-index-author.sh` VERSION from "1.10 2024-10-08"
to "1.10.1 2024-10-10".

Changed `bin/output-year-index.sh` VERSION from "1.6 2024-10-08"
to "1.6.1 2024-10-10".

Changed `bin/subst.entry-index.sh` VERSION from "1.8 2024-10-08"
to "1.8.1 2024-10-10".

Perform `make all_jfmt` to format canoncailly, all `entry.json`
and all `author/author_handle.json` files.  A side effect of this
is to replace all of the fancy non-ASCII characters within
JSON strings with their "bashslash-u hex hex hex hex" equivalent.
Thanks to the newly fixed `jstrdecode(1)` tool, there was
no change in the HTML output.

Perform `make www` to perform the above and test under macOS.
  • Loading branch information
lcn2 committed Oct 10, 2024
1 parent bcc4c07 commit da0c000
Show file tree
Hide file tree
Showing 13 changed files with 171 additions and 42 deletions.
2 changes: 1 addition & 1 deletion 2000/bmeyer/.entry.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"OK_to_edit" : false,
"display_as" : "image",
"display_via_github" : false,
"entry_text" : "image of author’s godchild and nephew"
"entry_text" : "image of author\u2019s godchild and nephew"
},
{
"file_path" : "try.sh",
Expand Down
2 changes: 1 addition & 1 deletion 2020/kurdyukov4/.entry.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"no_comment" : "mandatory comment: because comments were removed from the original JSON spec",
"entry_JSON_format_version" : "1.2 2024-09-25",
"award" : "Best abuse of lámatyávë",
"award" : "Best abuse of l\u00e1maty\u00e1v\u00eb",
"year" : 2020,
"dir" : "kurdyukov4",
"entry_id" : "2020_kurdyukov4",
Expand Down
2 changes: 1 addition & 1 deletion author/Anton_Algmyr.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"no_comment" : "mandatory comment: because comments were removed from the original JSON spec",
"author_JSON_format_version" : "1.1 2024-02-11",
"author_handle" : "Anton_Algmyr",
"full_name" : "Anton Älgmyr",
"full_name" : "Anton \u00c4lgmyr",
"sort_word" : "algmyr",
"location_code" : "SE",
"email" : "algmyr@student.chalmers.se",
Expand Down
2 changes: 1 addition & 1 deletion author/Ondrej_Adamovsky.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"no_comment" : "mandatory comment: because comments were removed from the original JSON spec",
"author_JSON_format_version" : "1.1 2024-02-11",
"author_handle" : "Ondrej_Adamovsky",
"full_name" : "Ondřej Adamovský",
"full_name" : "Ond\u0159ej Adamovsk\u00fd",
"sort_word" : "adamovsky",
"location_code" : "CZ",
"email" : "oa@cmail.cz",
Expand Down
113 changes: 112 additions & 1 deletion bin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,44 @@ be directly invoked as well, should you wish to see their output or if you have
some odd need to do so.


<div id="all-jfmt">
### [all-jfmt.sh](%%REPO_URL%%/bin/all-jfmt.sh)
</div>

Canonically format all entry and author JSON files

Usage:

``` <!---sh-->
bin/all-jfmt.sh -v 3
```

Alternate usage:

``` <!---sh-->
make all_jfmt
```


<div id="all-years">
### [all-years.sh](%%REPO_URL%%/bin/all-years.sh)
</div>

Run a command on all IOCCC years.

Usage:

``` <!---sh-->
bin/all-years.sh -v 1 bin/gen-year-index.sh -v 1
```

Alternate usage:

``` <!---sh-->
bin/all-years.sh -v 1 bin/chk-entry.sh
```


<div id="all-run">
### [all-run.sh](%%REPO_URL%%/bin/all-run.sh)
</div>
Expand Down Expand Up @@ -137,6 +175,53 @@ the top level `Makefile`:
FAQ on "[.entry.json files](../faq.html#entry_json)"
for more details on `.entry.json` files.


<div id="combine-author-handle">
### [combine_author_handle.sh](%%REPO_URL%%/bin/combine_author_handle.sh)
</div>

Combine all author/author_handle.JSON files as single JSON file.

The purpose of this tool is to make looking for information across all
authors faster by temporarily forming them into a single JSON file.

Because `jsp(1)` open remembers the last copy of a given JSON member name.
As such, we change the JSON member name "winning_entry_set" into
a unique "winning_entry_set.FILENO" where FILENO is the file number.
This the JSON member value will be preserved across all files.

We also convert where FILENO is the file number and FILENAME is the filename:

``` <!---json-->
"sort_word" : "data",
```

into:

``` <!---json-->
"sort_word.FILENO" : [
{
"sort_word" : "data FILENAME"
}
],
```

This will allow `jsp(1)` to print sort_word values.

We also make sure that the last item from a given file ends in a comma (",)",
due to the bogosity of the so-called JSON spec.

Usage:

``` <!---sh-->
bin/combine_author_handle.sh > combined_author_handle.json
```

**NOTE**: This tool assume that all JSON files have been formatted with the
`bin/jprint-wrapper.sh` tool. In particular the first line is just "{:,
and the last line is just "}" and each JSON element is on its own line.


<div id="csv2entry">
### [csv2entry.sh](%%REPO_URL%%/bin/csv2entry.sh)
</div>
Expand Down Expand Up @@ -686,8 +771,33 @@ For example:
bin/jval-wrapper.sh -q -T author/Anton_Algmyr.json '$.full_name' | jstrdecode -
```

**NOTE**: With `jstrdecode(1)` version 1.2.3 or better, one can use `jstrdecode -N`
and not have to use `-T` with `bin/jval-wrapper.sh`.


<div id="manifest-csv-entry">
### [manifest.csv.entry.awk](%%REPO_URL%%/bin/manifest.csv.entry.awk)
</div>

Output manifest csv from a entry's manifest as found in its `.entry.json` file.

``` <!---sh-->
awk -f bin/manifest.csv.entry.awk YYYY/dir/.entry.json
```


<div id="md2html_cfg">
<div id="manifest-csv-json">
### [bin/manifest.entry.json.awk](%%REPO_URL%%/bin/manifest.entry.json.awk)
</div>

Output manifest table from a entry's `.entry.json` file.

``` <!---sh-->
awk -v github=REPO_URL -f bin/manifest.entry.json.awk YYYY/dir/.entry.json
```


<div id="md2html-cfg">
### [md2html.cfg](%%REPO_URL%%/bin/md2html.cfg)
</div>

Expand Down Expand Up @@ -722,6 +832,7 @@ markdown files) and HTML fragments from the [inc directory](../inc/index.html).
The [md2html.cfg](index.html#md2html_cfg) configuration file is
used by [md2html.sh](%%REPO_URL%%/bin/md2html.sh) to drive the generation process.


<div id="new-dir">
### [new-dir.sh](%%REPO_URL%%/bin/new-dir.sh)
</div>
Expand Down
16 changes: 8 additions & 8 deletions bin/entry2csv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.5 2024-10-08"
export VERSION="1.5.1 2024-10-10"
NAME=$(basename "$0")
export NAME
export V_FLAG=0
Expand Down Expand Up @@ -156,7 +156,7 @@ if [[ -z $JSTRDECODE ]]; then
echo "$0: notice: then: cd jparse && sudo make install clobber" 1>&2
exit 5
fi
export MIN_JSTRDECODE_VERSION="1.2.0"
export MIN_JSTRDECODE_VERSION="1.2.3"
JSTRDECODE_VERSION=$("$JSTRDECODE" -V | head -1 | awk '{print $3;}')
if ! "$VERGE" "$JSTRDECODE_VERSION" "$MIN_JSTRDECODE_VERSION"; then
echo "$0: FATAL: jstrdecode version: $JSTRDECODE_VERSION < minimum version: $MIN_JSTRDECODE_VERSION" 1>&2
Expand Down Expand Up @@ -218,12 +218,12 @@ function output_award
#
PATTERN='$..award'
if [[ $V_FLAG -ge 5 ]]; then
echo "$0: debug[5]: about to run: $JVAL_WRAPPER -b -q -T -- $ENTRY_JSON_PATH '$PATTERN' | $JSTRDECODE -" 1>&2
echo "$0: debug[5]: about to run: $JVAL_WRAPPER -b -q -- $ENTRY_JSON_PATH '$PATTERN' | $JSTRDECODE -N -" 1>&2
fi
"$JVAL_WRAPPER" -b -q -T "$ENTRY_JSON_PATH" "$PATTERN" | "$JSTRDECODE" -
"$JVAL_WRAPPER" -b -q "$ENTRY_JSON_PATH" "$PATTERN" | "$JSTRDECODE" -N -
status_codes=("${PIPESTATUS[@]}")
if [[ ${status_codes[*]} =~ [1-9] ]]; then
echo "$0: ERROR: in output_award: $JVAL_WRAPPER -b -q -T -- $ENTRY_JSON_PATH '$PATTERN' | $JSTRDECODE - failed," \
echo "$0: ERROR: in output_award: $JVAL_WRAPPER -b -q -- $ENTRY_JSON_PATH '$PATTERN' | $JSTRDECODE -N - failed," \
"error codes: ${status_codes[*]}" 1>&2
return 5
fi
Expand Down Expand Up @@ -378,13 +378,13 @@ function output_abstract
#
PATTERN='$..abstract'
if [[ $V_FLAG -ge 5 ]]; then
echo "$0: debug[5]: about to run: $JVAL_WRAPPER -b -q -T -- $ENTRY_JSON_PATH '$PATTERN' | $JSTRDECODE -" 1>&2
echo "$0: debug[5]: about to run: $JVAL_WRAPPER -b -q -- $ENTRY_JSON_PATH '$PATTERN' | $JSTRDECODE -N -" 1>&2
fi
export ABSTRACT
ABSTRACT=$("$JVAL_WRAPPER" -b -q -T "$ENTRY_JSON_PATH" "$PATTERN" | "$JSTRDECODE" -)
ABSTRACT=$("$JVAL_WRAPPER" -b -q "$ENTRY_JSON_PATH" "$PATTERN" | "$JSTRDECODE" -N -)
status_codes=("${PIPESTATUS[@]}")
if [[ ${status_codes[*]} =~ [1-9] || -z $ABSTRACT ]]; then
echo "$0: ERROR: in output_abstract: $JVAL_WRAPPER -b -q -T -- $ENTRY_JSON_PATH '$PATTERN' | $JSTRDECODE - failed," \
echo "$0: ERROR: in output_abstract: $JVAL_WRAPPER -b -q -- $ENTRY_JSON_PATH '$PATTERN' | $JSTRDECODE -N - failed," \
"error codes: ${status_codes[*]}" 1>&2
return 5
fi
Expand Down
10 changes: 5 additions & 5 deletions bin/gen-authors.sh
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,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.14 2024-10-08"
export VERSION="1.14.1 2024-10-10"
NAME=$(basename "$0")
export NAME
export V_FLAG=0
Expand Down Expand Up @@ -126,7 +126,7 @@ if [[ -z $JSTRDECODE ]]; then
echo "$0: notice: then: cd jparse && sudo make install clobber" 1>&2
exit 5
fi
export MIN_JSTRDECODE_VERSION="1.2.0"
export MIN_JSTRDECODE_VERSION="1.2.3"
JSTRDECODE_VERSION=$("$JSTRDECODE" -V | head -1 | awk '{print $3;}')
if ! "$VERGE" "$JSTRDECODE_VERSION" "$MIN_JSTRDECODE_VERSION"; then
echo "$0: FATAL: jstrdecode version: $JSTRDECODE_VERSION < minimum version: $MIN_JSTRDECODE_VERSION" 1>&2
Expand Down Expand Up @@ -273,12 +273,12 @@ function output_award
#
PATTERN='$..award'
if [[ $V_FLAG -ge 5 ]]; then
echo "$0: debug[5]: about to run: $JVAL_WRAPPER -b -q -T -- $ENTRY_JSON_PATH '$PATTERN' | $JSTRDECODE -" 1>&2
echo "$0: debug[5]: about to run: $JVAL_WRAPPER -b -q -- $ENTRY_JSON_PATH '$PATTERN' | $JSTRDECODE -N -" 1>&2
fi
"$JVAL_WRAPPER" -b -q -T "$ENTRY_JSON_PATH" "$PATTERN" | "$JSTRDECODE" -
"$JVAL_WRAPPER" -b -q "$ENTRY_JSON_PATH" "$PATTERN" | "$JSTRDECODE" -N -
status_codes=("${PIPESTATUS[@]}")
if [[ ${status_codes[*]} =~ [1-9] ]]; then
echo "$0: ERROR: in output_award: $JVAL_WRAPPER -b -q -T -- $ENTRY_JSON_PATH '$PATTERN' | $JSTRDECODE - failed," \
echo "$0: ERROR: in output_award: $JVAL_WRAPPER -b -q -- $ENTRY_JSON_PATH '$PATTERN' | $JSTRDECODE -N - failed," \
"error codes: ${status_codes[*]}" 1>&2
return 5
fi
Expand Down
6 changes: 3 additions & 3 deletions bin/gen-location.sh
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,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.8 2024-10-08"
export VERSION="1.8.1 2024-10-10"
NAME=$(basename "$0")
export NAME
export V_FLAG=0
Expand Down Expand Up @@ -123,7 +123,7 @@ if [[ -z $JSTRDECODE ]]; then
echo "$0: notice: then: cd jparse && sudo make install clobber" 1>&2
exit 5
fi
export MIN_JSTRDECODE_VERSION="1.2.0"
export MIN_JSTRDECODE_VERSION="1.2.3"
JSTRDECODE_VERSION=$("$JSTRDECODE" -V | head -1 | awk '{print $3;}')
if ! "$VERGE" "$JSTRDECODE_VERSION" "$MIN_JSTRDECODE_VERSION"; then
echo "$0: FATAL: jstrdecode version: $JSTRDECODE_VERSION < minimum version: $MIN_JSTRDECODE_VERSION" 1>&2
Expand Down Expand Up @@ -593,7 +593,7 @@ find "$AUTHOR_DIR" -mindepth 1 -maxdepth 1 -type f -name '*.json' -print |
# obtain the author full name
#
PATTERN='$..full_name'
FULL_NAME=$("$JVAL_WRAPPER" -b -q -T "$AUTHOR_HANDLE_JSON" "$PATTERN" | "$JSTRDECODE" -)
FULL_NAME=$("$JVAL_WRAPPER" -b -q "$AUTHOR_HANDLE_JSON" "$PATTERN" | "$JSTRDECODE" -N -)
status_codes=("${PIPESTATUS[@]}")
if [[ ${status_codes[*]} =~ [1-9] || -z $FULL_NAME ]]; then
echo "$0: ERROR: cannot full name from: $AUTHOR_HANDLE" 1>&2
Expand Down
6 changes: 3 additions & 3 deletions bin/gen-years.sh
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,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-10-08"
export VERSION="1.6.1 2024-10-10"
NAME=$(basename "$0")
export NAME
export V_FLAG=0
Expand Down Expand Up @@ -126,7 +126,7 @@ if [[ -z $JSTRDECODE ]]; then
echo "$0: notice: then: cd jparse && sudo make install clobber" 1>&2
exit 5
fi
export MIN_JSTRDECODE_VERSION="1.2.0"
export MIN_JSTRDECODE_VERSION="1.2.3"
JSTRDECODE_VERSION=$("$JSTRDECODE" -V | head -1 | awk '{print $3;}')
if ! "$VERGE" "$JSTRDECODE_VERSION" "$MIN_JSTRDECODE_VERSION"; then
echo "$0: FATAL: jstrdecode version: $JSTRDECODE_VERSION < minimum version: $MIN_JSTRDECODE_VERSION" 1>&2
Expand Down Expand Up @@ -247,7 +247,7 @@ function output_award
# obtain the award string
#
PATTERN='$..award'
AWARD_STRING=$("$JVAL_WRAPPER" -b -q -T "$ENTRY_JSON_PATH" "$PATTERN" | "$JSTRDECODE" -)
AWARD_STRING=$("$JVAL_WRAPPER" -b -q "$ENTRY_JSON_PATH" "$PATTERN" | "$JSTRDECODE" -N -)
status_codes=("${PIPESTATUS[@]}")
if [[ ${status_codes[*]} =~ [1-9] || -z $AWARD_STRING ]]; then
echo "$0: ERROR: in output_award: no award found in .entry.json file: $ENTRY_JSON_PATH" 1>&2
Expand Down
20 changes: 19 additions & 1 deletion bin/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,22 @@ <h3 id="other-notes-about-some-of-the-common-options">Other notes about some of
<a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/bin/md2html.cfg">bin/md2html.cfg</a> file but some of these tools can
be directly invoked as well, should you wish to see their output or if you have
some odd need to do so.</p>
<div id="all-jfmt">
<h3 id="all-jfmt.sh"><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/bin/all-jfmt.sh">all-jfmt.sh</a></h3>
</div>
<p>canonically format all entry and author JSON files</p>
<p>Usage:</p>
<pre><code> bin/all-jfmt.sh -v 3</code></pre>
<p>Alternate usage:</p>
<pre><code> make all_jfmt</code></pre>
<div id="all-years">
<h3 id="all-years.sh"><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/bin/all-years.sh">all-years.sh</a></h3>
</div>
<p>Run a command on all IOCCC years.</p>
<p>Usage:</p>
<pre><code> bin/all-years.sh -v 1 bin/gen-year-index.sh -v 1</code></pre>
<p>Alternate usage:</p>
<pre><code> bin/all-years.sh -v 1 bin/chk-entry.sh</code></pre>
<div id="all-run">
<h3 id="all-run.sh"><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/bin/all-run.sh">all-run.sh</a></h3>
</div>
Expand All @@ -442,7 +458,7 @@ <h3 id="all-run.sh"><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/m
<p>Alternate usage:</p>
<pre><code> bin/all-run.sh -v 3 bin/readme2index.sh -v 1</code></pre>
<div id="all-years">
<h3 id="all-years.sh"><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/bin/all-years.sh">all-years.sh</a></h3>
<h3 id="all-years.sh-1"><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/bin/all-years.sh">all-years.sh</a></h3>
</div>
<p>Run a command on all IOCCC years.</p>
<p>Usage:</p>
Expand Down Expand Up @@ -793,6 +809,8 @@ <h3 id="jval-wrapper.sh"><a href="https://github.com/ioccc-src/temp-test-ioccc/b

bin/jval-wrapper.sh author/Anton_Algmyr.json &#39;$.full_name&#39;
bin/jval-wrapper.sh -q -T author/Anton_Algmyr.json &#39;$.full_name&#39; | jstrdecode -</code></pre>
<p><strong>NOTE</strong>: With <code>jstrdecode(1)</code> version 1.2.3 or better, one can use <code>jstrdecode -N</code>
and not have to use <code>-T</code> with <code>bin/jval-wrapper.sh</code>.</p>
<div id="md2html_cfg">
<h3 id="md2html.cfg"><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/bin/md2html.cfg">md2html.cfg</a></h3>
</div>
Expand Down
8 changes: 4 additions & 4 deletions bin/output-index-author.sh
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,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.10 2024-10-08"
export VERSION="1.10.1 2024-10-10"
NAME=$(basename "$0")
export NAME
export V_FLAG=0
Expand Down Expand Up @@ -142,7 +142,7 @@ if [[ -z $JSTRDECODE ]]; then
echo "$0: notice: then: cd jparse && sudo make install clobber" 1>&2
exit 5
fi
export MIN_JSTRDECODE_VERSION="1.2.0"
export MIN_JSTRDECODE_VERSION="1.2.3"
JSTRDECODE_VERSION=$("$JSTRDECODE" -V | head -1 | awk '{print $3;}')
if ! "$VERGE" "$JSTRDECODE_VERSION" "$MIN_JSTRDECODE_VERSION"; then
echo "$0: FATAL: jstrdecode version: $JSTRDECODE_VERSION < minimum version: $MIN_JSTRDECODE_VERSION" 1>&2
Expand Down Expand Up @@ -345,10 +345,10 @@ function output_full_name
# extract Full Name from the author/author_handle.json file
#
PATTERN='$..full_name'
"$JVAL_WRAPPER" -b -q -T "$AUTHOR_HANDLE_JSON_PATH" "$PATTERN" | "$JSTRDECODE" -
"$JVAL_WRAPPER" -b -q "$AUTHOR_HANDLE_JSON_PATH" "$PATTERN" | "$JSTRDECODE" -N -
status_codes=("${PIPESTATUS[@]}")
if [[ ${status_codes[*]} =~ [1-9] ]]; then
echo "$0: ERROR: in output_full_name: $JVAL_WRAPPER -b -q $AUTHOR_HANDLE_JSON_PATH '$PATTERN' failed," \
echo "$0: ERROR: in output_full_name: $JVAL_WRAPPER -b -q $AUTHOR_HANDLE_JSON_PATH '$PATTERN' | $JSTRDECODE -N - failed," \
"error codes: ${status_codes[*]}" 1>&2
return 5
fi
Expand Down
Loading

0 comments on commit da0c000

Please sign in to comment.