user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* [PATCH 2/4] hval: move PRE constant for wrapping UGC here
  2015-12-22  1:02  7% [PATCH 0/4] a bunch of cleanups for future expansion Eric Wong
@ 2015-12-22  1:02  7% ` Eric Wong
  0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2015-12-22  1:02 UTC (permalink / raw)
  To: meta

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       |  4 ++--
 lib/PublicInbox/Hval.pm       |  5 +++++
 lib/PublicInbox/SearchView.pm |  2 +-
 lib/PublicInbox/View.pm       | 16 ++++++++--------
 4 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/lib/PublicInbox/Feed.pm b/lib/PublicInbox/Feed.pm
index 1201dd1..68f1e67 100644
--- a/lib/PublicInbox/Feed.pm
+++ b/lib/PublicInbox/Feed.pm
@@ -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>" .
diff --git a/lib/PublicInbox/Hval.pm b/lib/PublicInbox/Hval.pm
index ab6e044..e0b85c6 100644
--- a/lib/PublicInbox/Hval.pm
+++ b/lib/PublicInbox/Hval.pm
@@ -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 {
diff --git a/lib/PublicInbox/SearchView.pm b/lib/PublicInbox/SearchView.pm
index 7f79090..ea8a45a 100644
--- a/lib/PublicInbox/SearchView.pm
+++ b/lib/PublicInbox/SearchView.pm
@@ -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);
diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index 3c4e954..68741c5 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -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>';
 }
 
-- 
EW


^ permalink raw reply related	[relevance 7%]

* [PATCH 0/4] a bunch of cleanups for future expansion
@ 2015-12-22  1:02  7% Eric Wong
  2015-12-22  1:02  7% ` [PATCH 2/4] hval: move PRE constant for wrapping UGC here Eric Wong
  0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2015-12-22  1:02 UTC (permalink / raw)
  To: meta

Pushing 4 changes out which are generic enough for master.
We'll be expanding the scope of the project slightly :>

      config: hoist out common functions
      hval: move PRE constant for wrapping UGC here
      git: cat-file wrapper enhancements
      rename 'GitCatFile' package to 'Git'

 MANIFEST                      |   2 +-
 lib/PublicInbox/Config.pm     |  72 +++++++++++++--------
 lib/PublicInbox/ExtMsg.pm     |  19 ++----
 lib/PublicInbox/Feed.pm       |  27 ++++----
 lib/PublicInbox/Git.pm        | 142 ++++++++++++++++++++++++++++++++++++++++++
 lib/PublicInbox/GitCatFile.pm |  91 ---------------------------
 lib/PublicInbox/Hval.pm       |   5 ++
 lib/PublicInbox/Mbox.pm       |   4 +-
 lib/PublicInbox/NNTP.pm       |   2 +-
 lib/PublicInbox/NewsGroup.pm  |   4 +-
 lib/PublicInbox/SearchIdx.pm  |  18 ++----
 lib/PublicInbox/SearchView.pm |  11 ++--
 lib/PublicInbox/View.pm       |  20 +++---
 lib/PublicInbox/WWW.pm        |  29 ++-------
 t/git.fast-import-data        | 101 ++++++++++++++++++++++++++++++
 t/git.t                       | 134 +++++++++++++++++++++++++++++++++++++++
 16 files changed, 472 insertions(+), 209 deletions(-)


^ permalink raw reply	[relevance 7%]

Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2015-12-22  1:02  7% [PATCH 0/4] a bunch of cleanups for future expansion Eric Wong
2015-12-22  1:02  7% ` [PATCH 2/4] hval: move PRE constant for wrapping UGC here Eric Wong

Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).