From 06310ae8a5649bb41f32d1c752f369dc5e077ee1 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sun, 12 Mar 2023 19:27:00 +0200 Subject: refactor --- gemtexter.conf | 4 ++-- lib/atomfeed.source.sh | 20 +++++++++++--------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/gemtexter.conf b/gemtexter.conf index 9c2d374..fa495b4 100644 --- a/gemtexter.conf +++ b/gemtexter.conf @@ -1,7 +1,7 @@ declare -xr DOMAIN=foo.zone declare -xr SUBTITLE='To be in the .zone!' -declare -xr AUTHOR='Paul C. Buetow' -declare -xr EMAIL='comments@mx.buetow.org' +declare -xr AUTHOR='Paul Buetow' +declare -xr EMAIL='hi@paul.cyou' declare -xr IMAGE_PATTERN='\.(jpg|png|gif)$' declare -xr ATOM_MAX_ENTRIES=42 declare -xr CONTENT_BASE_DIR=../foo.zone-content diff --git a/lib/atomfeed.source.sh b/lib/atomfeed.source.sh index 6be22a2..253af53 100644 --- a/lib/atomfeed.source.sh +++ b/lib/atomfeed.source.sh @@ -92,9 +92,9 @@ ATOMFOOTER } atomfeed::_entry () { - local -r gemfeed_dir="$1" - local -r gmi_file="$2" - local -r tmp_atom_file="$3" + local -r gemfeed_dir="$1"; shift + local -r gmi_file="$1"; shift + local -r tmp_atom_file="$1"; shift log INFO "Generating Atom feed entry for $gmi_file" @@ -111,19 +111,21 @@ atomfeed::_entry () { assert::not_empty summary "$summary" # Extract the date from the file name. - local publishing_date=$($SED -n '/^> Published at / { s/.*Published at //; s/;.*//; p; }' "$gemfeed_dir/$gmi_file") - if [ -z "$publishing_date" ]; then - publishing_date=$($DATE $DATE_FORMAT -r "$gemfeed_dir/$gmi_file") - log WARN "No publishing date specified for $gmi_file, assuming $publishing_date" + local date=$($SED -n '/^> Published at / { s/.*Published at //; s/;.*//; p; }' "$gemfeed_dir/$gmi_file") + if [ -z "$date" ]; then + # Extract the date from the file name. + local filename_date=$(cut -d- -f1,2,3 <<< "$gmi_file") + date=$($DATE $DATE_FORMAT --date "$filename_date $($DATE +%H:%M:%S)") + log WARN "No publishing date specified for $gmi_file, assuming $date" fi - assert::not_empty publishing_date "$publishing_date" + assert::not_empty publishing_date "$date" cat <> "$tmp_atom_file" $title gemini://$DOMAIN/gemfeed/$gmi_file - $publishing_date + $date $AUTHOR $EMAIL -- cgit v1.2.3