From 398e29344ecc43548a7d3998bb5d2fcee62d66cd Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 25 Dec 2015 11:48:27 +0000 Subject: view: favor whitespace wrap in If we bite the bullet and rely on inline CSS, we might as well only specify it once per page instead of inline in every
tag which may handle UGC.  So this actually saves us a small
amount of bandwith on most pages which have multiple 
start tags.
---
 lib/PublicInbox/Feed.pm       |  8 ++++----
 lib/PublicInbox/Hval.pm       |  3 ++-
 lib/PublicInbox/SearchView.pm |  2 +-
 lib/PublicInbox/View.pm       | 18 ++++++++++--------
 4 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/lib/PublicInbox/Feed.pm b/lib/PublicInbox/Feed.pm
index 150bea03..7ebc0505 100644
--- a/lib/PublicInbox/Feed.pm
+++ b/lib/PublicInbox/Feed.pm
@@ -128,18 +128,18 @@ sub emit_html_index {
 	my $top = "$title (Atom feed)";
 
 	if ($srch) {
-		$top = qq{$top} .
+		$top = qq{
$top} .
 			  qq{ } .
 			  qq{} .
-			  qq{} .
-			  PublicInbox::Hval::PRE;
+			  q{
}
 	} else {
-		$top = PublicInbox::Hval::PRE . $top . "\n";
+		$top = '
' . $top . "\n";
 	}
 
 	$fh->write("$title" .
 		   "" .
+		   PublicInbox::Hval::STYLE .
 		   "$top");
 
 	# if the 'r' query parameter is given, it is a legacy permalink
diff --git a/lib/PublicInbox/Hval.pm b/lib/PublicInbox/Hval.pm
index e0b85c68..5a869358 100644
--- a/lib/PublicInbox/Hval.pm
+++ b/lib/PublicInbox/Hval.pm
@@ -13,7 +13,8 @@ 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 => "";
+use constant STYLE => '';
+use constant PRE => ""; # legacy
 
 my $enc_ascii = find_encoding('us-ascii');
 
diff --git a/lib/PublicInbox/SearchView.pm b/lib/PublicInbox/SearchView.pm
index fec4f39f..5b15e0d7 100644
--- a/lib/PublicInbox/SearchView.pm
+++ b/lib/PublicInbox/SearchView.pm
@@ -32,7 +32,7 @@ sub sres_top_html {
 		$total = $mset->get_matches_estimated;
 	};
 	my $err = $@;
-	my $res = html_start($q, $ctx) . PublicInbox::Hval::PRE;
+	my $res = html_start($q, $ctx) . '
'
 	if ($err) {
 		$code = 400;
 		$res .= err_txt($err) . "

" . foot($ctx);
diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index 523d27fe..7603c514 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -38,7 +38,7 @@ sub msg_html {
 	}
 	headers_to_html_header($mime, $full_pfx, $ctx) .
 		multipart_text_as_html($mime, $full_pfx) .
-		'

' . PublicInbox::Hval::PRE . + '

' .
 		html_footer($mime, 1, $full_pfx, $ctx) .
 		$footer .
 		'
'; @@ -47,6 +47,7 @@ sub msg_html { sub feed_entry { my ($class, $mime, $full_pfx) = @_; + # no here for