summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2021-01-24 11:36:27 -0700
committerSean Whitton <spwhitton@spwhitton.name>2021-01-24 11:36:27 -0700
commitd41a20368ed7c7458495cfbe2a13eab50f9c5c28 (patch)
tree88c5e151174ec2c934905832a5979b8cdbd2aba7
parente004630d1e55006a4d8bce8dfea0658274f69d1b (diff)
downloadmailscripts-d41a20368ed7c7458495cfbe2a13eab50f9c5c28.tar.gz
gmi2email: support for Atom feeds
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
-rw-r--r--debian/changelog4
-rw-r--r--debian/control1
-rwxr-xr-xgmi2email25
-rw-r--r--gmi2email.1.pod5
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,
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
-<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