]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/Feed.pm
remove Email::Address dependency
[public-inbox.git] / lib / PublicInbox / Feed.pm
index 52fe0db4ac9ece1d5431a363b1646c1150e12449..81895dbf1d67289644007844cdf3853b47b15f3a 100644 (file)
@@ -5,13 +5,13 @@
 package PublicInbox::Feed;
 use strict;
 use warnings;
-use Email::Address;
 use Email::MIME;
 use Date::Parse qw(strptime);
 use PublicInbox::Hval qw/ascii_html/;
 use PublicInbox::Git;
 use PublicInbox::View;
 use PublicInbox::MID qw/mid_clean mid2path/;
+use PublicInbox::Address;
 use POSIX qw/strftime/;
 use constant {
        DATEFMT => '%Y-%m-%dT%H:%M:%SZ', # Atom standard
@@ -86,7 +86,6 @@ sub _no_thread {
 
 sub end_feed {
        my ($fh) = @_;
-       Email::Address->purge_cache;
        $fh->write('</feed>');
        $fh->close;
 }
@@ -171,7 +170,6 @@ sub emit_index_nosrch {
                PublicInbox::View::index_entry($mime, 0, $state);
                1;
        });
-       Email::Address->purge_cache;
        $last;
 }
 
@@ -224,6 +222,7 @@ sub each_recent_blob {
        my $nr = 0;
        my ($cur_commit, $first_commit, $last_commit);
        my ($ts, $subj, $u);
+       local $/ = "\n";
        while (defined(my $line = <$log>)) {
                if ($line =~ /$addmsg/o) {
                        my $add = $1;
@@ -244,6 +243,7 @@ sub each_recent_blob {
        }
 
        if ($last) {
+               local $/ = "\n";
                while (my $line = <$log>) {
                        if ($line =~ /^(${hex}{7,40})/o) {
                                $last_commit = $1;
@@ -315,11 +315,11 @@ sub add_to_feed {
        my $mid = $header_obj->header_raw('Message-ID');
        defined $mid or return 0;
        $mid = PublicInbox::Hval->new_msgid($mid);
-       my $href = $mid->as_href;
-       my $content = PublicInbox::View->feed_entry($mime);
-       defined($content) or return 0;
-       $mime = undef;
+       my $href = $midurl.$mid->as_href;
 
+       my $content = qq(<pre\nstyle="white-space:pre-wrap">) .
+               PublicInbox::View::multipart_text_as_html($mime, $href) .
+               '</pre>';
        my $date = $header_obj->header('Date');
        my $updated = feed_updated($date);
 
@@ -328,9 +328,9 @@ sub add_to_feed {
        $title = title_tag($title);
 
        my $from = $header_obj->header('From') or return 0;
-       my @from = Email::Address->parse($from) or return 0;
-       my $name = ascii_html($from[0]->name);
-       my $email = $from[0]->address;
+       my ($email) = PublicInbox::Address::emails($from);
+       my $name = PublicInbox::Address::from_name($from);
+       $name = ascii_html($name);
        $email = ascii_html($email);
 
        if (delete $feed_opts->{emit_header}) {
@@ -346,7 +346,7 @@ sub add_to_feed {
        my $h = '[a-f0-9]';
        my (@uuid5) = ($add =~ m!\A($h{8})($h{4})($h{4})($h{4})($h{12})!o);
        my $id = 'urn:uuid:' . join('-', @uuid5);
-       $fh->write(qq!</div></content><link\nhref="$midurl$href/"/>!.
+       $fh->write(qq!</div></content><link\nhref="$href/"/>!.
                   "<id>$id</id></entry>");
        1;
 }