diff --git a/Show_Submission/copy_shownotes b/Show_Submission/copy_shownotes index 742bd11..da92a44 100755 --- a/Show_Submission/copy_shownotes +++ b/Show_Submission/copy_shownotes @@ -18,7 +18,7 @@ # AUTHOR: Dave Morriss (djm), Dave.Morriss@gmail.com # VERSION: 0.0.10 # CREATED: 2015-09-16 21:51:15 -# REVISION: 2023-07-01 22:48:53 +# REVISION: 2024-06-18 20:42:17 # #=============================================================================== @@ -29,9 +29,9 @@ SCRIPT=${0##*/} # # Load library functions # -LIB="$HOME/bin/function_lib.sh" +LIB="$HOME/HPR/function_lib.sh" [ -e "$LIB" ] || { echo "$SCRIPT: Unable to source functions"; exit 1; } -# shellcheck source=/home/cendjm/bin/function_lib.sh +# shellcheck source=/home/cendjm/HPR/function_lib.sh source "$LIB" # diff --git a/Show_Submission/do_brave b/Show_Submission/do_brave index aa0f53f..8ad0759 100755 --- a/Show_Submission/do_brave +++ b/Show_Submission/do_brave @@ -19,10 +19,17 @@ # 2022-12-22: We now write state changes to the file .status in # the show directory, so we need to do that here too. Also # changed to using the function library for cleanup_temp. +# 2024-10-17: Changed the logic around 'hpr????_full.html' by +# using a TT² template to enclose the usual HTML fragment in +# enough HTML to make it standalone. We have to get values from +# 'shownotes.json' and paass them into 'tpage' to do this, and +# the end result is not the same as the one generated by +# 'do_pandoc'. The result looks better than using the HTML +# fragment. # AUTHOR: Dave Morriss (djm), Dave.Morriss@gmail.com -# VERSION: 0.0.5 +# VERSION: 0.0.6 # CREATED: 2016-03-20 15:22:29 -# REVISION: 2022-12-22 17:28:12 +# REVISION: 2024-10-17 19:33:42 # #=============================================================================== @@ -47,18 +54,29 @@ if [[ $# -ne 1 ]]; then exit 1 fi +epno="${1}" + # # Directories and files # BASENAME="$HOME/HPR/Show_Submission" -SHOWDIR="$BASENAME/shownotes/hpr${1}" -RAWNOTES="$SHOWDIR/hpr${1}.out" -HTML="$SHOWDIR/hpr${1}.html" -FULLHTML="$SHOWDIR/hpr${1}_full.html" +SHOWDIR="$BASENAME/shownotes/hpr${epno}" +RAWNOTES="$SHOWDIR/hpr${epno}.out" +HTML="$SHOWDIR/hpr${epno}.html" +FULLHTML="$SHOWDIR/hpr${epno}_full.html" +SHOWNOTES="$SHOWDIR/shownotes.json" STATUSFILE="$SHOWDIR/.status" +FORMATFILE="$SHOWDIR/.format" +FORMAT="$(cat "$FORMATFILE")" HTMLFILE="$FULLHTML" +# +# Check we have this template +# +FULLTPL="$BASENAME/make_fullnotes.tpl" +[[ -e $FULLTPL ]] || { echo "Unable to find template $FULLTPL"; exit 1; } + # # Check we have this browser # @@ -66,28 +84,57 @@ BRAVE=$(command -v brave-browser) [[ -v BRAVE ]] || { echo "Problem finding the Brave browser"; exit 1; } # -# We prefer to view the 'full' html which we do by default. If not found -# (because the host sent in HTML themselves) we look for hpr????.html, which -# is a link to the notes from the form (hpr????.out), and view that. If the -# link didn't get created (not sure why) we copy the "raw" notes to -# a temporary file with an '.html' extension (TODO: we could just make a link -# here). Otherwise we found nothing viewable. +# Taking a different approach with the 'full' html. If the format is known to +# be 'html5' there will not be one the first time we run this script. We will +# make 'hpr????_full.html' by enclosing the HTML "fragment" in 'hpr????.html' +# in a TT² template with HTML header and footer. # -if [[ ! -e $FULLHTML ]]; then - if [[ -e $HTML ]]; then - echo "No full HTML found, viewing $HTML instead" - HTMLFILE="$HTML" - elif [[ -e $RAWNOTES ]]; then - echo "No files with ''.HTML' suffix, viewing raw notes" +if [[ $FORMAT = 'html5' ]]; then + # + # Extract the fields we want from the JSON and make them Bash variables + # + declare _author _title _summary # Declare them for shellcheck + jqprog='@sh "_author=\(.host.Host_Name) ' + jqprog+='_title=\(.episode.Title) ' + jqprog+='_summary=\(.episode.Summary)"' + eval "$(jq -r "$jqprog" "$SHOWNOTES")" - TMP1=$(mktemp '/tmp/notes_XXXXXX.html') || { echo "$SCRIPT: creation of temporary file failed!"; exit 1; } - trap 'cleanup_temp $TMP1' SIGHUP SIGINT SIGPIPE SIGTERM EXIT + # + # Feed the variables to the template to make the full HTML + # + tpage --define author="$_author" \ + --define title="$_title" \ + --define summary="$_summary" \ + --define body="$HTML" \ + "$FULLTPL" > "$FULLHTML" +else + # + # See above for how we make the 'full' notes if the host sent in HTML + # notes. Here we have received notes that use one of the excepted markup + # formats or are plain text (≡ Pandoc Markdown). + # + # If the 'full' HTML is not found (for unknown reasons) we look for + # hpr????.html, which is a link to the notes from the form (hpr????.out), + # and view that. If the link didn't get created (not sure why) we copy the + # "raw" notes to a temporary file with an '.html' extension (TODO: we + # could just make a link here). Otherwise we found nothing viewable. + # + if [[ ! -e $FULLHTML ]]; then + if [[ -e $HTML ]]; then + echo "No full HTML found, viewing $HTML instead" + HTMLFILE="$HTML" + elif [[ -e $RAWNOTES ]]; then + echo "No files with ''.HTML' suffix, viewing raw notes" - cp "$RAWNOTES" "$TMP1" - HTMLFILE="$TMP1" - else - echo "Nothing to view, giving up" - exit + TMP1=$(mktemp '/tmp/notes_XXXXXX.html') || { echo "$SCRIPT: creation of temporary file failed!"; exit 1; } + trap 'cleanup_temp $TMP1' SIGHUP SIGINT SIGPIPE SIGTERM EXIT + + cp "$RAWNOTES" "$TMP1" + HTMLFILE="$TMP1" + else + echo "Nothing to view, giving up" + exit + fi fi fi diff --git a/Show_Submission/do_index b/Show_Submission/do_index index 9795db4..ec25607 100755 --- a/Show_Submission/do_index +++ b/Show_Submission/do_index @@ -1,4 +1,4 @@ -#!/bin/bash - +#!/bin/bash - #=============================================================================== # # FILE: do_index @@ -11,11 +11,11 @@ # OPTIONS: --- # REQUIREMENTS: --- # BUGS: --- -# NOTES: --- +# NOTES: [[ Probably obsolete! ]] # AUTHOR: Dave Morriss (djm), Dave.Morriss@gmail.com # VERSION: 0.0.5 # CREATED: 2022-10-30 15:39:28 -# REVISION: 2022-12-17 17:38:00 +# REVISION: 2024-06-18 20:28:55 # #=============================================================================== @@ -31,9 +31,9 @@ STDOUT="/dev/fd/2" # # Load library functions (make_file_list, range_parse, cleanup_temp) # -LIB="$HOME/bin/function_lib.sh" +LIB="$HOME/HPR/function_lib.sh" [ -e "$LIB" ] || { echo "$SCRIPT: Unable to source functions"; exit 1; } -# shellcheck source=/home/cendjm/bin/function_lib.sh +# shellcheck source=/home/cendjm/HPR/function_lib.sh source "$LIB" # diff --git a/Show_Submission/do_pandoc b/Show_Submission/do_pandoc index 997b347..b62a9de 100755 --- a/Show_Submission/do_pandoc +++ b/Show_Submission/do_pandoc @@ -37,9 +37,9 @@ # careful about collisions. # # AUTHOR: Dave Morriss (djm), Dave.Morriss@gmail.com -# VERSION: 0.2.10 +# VERSION: 0.2.11 # CREATED: 2016-08-16 15:34:30 -# REVISION: 2024-02-18 13:27:40 +# REVISION: 2024-10-18 23:03:25 # #=============================================================================== @@ -48,16 +48,16 @@ set -o nounset # Treat unset variables as an error SCRIPT=${0##*/} #DIR=${0%/*} -VERSION='0.2.10' +VERSION='0.2.11' STDOUT="/dev/fd/2" # # Load library functions # -LIB="$HOME/bin/function_lib.sh" +LIB="$HOME/HPR/function_lib.sh" [ -e "$LIB" ] || { echo "$SCRIPT: Unable to source functions"; exit 1; } -# shellcheck source=/home/cendjm/bin/function_lib.sh +# shellcheck source=/home/cendjm/HPR/function_lib.sh source "$LIB" # @@ -65,7 +65,7 @@ source "$LIB" # define_colours -# {{{ Functions: -- _usage -- _DEBUG -- +# {{{ Functions: -- _usage -- #=== FUNCTION ================================================================ # NAME: _usage # DESCRIPTION: Report usage @@ -102,19 +102,6 @@ Examples endusage exit } - -#=== FUNCTION ================================================================ -# NAME: _DEBUG -# DESCRIPTION: Writes one or more message lines if in DEBUG mode -# PARAMETERS: List of messages -# RETURNS: Nothing -#=============================================================================== -_DEBUG () { - [ "$DEBUG" == 0 ] && return - for msg in "$@"; do - printf 'D> %s\n' "$msg" - done -} # }}} #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -168,8 +155,8 @@ options[txt2tags]='' # # Sanity checks # -JQ=$(command -v jq) -[ -n "$JQ" ] || { echo "Program 'jq' was not found"; exit 1; } +# JQ=$(command -v jq) +# [ -n "$JQ" ] || { echo "Program 'jq' was not found"; exit 1; } # YQ=$(command -v yq) # [ -n "$YQ" ] || { echo "Program 'yq' was not found"; exit 1; } @@ -235,7 +222,7 @@ trap 'cleanup_temp $TMP1 $TMP2 $TMP3' SIGHUP SIGINT SIGPIPE SIGTERM EXIT # Main directory BASENAME="$HOME/HPR/Show_Submission" -# JSON to YAML Perl script +# JSON to YAML Perl script - sanity check J2Y="$BASENAME/author_title.pl" [ -e "$J2Y" ] || { echo "Program '$J2Y' was not found"; exit 1; } @@ -303,19 +290,23 @@ BASEURL='https://hackerpublicradio.org/eps/' # needed for Pandoc # # Non-YAML alternative - not chosen -#jqprog="@text \"author: \(.host.Host_Name)\ntitle: \(.episode.Title)\"" +# jqprog="@text \"author: \(.host.Host_Name)\ntitle: \(.episode.Title)\"" # # Testing another formatter (Journal 2023-03-03) -#jqprog="@sh \"---\nauthor: \(.host.Host_Name)\ntitle: \(.episode.Title)\n---\"" +# jqprog="@sh \"---\nauthor: \(.host.Host_Name)\ntitle: \(.episode.Title)\n---\"" # Added quotes around the generated strings (2023-03-31) # jqprog="@text \"---\nauthor: \(.host.Host_Name)\ntitle: \(.episode.Title)\n---\"" +# # Moved to 'yq' 2023-04-01 # jqprog="@text \"---\nauthor: '\(.host.Host_Name)'\ntitle: '\(.episode.Title)'\n---\"" # jq -r "$jqprog" "$JSONFILE" > "$TMP1" +# # On 2023-10-01 wrote a Perl JSON to YAML generator just for these two # elements. It's called 'author_title.pl' +# # yqprog='{author:.host.Host_Name,title:.episode.Title}' # ( echo "---"; $YQ -y "$yqprog" "$JSONFILE"; echo "---"; ) > "$TMP1" +# $J2Y "$JSONFILE" "$TMP1" _DEBUG "YAML:" "$(cat "$TMP1")" @@ -497,7 +488,7 @@ if [[ $DRYRUN -eq 0 ]]; then # # shellcheck disable=SC2086 pandoc -f ${FROM}${POPTIONS} -t html5 --ascii \ - --standalone --template=hpr.html5 --no-highlight \ + --standalone --template=hpr_dev.html5 --no-highlight \ -c https://hackerpublicradio.org/css/hpr.css \ --metadata-file="$TMP1" -o "$FULLHTML" "$TMP3" RES=$? diff --git a/Show_Submission/do_parse b/Show_Submission/do_parse index 47f5758..98a02c7 100755 --- a/Show_Submission/do_parse +++ b/Show_Submission/do_parse @@ -124,6 +124,7 @@ fi # # $PARSER -novalid -ep "${show}" -in "$FROM" -show "$TOTPL" \ # -json "$JSONTPL" -format="$FMT" +# $PARSER -ep "${show}" -in "$FROM" -show "$TOTPL" \ -format="$FMT" -release="$REL" -pictures="$PICTURES" -assets="$ASSETS" \ -zip="$ZIP" diff --git a/Show_Submission/do_pictures b/Show_Submission/do_pictures index b614121..a3b931a 100755 --- a/Show_Submission/do_pictures +++ b/Show_Submission/do_pictures @@ -60,9 +60,9 @@ # BUGS: --- # NOTES: --- # AUTHOR: Dave Morriss (djm), Dave.Morriss@gmail.com -# VERSION: 0.2.3 +# VERSION: 0.2.4 # CREATED: 2020-05-25 13:20:18 -# REVISION: 2024-02-22 14:32:03 +# REVISION: 2024-07-25 21:39:16 # #=============================================================================== @@ -71,16 +71,16 @@ set -o nounset # Treat unset variables as an error SCRIPT=${0##*/} # DIR=${0%/*} -VERSION="0.2.3" +VERSION="0.2.4" STDOUT="/dev/fd/2" # # Load library functions (make_file_list, range_parse, cleanup_temp) # -LIB="$HOME/bin/function_lib.sh" +LIB="$HOME/HPR/function_lib.sh" [ -e "$LIB" ] || { echo "$SCRIPT: Unable to source functions"; exit 1; } -# shellcheck source=/home/cendjm/bin/function_lib.sh +# shellcheck source=/home/cendjm/HPR/function_lib.sh source "$LIB" # @@ -88,7 +88,7 @@ source "$LIB" # define_colours -# {{{ -- _usage -- +# {{{ -- _usage - _silent -- _dryrun -- #=== FUNCTION ================================================================ # NAME: _usage # DESCRIPTION: Report usage @@ -150,9 +150,7 @@ Examples endusage exit } -# }}} -# {{{ -- _silent -- _dryrun -- _DEBUG -- #=== FUNCTION ================================================================ # NAME: _silent # DESCRIPTION: Output a message unless we're being silent @@ -179,19 +177,6 @@ _dryrun () { prefix= done } - -#=== FUNCTION ================================================================ -# NAME: _DEBUG -# DESCRIPTION: Writes one or more message lines if in DEBUG mode -# PARAMETERS: List of messages -# RETURNS: Nothing -#=============================================================================== -_DEBUG () { - [ "$DEBUG" == 0 ] && return - for msg in "$@"; do - printf 'D> %s\n' "$msg" - done -} # }}} #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -229,12 +214,25 @@ if [[ $# -ne 1 ]]; then echo "${red}Missing shownumber argument${reset}" _usage fi +epno="${1}" + +# +# Ensure item spec is correctly formatted. Have to cater for leading zeroes +# being interpreted as octal. +# +if [[ $epno =~ ^(hpr)?([0-9]+)$ ]]; then + epno="$((10#${BASH_REMATCH[-1]}))" +else + coloured 'red' "Incorrect show specification: $epno" + coloured 'yellow' "Use 'hpr9999' or '9999' formats" + exit 1 +fi # # Paths to files # BASEDIR="$HOME/HPR/Show_Submission" -SHOWDIR="$BASEDIR/shownotes/hpr${1}" +SHOWDIR="$BASEDIR/shownotes/hpr${epno}" # RAWFILE="$SHOWDIR/shownotes.txt" JSONFILE="$SHOWDIR/shownotes.json" PICDIR="$SHOWDIR/uploads" diff --git a/Show_Submission/do_report b/Show_Submission/do_report index 9ad71b5..bad7d22 100755 --- a/Show_Submission/do_report +++ b/Show_Submission/do_report @@ -15,7 +15,7 @@ # AUTHOR: Dave Morriss (djm), Dave.Morriss@gmail.com # VERSION: 0.0.8 # CREATED: 2022-09-07 15:27:29 -# REVISION: 2023-06-01 17:58:09 +# REVISION: 2024-06-18 20:13:46 # #=============================================================================== @@ -32,9 +32,9 @@ STDOUT="/dev/fd/2" # # Load library functions # -LIB="$HOME/bin/function_lib.sh" +LIB="$HOME/HPR/function_lib.sh" [ -e "$LIB" ] || { echo "$SCRIPT: Unable to source functions"; exit 1; } -# shellcheck source=/home/cendjm/bin/function_lib.sh +# shellcheck source=/home/cendjm/HPR/function_lib.sh source "$LIB" # @@ -42,7 +42,7 @@ source "$LIB" # define_colours -#{{{ Functions: --- _usage --- _DEBUG --- _verbose --- _silent --- +#{{{ Functions: --- _usage --- _verbose --- _silent --- #=== FUNCTION ================================================================ # NAME: _usage # DESCRIPTION: Report usage @@ -77,22 +77,6 @@ endusage exit } -#=== FUNCTION ================================================================ -# NAME: _DEBUG -# DESCRIPTION: Writes one or more messages if in DEBUG mode. Each argument is -# seen as a message and is written on a separate line. -# References the global variable 'DEBUG' which is expected to be -# True if debug output is wanted. -# PARAMETERS: List of messages -# RETURNS: Nothing -#=============================================================================== -_DEBUG () { - [ "$DEBUG" == 0 ] && return - for msg in "$@"; do - printf 'D> %s\n' "$msg" - done -} - #=== FUNCTION ================================================================ # NAME: _verbose # DESCRIPTION: Writes a message in verbose mode diff --git a/Show_Submission/do_update_reservations b/Show_Submission/do_update_reservations index 68f1b4e..ffbf068 100755 --- a/Show_Submission/do_update_reservations +++ b/Show_Submission/do_update_reservations @@ -15,7 +15,7 @@ # AUTHOR: Dave Morriss (djm), Dave.Morriss@gmail.com # VERSION: 0.0.6 # CREATED: 2022-04-11 09:36:21 -# REVISION: 2023-06-14 23:24:42 +# REVISION: 2024-06-18 20:16:19 # #=============================================================================== @@ -32,9 +32,9 @@ STDOUT="/dev/fd/2" # # Load library functions # -LIB="$HOME/bin/function_lib.sh" +LIB="$HOME/HPR/function_lib.sh" [ -e "$LIB" ] || { echo "$SCRIPT: Unable to source functions"; exit 1; } -# shellcheck source=/home/cendjm/bin/function_lib.sh +# shellcheck source=/home/cendjm/HPR/function_lib.sh source "$LIB" # diff --git a/Show_Submission/fix_relative_links b/Show_Submission/fix_relative_links index 0cff9a8..d91eca5 100755 --- a/Show_Submission/fix_relative_links +++ b/Show_Submission/fix_relative_links @@ -25,8 +25,7 @@ use v5.16; use strict; use warnings; use utf8; -use feature qw{ postderef say signatures state }; -no warnings qw{ experimental::postderef experimental::signatures }; +use feature qw{ say state }; use Carp; use Getopt::Long; @@ -605,7 +604,7 @@ base URL described below. =item B<-baseURL=URL> -This option will default to the foillowing URL if not provided: +This option will default to the following URL if not provided: https://hackerpublicradio.org/eps/hpr${show}/ diff --git a/Show_Submission/parse_JSON b/Show_Submission/parse_JSON index 6dfb1ad..8a3bf57 100755 --- a/Show_Submission/parse_JSON +++ b/Show_Submission/parse_JSON @@ -21,14 +21,17 @@ # BUGS: --- # NOTES: --- # AUTHOR: Dave Morriss (djm), Dave.Morriss@gmail.com -# VERSION: 0.0.14 +# VERSION: 0.0.17 # CREATED: 2020-11-28 10:52:02 -# REVISION: 2024-03-09 20:34:54 +# REVISION: 2024-10-04 18:37:29 # #=============================================================================== -use 5.30.0; +use v5.36; use utf8; +use feature qw{ postderef say signatures state try }; +no warnings + qw{ experimental::postderef experimental::signatures experimental::try }; use Getopt::Long; use Pod::Usage; @@ -57,7 +60,7 @@ use Data::Dumper; # # Version number (manually incremented) # -our $VERSION = '0.0.14'; +our $VERSION = '0.0.17'; # # Script and directory names @@ -79,7 +82,12 @@ my $logfile = "$logdir/${PROG}.log"; my ( $snlevel, $showno, $summarylength, $notelength ); our $MARKUP_DETECTED = 0; + +# +# Maximum and minimum number of characters (bytes) +# my $MAXNOTELEN = 4000; +my $MINNOTELEN = 10; # # Printing: general output format @@ -223,13 +231,14 @@ my @markup_types = ( my @markup_found; my $markup_choice; -my ( $showdir, $assetdir , $statusfile ); +my ( $showdir, $assetdir, $statusfile ); my ( %media_files, $media_files ); my ( %assets, @assets, @audio, $sanitised ); my ( $has_audio, $has_extra, $has_archives ); my ( @archives, @extracted ); my ( $astate, $has_pictures, @pictures, $pictures ); -my ( %spellchecks ); +my ( $has_markup, @markup, $markup ); +my ( $json_change, @json_changes, %spellchecks ); my @pstates = ( 'No pictures found', # 0 'Pictures that need management', # 1 @@ -347,8 +356,13 @@ open( my $fh, '<:encoding(UTF-8)', $infile ); my $json_text = <$fh>; close($fh); -# TODO: bad JSON can crash the script here! -my $content = decode_json($json_text); +my $content; +try { + $content = decode_json($json_text); +} +catch ($e) { + die colored( "Failed to decode the JSON in $infile", 'red' ) . "\n" +} $log->info( $showno, "[$VERSION] Processing $infile" ); @@ -372,6 +386,19 @@ print STDERR '-' x 80, "\n"; printf STDERR $ofmt, "Show:", $content->{metadata}{Episode_Number}; printf STDERR $ofmt, "Date:", $content->{metadata}{Episode_Date}; +# +# Trim off leading and trailing spaces in these fields +# +$json_change = 0; +for my $key ( 'Title', 'Summary', 'Tags' ) { + my $str = trim($content->{episode}{$key}); + if ($str ne $content->{episode}{$key}) { + $content->{episode}{$key} = $str; + $json_change = 1; + push(@json_changes,$key); + } +} + # # Detect Unicode in the Title, Summary or Tags and flag their presence. # @@ -386,6 +413,9 @@ for my $key ( 'Title', 'Summary', 'Tags' ) { ); } +alert( $ofmt, "JSON to be updated; changes to: " . + join(',',@json_changes) ) if $json_change; + # # Check summary length. The field might be filled and something might have # been lost. @@ -429,7 +459,12 @@ printf STDERR $ofmt, "Notes:", $snlevel . " HTML start/end tags found"; $notelength = length( $content->{episode}{Show_Notes} ); if ( $notelength > $MAXNOTELEN ) { printf STDERR $ofmt, "Notes:", - colored( "Notes are longer than $MAXNOTELEN ($notelength)", + colored( "Notes are longer than $MAXNOTELEN bytes ($notelength)", + 'bold yellow on_magenta' ); +} +elsif ( $notelength <= $MINNOTELEN ) { + printf STDERR $ofmt, "Notes:", + colored( "Notes are shorter than $MINNOTELEN bytes ($notelength)", 'bold yellow on_magenta' ); } @@ -651,6 +686,17 @@ if (%media_files) { _debug( $DEBUG > 2, '@assets: ' . Dumper( \@assets ) ); } + #------------------------------------------------------------------------------- + # Look for un-processed markup in the assets hash. For the moment we + # only look for Markdown. + #------------------------------------------------------------------------------- + $has_markup = @markup + = grep { $assets{$_}->{type} =~ m{^text/markdown$} } keys(%assets); + $markup = join( ', ', @markup ); + if (@markup) { + _debug( $DEBUG > 2, '@markup ' . Dumper( \@markup ) ); + } + #------------------------------------------------------------------------------- # Look for archive files in the assets #------------------------------------------------------------------------------- @@ -690,6 +736,11 @@ if (%media_files) { @assets = array_difference(\@assets,\@archives); push(@assets, @extracted); + # + # Remove markup files from the assets so we don't upload them + # + @assets = array_difference(\@assets,\@markup); + # # Remove directory stuff from @assets elements and %assets keys # @@ -745,6 +796,8 @@ if (%media_files) { $log->info( $showno, "Media files: $media_files" ) if ($media_files); $log->info( $showno, "Pictures: " . join( ', ', @pictures ) ) if (@pictures); + $log->info( $showno, "Markup " . join( ', ', @markup ) ) + if (@markup); $log->info( $showno, "Assets: " . join( ', ', @assets ) ) if (@assets); @@ -849,7 +902,6 @@ if ( $snlevel > 0 && $content->{metadata}{Shownotes_Format} =~ /html5/i ) { "Apparently incorrect URLs detected in the notes", 'red' ), "\n"; } - } # @@ -866,6 +918,15 @@ if ( $markup_choice eq 'html5' "Declared format 'plain_text' but notes seem to be HTML5!" ); } +# +# 7. The host has sent in markup version(s) of their external notes, so we +# need to take special action. +# +if ($markup) { + printf STDERR "%s\n", + textFormat( $markup, 'Markup files:', 'L', 18, 80 ); +} + #------------------------------------------------------------------------------- # Determine the picture asset state #------------------------------------------------------------------------------- @@ -1709,6 +1770,23 @@ sub find_Unicode { return ( $string =~ /[^\x{00}-\x{7F}]/ ); } +#=== FUNCTION ================================================================ +# NAME: trim +# PURPOSE: Trims leading and trailing spaces from a string +# PARAMETERS: string string to trim +# RETURNS: Trimmed string +# DESCRIPTION: +# THROWS: No exceptions +# COMMENTS: None +# SEE ALSO: N/A +#=============================================================================== +sub trim { + my ($str) = @_; + + $str =~ s/^\s+|\s+$//g; + return $str; +} + #=== FUNCTION ================================================================ # NAME: output_file_name # PURPOSE: Generate an output file name with three choices @@ -1969,7 +2047,6 @@ sub alert { my ( $fmt, $message ) = @_; $fmt = "%-16s %s\n" unless $fmt; -# print STDERR "$bold$red", sprintf( $fmt, "** ALERT **:", $message ), "$reset"; print STDERR colored( sprintf( $fmt, "** ALERT **:", $message ), 'bold red' ); } @@ -2082,7 +2159,7 @@ parse_JSON - parse the JSON output file from the HPR show submission form =head1 VERSION -This documentation refers to parse_JSON version 0.0.14 +This documentation refers to parse_JSON version 0.0.17 =head1 USAGE