]> Sergey Matveev's repositories - public-inbox.git/commitdiff
hval: move PRE constant for wrapping UGC here
authorEric Wong <e@80x24.org>
Tue, 15 Dec 2015 20:58:50 +0000 (20:58 +0000)
committerEric Wong <e@80x24.org>
Tue, 22 Dec 2015 00:58:06 +0000 (00:58 +0000)
User-generated content (UGC) may have excessively long lines
which screw up rendering.  This is the only bit of CSS we use.

lib/PublicInbox/Feed.pm
lib/PublicInbox/Hval.pm
lib/PublicInbox/SearchView.pm
lib/PublicInbox/View.pm

index 1201dd1165a03d3e0fc3ca3ed81b3dfe3bbf735f..68f1e67bf1bba4939df8b66c413a861bee49d018 100644 (file)
@@ -134,9 +134,9 @@ sub emit_html_index {
                          qq{ <input\nname=q\ntype=text />} .
                          qq{<input\ntype=submit\nvalue=search />} .
                          qq{</tt></form>} .
-                         PublicInbox::View::PRE_WRAP;
+                         PublicInbox::Hval::PRE;
        } else {
-               $top = PublicInbox::View::PRE_WRAP . $top . "\n";
+               $top = PublicInbox::Hval::PRE . $top . "\n";
        }
 
        $fh->write("<html><head><title>$title</title>" .
index ab6e044bbf9716f9a1c23ab00cfa70339a781c70..e0b85c685c58d0b8824d0e19d39560f0920605ca 100644 (file)
@@ -10,6 +10,11 @@ use Encode qw(find_encoding);
 use URI::Escape qw(uri_escape_utf8);
 use PublicInbox::MID qw/mid_clean/;
 
+# for user-generated content (UGC) which may have excessively long lines
+# and screw up rendering on some browsers.  This is the only CSS style
+# feature we use.
+use constant PRE => "<pre\nstyle=\"white-space:pre-wrap\">";
+
 my $enc_ascii = find_encoding('us-ascii');
 
 sub new {
index 7f790902ca4c74e83b024196eafa3c47320b866c..ea8a45a4e91f6d4416db9b6792d442d44e150e4a 100644 (file)
@@ -31,7 +31,7 @@ sub sres_top_html {
                $total = $mset->get_matches_estimated;
        };
        my $err = $@;
-       my $res = html_start($q, $ctx) . PublicInbox::View::PRE_WRAP;
+       my $res = html_start($q, $ctx) . PublicInbox::Hval::PRE;
        if ($err) {
                $code = 400;
                $res .= err_txt($err) . "</pre><hr /><pre>" . foot($ctx);
index 3c4e9547e5f56808dee6caed782f6303c401168a..68741c5e0366c13c9e1a2bf05d775d87437c621b 100644 (file)
@@ -21,7 +21,6 @@ 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 PRE_WRAP => "<pre\nstyle=\"white-space:pre-wrap\">";
 use constant T_ANCHOR => '#u';
 use constant INDENT => '  ';
 
@@ -39,7 +38,7 @@ sub msg_html {
        }
        headers_to_html_header($mime, $full_pfx, $ctx) .
                multipart_text_as_html($mime, $full_pfx) .
-               '</pre><hr />' . PRE_WRAP .
+               '</pre><hr />' . PublicInbox::Hval::PRE .
                html_footer($mime, 1, $full_pfx, $ctx) .
                $footer .
                '</pre></body></html>';
@@ -48,7 +47,8 @@ sub msg_html {
 sub feed_entry {
        my ($class, $mime, $full_pfx) = @_;
 
-       PRE_WRAP . multipart_text_as_html($mime, $full_pfx) . '</pre>';
+       PublicInbox::Hval::PRE .
+               multipart_text_as_html($mime, $full_pfx) . '</pre>';
 }
 
 sub in_reply_to {
@@ -107,7 +107,7 @@ sub index_entry {
        if ($level) {
                $rv .= '<td><pre>' . (INDENT x $level) . '</pre></td>';
        }
-       $rv .= "<td\nid=s$midx>" . PRE_WRAP;
+       $rv .= "<td\nid=s$midx>" . PublicInbox::Hval::PRE;
        $rv .= "<b\nid=\"$id\">$subj</b>\n";
        $rv .= "- $from @ $ts UTC - ";
        $rv .= "<a\nhref=\"#s$next\">next</a>";
@@ -206,8 +206,8 @@ sub emit_thread_html {
        $next .= "\ndownload thread: ";
        $next .= "<a\n$MBOX_TITLE\nhref=\"../t.mbox.gz\">mbox.gz</a>";
        $next .= " / follow: <a\nhref=\"../t.atom\">Atom feed</a>";
-       $cb->write("<hr />" . PRE_WRAP . $next . "\n\n". $foot .
-                  "</pre></body></html>");
+       $cb->write("<hr />" . PublicInbox::Hval::PRE . $next . "\n\n".
+               $foot .  "</pre></body></html>");
        $cb->close;
 }
 
@@ -457,7 +457,7 @@ sub headers_to_html_header {
        $rv .= "\n";
 
        ("<html><head><title>".  join(' - ', @title) .
-        "</title>$atom</head><body>" . PRE_WRAP . $rv);
+        "</title>$atom</head><body>" . PublicInbox::Hval::PRE . $rv);
 }
 
 sub thread_inline {
@@ -634,7 +634,7 @@ sub ghost_table {
        my ($upfx, $mid, $level) = @_;
        "<table\nsummary=ghost><tr><td>" .
                (INDENT x $level) . "</td><td>" .
-               PRE_WRAP . ghost_parent($upfx, $mid) .
+               PublicInbox::Hval::PRE . ghost_parent($upfx, $mid) .
                '</pre></td></table>';
 }