diff options
-rw-r--r-- | debian/changelog | 4 | ||||
-rw-r--r-- | debian/control | 1 | ||||
-rwxr-xr-x | gmi2email | 25 | ||||
-rw-r--r-- | 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 <spwhitton@spwhitton.name> 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, @@ -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 -<gemini://gemini.circumlunar.space/docs/companion/subscription.gmi>. +We support the subscription mechanism described at +<gemini://gemini.circumlunar.space/docs/companion/subscription.gmi> as well as +Atom feeds. B<gmi2email> looks for a file with a list of gemini:// URIs to check for new posts, one per line, in |