X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FWwwAtomStream.pm;h=c3fbb1a7cef589479f55860474390a7a3b3e5687;hb=c91490ccae1a1775da1e816866ef0b08b234ff54;hp=d142a469c68b382331462c24ad0947e6c7184e8b;hpb=256d049b7ac24f40bb1df691fe014853b75bf491;p=public-inbox.git diff --git a/lib/PublicInbox/WwwAtomStream.pm b/lib/PublicInbox/WwwAtomStream.pm index d142a469..c3fbb1a7 100644 --- a/lib/PublicInbox/WwwAtomStream.pm +++ b/lib/PublicInbox/WwwAtomStream.pm @@ -1,4 +1,4 @@ -# Copyright (C) 2016-2019 all contributors +# Copyright (C) 2016-2020 all contributors # License: AGPL-3.0+ # # Atom body stream for which yields getline+close methods @@ -12,8 +12,7 @@ use warnings; use POSIX qw(strftime); use Digest::SHA qw(sha1_hex); use PublicInbox::Address; -use PublicInbox::Hval qw(ascii_html); -use PublicInbox::MID qw(mid_escape); +use PublicInbox::Hval qw(ascii_html mid_href); use PublicInbox::MsgTime qw(msg_timestamp); # called by PSGI server after getline: @@ -21,9 +20,8 @@ sub close {} sub new { my ($class, $ctx, $cb) = @_; - $ctx->{emit_header} = 1; $ctx->{feed_base_url} = $ctx->{-inbox}->base_url($ctx->{env}); - bless { cb => $cb || \&close, ctx => $ctx }, $class; + bless { cb => $cb || \&close, ctx => $ctx, emit_header => 1 }, $class; } sub response { @@ -71,7 +69,7 @@ sub atom_header { my $mid = $ctx->{mid}; my $page_id; if (defined $mid) { # per-thread - $self_url .= mid_escape($mid).'/t.atom'; + $self_url .= mid_href($mid).'/t.atom'; $page_id = to_uuid("t\n".$mid) } elsif (defined $search_q) { my $query = $search_q->{'q'}; @@ -109,13 +107,13 @@ sub feed_entry { my $base = $ctx->{feed_base_url}; if (defined $irt) { my $irt_uuid = to_uuid($irt); - $irt = mid_escape($irt); + $irt = mid_href($irt); $irt = qq(); } else { $irt = ''; } - my $href = $base . mid_escape($mid) . '/'; + my $href = $base . mid_href($mid) . '/'; my $t = msg_timestamp($hdr); my @t = gmtime(defined $t ? $t : time); my $updated = feed_updated(@t); @@ -131,7 +129,7 @@ sub feed_entry { $email = ascii_html($email); my $s = ''; - if (delete $ctx->{emit_header}) { + if (delete $self->{emit_header}) { $s .= atom_header($ctx, $title); } $s .= "$name$email" . @@ -142,7 +140,8 @@ sub feed_entry { qq{} . qq(); $ctx->{obuf} = \$s; - PublicInbox::View::multipart_text_as_html($mime, $href, $ctx); + $ctx->{mhref} = $href; + PublicInbox::View::multipart_text_as_html($mime, $ctx); delete $ctx->{obuf}; $s .= ''; }