diff options
| author | Paul Buetow <paul@buetow.org> | 2023-03-12 19:27:00 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2023-03-12 19:27:00 +0200 |
| commit | 06310ae8a5649bb41f32d1c752f369dc5e077ee1 (patch) | |
| tree | 8f8d7ae0bbfba7a8bdde3c8ffe8e89e704b9263a /lib/atomfeed.source.sh | |
| parent | 2817cf0c36ea14c5a68e65f61a0e4f939d847028 (diff) | |
refactor
Diffstat (limited to 'lib/atomfeed.source.sh')
| -rw-r--r-- | lib/atomfeed.source.sh | 20 |
1 files changed, 11 insertions, 9 deletions
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 <<ATOMENTRY >> "$tmp_atom_file" <entry> <title>$title</title> <link href="gemini://$DOMAIN/gemfeed/$gmi_file" /> <id>gemini://$DOMAIN/gemfeed/$gmi_file</id> - <updated>$publishing_date</updated> + <updated>$date</updated> <author> <name>$AUTHOR</name> <email>$EMAIL</email> |
