X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FView.pm;h=e6d30a850a8bb36e1c47149dad34ade5b7c4ef05;hb=956ede734d7c2e8d0a3003c6e2d554114586643e;hp=8af51adfd6bc88f50b55f4cfb3b94877705551dd;hpb=4ff467429242ec7e18158de7ed203f13761e9dcf;p=public-inbox.git diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm index 8af51adf..81e83d97 100644 --- a/lib/PublicInbox/View.pm +++ b/lib/PublicInbox/View.pm @@ -6,472 +6,584 @@ package PublicInbox::View; use strict; use warnings; -use URI::Escape qw/uri_escape_utf8/; use Date::Parse qw/str2time/; -use Encode qw/find_encoding/; -use Encode::MIME::Header; -use Email::MIME::ContentType qw/parse_content_type/; -use PublicInbox::Hval; -use PublicInbox::MID qw/mid_clean id_compress mid2path/; -use Digest::SHA qw/sha1_hex/; -my $SALT = rand; +use PublicInbox::Hval qw/ascii_html obfuscate_addrs/; +use PublicInbox::Linkify; +use PublicInbox::MID qw/mid_clean id_compress mid_mime mid_escape/; +use PublicInbox::MsgIter; +use PublicInbox::Address; +use PublicInbox::WwwStream; +use PublicInbox::Reply; require POSIX; -# TODO: make these constants tunable -use constant MAX_INLINE_QUOTED => 12; # half an 80x24 terminal -use constant MAX_TRUNC_LEN => 72; -use constant T_ANCHOR => '#u'; use constant INDENT => ' '; +use constant TCHILD => '` '; +sub th_pfx ($) { $_[0] == 0 ? '' : TCHILD }; -*ascii_html = *PublicInbox::Hval::ascii_html; - -my $enc_utf8 = find_encoding('UTF-8'); - -# public functions: +# public functions: (unstable) sub msg_html { - my ($ctx, $mime, $full_pfx, $footer) = @_; - if (defined $footer) { - $footer = "\n" . $footer; - } else { - $footer = ''; - } - headers_to_html_header($mime, $full_pfx, $ctx) . - multipart_text_as_html($mime, $full_pfx) . - '
' .
-		html_footer($mime, 1, $full_pfx, $ctx) .
-		$footer .
-		'
'; + my ($ctx, $mime) = @_; + my $hdr = $mime->header_obj; + my $ibx = $ctx->{-inbox}; + my $obfs_ibx = $ibx->{obfuscate} ? $ibx : undef; + my $tip = _msg_html_prepare($hdr, $ctx, $obfs_ibx); + PublicInbox::WwwStream->response($ctx, 200, sub { + my ($nr, undef) = @_; + if ($nr == 1) { + $tip . multipart_text_as_html($mime, '', $obfs_ibx) . + '
' + } elsif ($nr == 2) { + # fake an EOF if generating the footer fails; + # we want to at least show the message if something + # here crashes: + eval { + '
' . html_footer($hdr, 1, $ctx) .
+				'
' . msg_reply($ctx, $hdr) + }; + } else { + undef + } + }); } -sub feed_entry { - my ($class, $mime, $full_pfx) = @_; +# /$INBOX/$MESSAGE_ID/#R +sub msg_reply { + my ($ctx, $hdr) = @_; + my $se_url = + 'https://kernel.org/pub/software/scm/git/docs/git-send-email.html'; + my $p_url = + 'https://en.wikipedia.org/wiki/Posting_style#Interleaved_style'; + + my $info = ''; + my $ibx = $ctx->{-inbox}; + if (my $url = $ibx->{infourl}) { + $url = PublicInbox::Hval::prurl($ctx->{env}, $url); + $info = qq(\n List information: $url\n); + } - # no here for