1 # Copyright (C) 2013, Eric Wong <normalperson@yhbt.net> and all contributors
2 # License: AGPLv3 or later (https://www.gnu.org/licenses/agpl-3.0.txt)
17 > Long and wordy reply goes here and it is split across multiple lines.
18 > We generate links to a separate full page where quoted-text is inline.
22 my $s = Email::Simple->create(
24 From => 'a@example.com',
25 To => 'b@example.com',
26 'Content-Type' => 'text/plain',
27 'Message-ID' => '<hello@example.com>',
28 Subject => 'this is a subject',
32 $s = Email::MIME->new($s->as_string);
33 my $html = PublicInbox::View->as_html($s);
36 like($html, qr/<a href="?hello%40/s, "MID link present");
37 like($html, qr/hello world\b/, "body present");
38 like($html, qr/> keep this inline/, "short quoted text is inline");
39 like($html, qr/<a name=[^>]+>> Long and wordy/,
40 "long quoted text is anchored");
43 my $pfx = "http://example.com/test/f";
44 my $short = PublicInbox::View->as_html($s, $pfx);
45 like($short, qr/\n> keep this inline/,
46 "short quoted text is inline");
47 like($short, qr/<a href=\Q$pfx\E#[^>]+>Long and wordy/,
48 "long quoted text is made into a link");
49 ok(length($short) < length($html), "short page is shorter");
56 attributes => { content_type => 'text/plain', },
60 attributes => { content_type => 'text/plain', },
64 my $mime = Email::MIME->create(
66 From => 'a@example.com',
68 'Message-ID' => '<blah@example.com>',
69 'In-Reply-To' => '<irp@example.com>',
74 my $html = PublicInbox::View->as_html($mime);
75 like($html, qr/hi\n-+ part #2 -+\nbye\n/, "multipart split");
78 # multipart email with attached patch
82 attributes => { content_type => 'text/plain', },
83 body => 'hi, see attached patch',
87 content_type => 'text/plain',
88 filename => "foo.patch",
90 body => "--- a/file\n+++ b/file\n" .
91 "@@ -49, 7 +49,34 @@\n",
94 my $mime = Email::MIME->create(
96 From => 'a@example.com',
97 Subject => '[PATCH] asdf',
98 'Message-ID' => '<patch@example.com>',
103 my $html = PublicInbox::View->as_html($mime);
104 like($html, qr!see attached patch\n-+ foo\.patch -+\n--- a/file\n!,
105 "parts split with filename");