]> Sergey Matveev's repositories - public-inbox.git/commitdiff
consistently whitespace wrap on <pre> sections
authorEric Wong <e@80x24.org>
Tue, 6 May 2014 19:44:43 +0000 (19:44 +0000)
committerEric Wong <e@80x24.org>
Wed, 7 May 2014 01:35:30 +0000 (01:35 +0000)
Horizontal scrolling is a usability problem for GUI browsers,
so help them avoid it.  I love GUI users, really! :)

lib/PublicInbox/Feed.pm
lib/PublicInbox/View.pm

index e9989e418f3f8dd0d4597391ef6ffab42893c700..0104a6baf70ef97499e37bc3386d1cd292adf29d 100644 (file)
@@ -11,6 +11,7 @@ use PublicInbox::GitCatFile;
 use constant {
        DATEFMT => '%Y-%m-%dT%H:%M:%SZ', # atom standard
        MAX_PER_PAGE => 25, # this needs to be tunable
+       PRE_WRAP => '<pre style="white-space:pre-wrap">',
 };
 
 # main function
@@ -75,7 +76,7 @@ sub generate_html_index {
        my $html = "<html><head><title>$title</title>" .
                '<link rel="alternate" title="Atom feed" href="' .
                $feed_opts->{atomurl} . '" type="application/atom+xml"/>' .
-               '</head><body><pre>';
+               '</head><body>' . PRE_WRAP;
 
        # sort by date, most recent at top
        $th->order(sub {
@@ -91,7 +92,7 @@ sub generate_html_index {
        my $footer = nav_footer($args->{cgi}, $last, $feed_opts);
        my $list_footer = $args->{footer};
        $footer .= "\n" . $list_footer if ($footer && $list_footer);
-       $footer = "<hr /><pre>$footer</pre>" if $footer;
+       $footer = "<hr />" . PRE_WRAP . "$footer</pre>" if $footer;
        $html . "</pre>$footer</html>";
 }
 
index 860663111fb00a7e1551c5c663657ca977a09c20..8bc28cd17c5bc8912daf17de46e369b15a6e1318 100644 (file)
@@ -12,6 +12,7 @@ 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;
+use constant PRE_WRAP => '<pre style="white-space:pre-wrap">';
 
 *ascii_html = *PublicInbox::Hval::ascii_html;
 
@@ -28,7 +29,7 @@ sub msg_html {
        }
        headers_to_html_header($mime, $full_pfx) .
                multipart_text_as_html($mime, $full_pfx) .
-               '</pre><hr /><pre>' .
+               '</pre><hr />' . PRE_WRAP .
                html_footer($mime) . $footer .
                '</pre></body></html>';
 }
@@ -36,7 +37,7 @@ sub msg_html {
 sub feed_entry {
        my ($class, $mime, $full_pfx) = @_;
 
-       '<pre>' . multipart_text_as_html($mime, $full_pfx) . '</pre>';
+       PRE_WRAP . multipart_text_as_html($mime, $full_pfx) . '</pre>';
 }
 
 
@@ -199,7 +200,7 @@ sub headers_to_html_header {
        $rv .= "\n";
 
        ("<html><head><title>".  join(' - ', @title) .
-        '</title></head><body><pre style="white-space:pre-wrap">' .  $rv);
+        '</title></head><body>' . PRE_WRAP . $rv);
 }
 
 sub html_footer {