]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/View.pm
www: add footers to HTML index and message views
[public-inbox.git] / lib / PublicInbox / View.pm
index a43ab620792c8de7aeb2f155d3923cc5ff36f14f..5870c9d1ad3099ca857f0ab2d6966a2f16cf95d9 100644 (file)
@@ -8,28 +8,31 @@ use URI::Escape qw/uri_escape_utf8/;
 use Encode qw/find_encoding/;
 use Encode::MIME::Header;
 use Email::MIME::ContentType qw/parse_content_type/;
+
+# TODO: make these constants tunable
 use constant MAX_INLINE_QUOTED => 5;
 use constant MAX_TRUNC_LEN => 72;
+
 *ascii_html = *PublicInbox::Hval::ascii_html;
 
 my $enc_utf8 = find_encoding('UTF-8');
 my $enc_mime = find_encoding('MIME-Header');
 
 # public functions:
-sub as_html {
-       my ($class, $mime, $full_pfx) = @_;
-
+sub msg_html {
+       my ($class, $mime, $full_pfx, $footer) = @_;
+       $footer = '' unless defined $footer;
        headers_to_html_header($mime, $full_pfx) .
                multipart_text_as_html($mime, $full_pfx) .
                '</pre><hr /><pre>' .
-               html_footer($mime) .
+               html_footer($mime) . $footer .
                '</pre></body></html>';
 }
 
-sub as_feed_entry {
+sub feed_entry {
        my ($class, $mime, $full_pfx) = @_;
 
-       "<pre>" . multipart_text_as_html($mime, $full_pfx) . "</pre>";
+       '<pre>' . multipart_text_as_html($mime, $full_pfx) . '</pre>';
 }
 
 
@@ -92,6 +95,7 @@ sub add_text_body_short {
        my ($enc, $part, $part_nr, $full_pfx) = @_;
        my $n = 0;
        my $s = ascii_html($enc->decode($part->body));
+       # TODO: fold the "so-and-so wrote:" attribute line here, too:
        $s =~ s!^((?:(?:&gt;[^\n]*)\n)+)!
                my $cur = $1;
                my @lines = split(/\n/, $cur);