# Copyright (C) 2014-2015 all contributors # License: AGPLv3 or later (https://www.gnu.org/licenses/agpl-3.0.txt) # # Used for displaying the HTML web interface. # See Documentation/design_www.txt for this. 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 qw/ascii_html/; use PublicInbox::Linkify; use PublicInbox::MID qw/mid_clean id_compress mid2path mid_mime/; require POSIX; use constant INDENT => ' '; use constant TCHILD => '` '; sub th_pfx ($) { $_[0] == 0 ? '' : TCHILD }; my $enc_utf8 = find_encoding('UTF-8'); # public functions: sub msg_html { my ($ctx, $mime, $footer) = @_; $footer = defined($footer) ? "\n$footer" : ''; my $hdr = $mime->header_obj; headers_to_html_header($hdr, $ctx) . multipart_text_as_html($mime) . '
' .
		html_footer($hdr, 1, $ctx, 'R/') .
		$footer .
		'
'; } # /$LISTNAME/$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; my $mid = $hdr->header_raw('Message-ID'); $mid = PublicInbox::Hval->new_msgid($mid); my $t = ascii_html($s); my $se_url = 'https://kernel.org/pub/software/scm/git/docs/git-send-email.html'; my ($arg, $link) = mailto_arg_link($hdr); push @$arg, '/path/to/YOUR_REPLY'; "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) = @_; # no here for