X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FView.pm;h=a78ce31d291ea0859edc5cf75a7e2d253579c3a2;hb=ef9ce6f2dfc9fcbb91e3cec0b7a2b7f7e359be5d;hp=de7bdf9c073eaba6c762f0fb8ae01f73200e0d33;hpb=cb6cb8a6146c1f7a51b6eb0fe777311c9cc6a245;p=public-inbox.git diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm index de7bdf9c..687a0acb 100644 --- a/lib/PublicInbox/View.pm +++ b/lib/PublicInbox/View.pm @@ -6,500 +6,578 @@ 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 = ''; - } + my ($ctx, $mime) = @_; my $hdr = $mime->header_obj; - headers_to_html_header($hdr, $full_pfx, $ctx) . - multipart_text_as_html($mime, $full_pfx) . - '
' .
-		html_footer($hdr, 1, $full_pfx, $ctx) .
-		$footer .
-		'
'; + my $obfs = $ctx->{-inbox}->{obfuscate}; + my $tip = _msg_html_prepare($hdr, $ctx, $obfs); + PublicInbox::WwwStream->response($ctx, 200, sub { + my ($nr, undef) = @_; + if ($nr == 1) { + $tip . multipart_text_as_html($mime, '', $obfs) . + '
' + } 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 + } + }); } -# /$LISTNAME/$MESSAGE_ID/R/ +# /$INBOX/$MESSAGE_ID/#R sub msg_reply { - my ($ctx, $hdr, $footer) = @_; - my $s = $hdr->header('Subject'); - $s = '(no subject)' if (!defined $s) || ($s eq ''); - my $f = $hdr->header('From'); - $f = '' unless defined $f; - $s = PublicInbox::Hval->new_oneline($s); - my $mid = $hdr->header('Message-ID'); - $mid = PublicInbox::Hval->new_msgid($mid); - my $t = $s->as_html; + 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); + } - my ($arg, $link) = mailto_arg_link($hdr); + my ($arg, $link) = PublicInbox::Reply::mailto_arg_link($ibx, $hdr); push @$arg, '/path/to/YOUR_REPLY'; + $arg = ascii_html(join(" \\\n ", '', @$arg)); + <
Reply instructions:
+
+You may reply publically to this message via plain-text email
+using any one of the following methods:
+
+* Save the following mbox file, import it into your mail client,
+  and reply-to-all from there: mbox
 
-	"replying to \"$t\"
" .
-	"replying to message:\n\n" .
-	"Subject: $t\n" .
-	"From: ". ascii_html($f) .
-	"\nDate: " .  ascii_html($hdr->header('Date')) .
-	"\nMessage-ID: <" . $mid->as_html . ">\n\n" .
-	"There are multiple ways to reply:\n\n" .
-	"* Save the following mbox file, import it into your mail client,\n" .
-	"  and reply-to-all from there: mbox\n\n" .
-	"* Reply to all the recipients using the --to, --cc,\n" .
-	"  and --in-reply-to switches of git-send-email(1):\n\n" .
-	"\tgit send-email \\\n\t\t" .
-	join(" \\ \n\t\t", @$arg ). "\n\n" .
-	qq(  $se_url\n\n) .
-	"* If your mail client supports setting the In-Reply-To" .
-	" header\n  via mailto: links, try the " .
-	qq(mailto: link\n) .
-	"\nFor context, the original message or " .
-	qq(thread) .
-	'

' . $footer .  '
'; -} - -sub feed_entry { - my ($class, $mime, $full_pfx) = @_; - - # no here for