From dc3ca765a9a8db0dbc4044583f51133eb6b0251e Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 18 Jan 2019 06:19:09 +0000 Subject: view: disable bold in topic display It seems pointless due to the indentation, and interacts badly with some CSS colouring. --- lib/PublicInbox/View.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/PublicInbox/View.pm') diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm index cd125e00..470e3ab7 100644 --- a/lib/PublicInbox/View.pm +++ b/lib/PublicInbox/View.pm @@ -1075,7 +1075,7 @@ sub dump_topics { my $mbox = qq(mbox.gz); my $atom = qq(Atom); - my $s = "$top\n" . + my $s = "$top\n" . " $ds UTC $n - $mbox / $atom\n"; for (my $i = 0; $i < scalar(@ex); $i += 2) { my $level = $ex[$i]; -- cgit v1.2.3-24-ge0c7 From ca0a28d52d43609cd6cabf5af085260032e5afa9 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 17 Jan 2019 11:51:34 +0000 Subject: view: wire up diff and vcs viewers with solver --- lib/PublicInbox/View.pm | 47 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 12 deletions(-) (limited to 'lib/PublicInbox/View.pm') diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm index 470e3ab7..0187ec33 100644 --- a/lib/PublicInbox/View.pm +++ b/lib/PublicInbox/View.pm @@ -14,6 +14,7 @@ use PublicInbox::MsgIter; use PublicInbox::Address; use PublicInbox::WwwStream; use PublicInbox::Reply; +use PublicInbox::ViewDiff qw(flush_diff); require POSIX; use Time::Local qw(timegm); @@ -28,7 +29,7 @@ sub msg_html { my ($ctx, $mime, $more, $smsg) = @_; my $hdr = $mime->header_obj; my $ibx = $ctx->{-inbox}; - my $obfs_ibx = $ctx->{-obfs_ibx} = $ibx->{obfuscate} ? $ibx : undef; + $ctx->{-obfs_ibx} = $ibx->{obfuscate} ? $ibx : undef; my $tip = _msg_html_prepare($hdr, $ctx, $more, 0); my $end = 2; PublicInbox::WwwStream->response($ctx, 200, sub { @@ -36,7 +37,7 @@ sub msg_html { if ($nr == 1) { # $more cannot be true w/o $smsg being defined: my $upfx = $more ? '../'.mid_escape($smsg->mid).'/' : ''; - $tip . multipart_text_as_html($mime, $upfx, $obfs_ibx) . + $tip . multipart_text_as_html($mime, $upfx, $ibx) . '
' } elsif ($more && @$more) { ++$end; @@ -81,15 +82,15 @@ sub msg_html_more { my $str = eval { my ($id, $prev, $smsg) = @$more; my $mid = $ctx->{mid}; - $smsg = $ctx->{-inbox}->smsg_mime($smsg); + my $ibx = $ctx->{-inbox}; + $smsg = $ibx->smsg_mime($smsg); my $next = $ctx->{srch}->next_by_mid($mid, \$id, \$prev); @$more = $next ? ($id, $prev, $next) : (); if ($smsg) { my $mime = $smsg->{mime}; my $upfx = '../' . mid_escape($smsg->mid) . '/'; _msg_html_prepare($mime->header_obj, $ctx, $more, $nr) . - multipart_text_as_html($mime, $upfx, - $ctx->{-obfs_ibx}) . + multipart_text_as_html($mime, $upfx, $ibx) . '
' } else { ''; @@ -260,7 +261,8 @@ sub index_entry { $rv .= "\n"; # scan through all parts, looking for displayable text - msg_iter($mime, sub { $rv .= add_text_body($mhref, $obfs_ibx, $_[0]) }); + my $ibx = $ctx->{-inbox}; + msg_iter($mime, sub { $rv .= add_text_body($mhref, $ibx, $_[0]) }); # add the footer $rv .= "\n^ ". @@ -488,11 +490,11 @@ sub thread_html { } sub multipart_text_as_html { - my ($mime, $upfx, $obfs_ibx) = @_; + my ($mime, $upfx, $ibx) = @_; my $rv = ""; # scan through all parts, looking for displayable text - msg_iter($mime, sub { $rv .= add_text_body($upfx, $obfs_ibx, $_[0]) }); + msg_iter($mime, sub { $rv .= add_text_body($upfx, $ibx, $_[0]) }); $rv; } @@ -545,7 +547,8 @@ sub attach_link ($$$$;$) { } sub add_text_body { - my ($upfx, $obfs_ibx, $p) = @_; + my ($upfx, $ibx, $p) = @_; + my $obfs_ibx = $ibx->{obfuscate} ? $ibx : undef; # $p - from msg_iter: [ Email::MIME, depth, @idx ] my ($part, $depth) = @$p; # attachment @idx is unused my $ct = $part->content_type || 'text/plain'; @@ -554,6 +557,19 @@ sub add_text_body { return attach_link($upfx, $ct, $p, $fn) unless defined $s; + my ($diff, $spfx); + if ($ibx->{-repo_objs} && $s =~ /^(?:diff|---|\+{3}) /ms) { + $diff = []; + my $n_slash = $upfx =~ tr!/!/!; + if ($n_slash == 0) { + $spfx = '../'; + } elsif ($n_slash == 1) { + $spfx = ''; + } else { # nslash == 2 + $spfx = '../../'; + } + }; + my @lines = split(/^/m, $s); $s = ''; if (defined($fn) || $depth > 0 || $err) { @@ -568,19 +584,26 @@ sub add_text_body { # show the previously buffered quote inline flush_quote(\$s, $l, \@quot) if @quot; - # regular line, OK - $l->linkify_1($cur); - $s .= $l->linkify_2(ascii_html($cur)); + if ($diff) { + push @$diff, $cur; + } else { + # regular line, OK + $l->linkify_1($cur); + $s .= $l->linkify_2(ascii_html($cur)); + } } else { + flush_diff(\$s, $spfx, $l, $diff) if $diff && @$diff; push @quot, $cur; } } if (@quot) { # ugh, top posted flush_quote(\$s, $l, \@quot); + flush_diff(\$s, $spfx, $l, $diff) if $diff && @$diff; obfuscate_addrs($obfs_ibx, $s) if $obfs_ibx; $s; } else { + flush_diff(\$s, $spfx, $l, $diff) if $diff && @$diff; obfuscate_addrs($obfs_ibx, $s) if $obfs_ibx; if ($s =~ /\n\z/s) { # common, last line ends with a newline $s; -- cgit v1.2.3-24-ge0c7 From a01040ed2ec1e4575947e6d589499a4c7315d90e Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 20 Jan 2019 09:42:34 +0000 Subject: viewdiff: support diff-highlighting w/o coderepo Having diff highlighting alone is still useful, even if blob-resolution/recreation is too expensive or unfeasible. --- lib/PublicInbox/View.pm | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'lib/PublicInbox/View.pm') diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm index 0187ec33..41a45b0b 100644 --- a/lib/PublicInbox/View.pm +++ b/lib/PublicInbox/View.pm @@ -558,15 +558,17 @@ sub add_text_body { return attach_link($upfx, $ct, $p, $fn) unless defined $s; my ($diff, $spfx); - if ($ibx->{-repo_objs} && $s =~ /^(?:diff|---|\+{3}) /ms) { + if ($s =~ /^(?:diff|---|\+{3}) /ms) { $diff = []; - my $n_slash = $upfx =~ tr!/!/!; - if ($n_slash == 0) { - $spfx = '../'; - } elsif ($n_slash == 1) { - $spfx = ''; - } else { # nslash == 2 - $spfx = '../../'; + if ($ibx->{-repo_objs}) { + my $n_slash = $upfx =~ tr!/!/!; + if ($n_slash == 0) { + $spfx = '../'; + } elsif ($n_slash == 1) { + $spfx = ''; + } else { # nslash == 2 + $spfx = '../../'; + } } }; -- cgit v1.2.3-24-ge0c7 From a817e10a4f94270d064fee0f18328efb910d9c35 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 26 Jan 2019 20:05:56 +0000 Subject: view: swap CRLF for LF in HTML output It makes no difference to browsers aside from saving a few bytes; and this means we won't have to worry about extra '%0D' showing up in links to solver. --- lib/PublicInbox/View.pm | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib/PublicInbox/View.pm') diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm index 41a45b0b..5aaa72ba 100644 --- a/lib/PublicInbox/View.pm +++ b/lib/PublicInbox/View.pm @@ -557,6 +557,10 @@ sub add_text_body { return attach_link($upfx, $ct, $p, $fn) unless defined $s; + # makes no difference to browsers, and don't screw up filename + # link generation in diffs with the extra '%0D' + $s =~ s/\r\n/\n/sg; + my ($diff, $spfx); if ($s =~ /^(?:diff|---|\+{3}) /ms) { $diff = []; -- cgit v1.2.3-24-ge0c7