X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FView.pm;h=47082431ec8fa375580c7b85afa95117ea0496a9;hb=118ac5c2dc0e7a193ff58f2a9003636e1353583c;hp=7c92cbab7aaf4398b2d5e2d8a4e6a812e655df92;hpb=27beeb0425cd92343d3d529e37f01de8982a1078;p=public-inbox.git diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm index 7c92cbab..47082431 100644 --- a/lib/PublicInbox/View.pm +++ b/lib/PublicInbox/View.pm @@ -3,51 +3,262 @@ package PublicInbox::View; use strict; use warnings; -use URI::Escape qw/uri_escape/; -use CGI qw/escapeHTML/; -use Encode qw/decode encode/; +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 mid_compressed mid2path/; +use Digest::SHA; +require POSIX; -# public functions: -sub as_html { - my ($class, $mime, $full_pfx) = @_; +# TODO: make these constants tunable +use constant MAX_INLINE_QUOTED => 12; # half an 80x24 terminal +use constant MAX_TRUNC_LEN => 72; +use constant PRE_WRAP => "
"; +use constant T_ANCHOR => '#u'; + +*ascii_html = *PublicInbox::Hval::ascii_html; + +my $enc_utf8 = find_encoding('UTF-8'); - headers_to_html_header($mime) . +# public functions: +sub msg_html { + my ($class, $mime, $full_pfx, $footer, $srch) = @_; + if (defined $footer) { + $footer = "\n" . $footer; + } else { + $footer = ''; + } + headers_to_html_header($mime, $full_pfx, $srch) . multipart_text_as_html($mime, $full_pfx) . - ''; + '