From d41a20368ed7c7458495cfbe2a13eab50f9c5c28 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sun, 24 Jan 2021 11:36:27 -0700 Subject: gmi2email: support for Atom feeds Signed-off-by: Sean Whitton --- debian/changelog | 4 ++-- debian/control | 1 + gmi2email | 25 +++++++++++++++++-------- gmi2email.1.pod | 5 +++-- 4 files changed, 23 insertions(+), 12 deletions(-) diff --git a/debian/changelog b/debian/changelog index bbb3bf5..5373cf1 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,8 +2,8 @@ mailscripts (0.23-1) UNRELEASED; urgency=medium * New script: gmi2email - add libdbd-sqlite3-perl, libio-socket-ssl-perl, libmime-lite-perl, - libemail-date-format-perl, libtry-tiny-perl and libmailtools-perl to - Recommends. + libemail-date-format-perl, libtry-tiny-perl, libmailtools-perl and + libxml-feed-perl to Recommends. -- Sean Whitton Sat, 23 Jan 2021 16:36:25 -0700 diff --git a/debian/control b/debian/control index a47be4c..552da66 100644 --- a/debian/control +++ b/debian/control @@ -57,6 +57,7 @@ Recommends: libemail-date-format-perl, libtry-tiny-perl, libmailtools-perl, + libxml-feed-perl, notmuch, python3-argcomplete, python3-gssapi, diff --git a/gmi2email b/gmi2email index 714e58a..dd9edba 100755 --- a/gmi2email +++ b/gmi2email @@ -32,6 +32,7 @@ use Getopt::Long; use Email::Date::Format "email_date"; use Time::Local; use Mail::Field::AddrList; +use XML::Feed; my ($from, $to, $do_subs, $inline_images, $no_mail); GetOptions @@ -108,15 +109,23 @@ foreach my $sub (<$subs_fh>) { } }; #>>> - $type =~ m{^text/gemini} or die "$sub is not gemtext"; - for (@$data) { - if (/^#\s*/ and not $gemlog) { - chomp($gemlog = $'); - } elsif (my ($uri, $y, $m, $d, $title) - = /^=>\s*(\S+)\s+([0-9]{4})-([0-9]{2})-([0-9]{2})[\s-]*(.*)/) { - send_subscribed_gemtext($uri, $gemlog // "unknown gemlog", - $title, timelocal 0, 0, 12, $d, $m - 1, $y); + if ($type =~ m{^text/gemini}) { + for (@$data) { + if (/^#\s*/ and not $gemlog) { + chomp($gemlog = $'); + } elsif (my ($uri, $y, $m, $d, $title) + = /^=>\s*(\S+)\s+([0-9]{4})-([0-9]{2})-([0-9]{2})[\s-]*(.*)/) { + send_subscribed_gemtext($uri, $gemlog // "unknown gemlog", + $title, timelocal 0, 0, 12, $d, $m - 1, $y); + } } + } elsif ($type =~ m{^text/xml}) { + my $feed = XML::Feed->parse(\$data); + send_subscribed_gemtext($_->link, $feed->title, $_->title, + ($_->issued // $_->modified)->epoch) + for $feed->entries; + } else { + die "$sub is not gemtext"; } } diff --git a/gmi2email.1.pod b/gmi2email.1.pod index d4e656c..d5004d5 100644 --- a/gmi2email.1.pod +++ b/gmi2email.1.pod @@ -23,8 +23,9 @@ text/gemini content specified on the command line. In addition to mailing any URIs/files specified on the command line, check subscribed gemlogs for new posts and send those too. Useful in a crontab. -Currently we only support the subscription mechanism described at -. +We support the subscription mechanism described at + as well as +Atom feeds. B looks for a file with a list of gemini:// URIs to check for new posts, one per line, in -- cgit v1.2.3