From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 2/6] view: misc cleanups and simplifications
Date: Sat, 22 Aug 2015 11:41:20 +0000 [thread overview]
Message-ID: <1440243684-2205-2-git-send-email-e@80x24.org> (raw)
In-Reply-To: <1440243684-2205-1-git-send-email-e@80x24.org>
Less code should be easier-to-read.
---
lib/PublicInbox/View.pm | 22 +++++++---------------
1 file changed, 7 insertions(+), 15 deletions(-)
diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index 4e01507..922e8e9 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -93,8 +93,7 @@ sub index_entry {
unless (defined $ts) {
$ts = msg_timestamp($mime);
}
- my $fmt = '%Y-%m-%d %H:%M';
- $ts = POSIX::strftime($fmt, gmtime($ts));
+ $ts = POSIX::strftime('%Y-%m-%d %H:%M', gmtime($ts));
my $rv = "<table\nsummary=l$level><tr>";
if ($level) {
@@ -167,14 +166,8 @@ sub emit_thread_html {
}
my $final_anchor = $state->[3];
my $next = "<a\nid=\"s$final_anchor\">";
-
- if ($final_anchor == 1) {
- $next .= 'only message in thread';
- } else {
- $next .= 'end of thread';
- }
- $next .= "</a>, back to <a\nhref=\"../\">index</a>\n";
-
+ $next .= $final_anchor == 1 ? 'only message in' : 'end of';
+ $next .= " thread</a>, back to <a\nhref=\"../\">index</a>\n";
$fh->write("<hr />" . PRE_WRAP . $next . $foot .
"</pre></body></html>");
$fh->close;
@@ -258,9 +251,9 @@ sub flush_quote {
if ($full_pfx) {
if (!$final && scalar(@$quot) <= MAX_INLINE_QUOTED) {
# show quote inline
- my $rv = join("\n", map { linkify($_); $_ } @$quot);
+ my $rv = join('', map { linkify($_); $_ } @$quot);
@$quot = ();
- return $rv . "\n";
+ return $rv;
}
# show a short snippet of quoted text and link to full version:
@@ -286,7 +279,7 @@ sub flush_quote {
# short version (see above)
my $nr = ++$$n;
my $rv = "<a\nid=q${part_nr}_$nr></a>";
- $rv .= join("\n", map { linkify($_); $_ } @$quot) . "\n";
+ $rv .= join('', map { linkify($_); $_ } @$quot);
@$quot = ();
$rv;
}
@@ -309,7 +302,7 @@ sub add_text_body {
$part->body_set('');
$s = $enc->decode($s);
$s = ascii_html($s);
- my @lines = split(/\n/, $s);
+ my @lines = split(/^/m, $s);
$s = '';
if ($$part_nr > 0) {
@@ -330,7 +323,6 @@ sub add_text_body {
# regular line, OK
linkify($cur);
$s .= $cur;
- $s .= "\n";
} else {
push @quot, $cur;
}
--
EW
next prev parent reply other threads:[~2015-08-22 11:41 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-22 11:41 [PATCH 1/6] search: split search indexing to a separate file Eric Wong
2015-08-22 11:41 ` Eric Wong [this message]
2015-08-22 11:41 ` [PATCH 3/6] view: reference total followups Eric Wong
2015-08-22 11:41 ` [PATCH 4/6] search: consistently pass options and flags Eric Wong
2015-08-22 11:41 ` [PATCH 5/6] mbox: support uncompressed mbox Eric Wong
2015-08-22 11:41 ` [PATCH 6/6] view: wire up mbox.gz links Eric Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://public-inbox.org/README
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1440243684-2205-2-git-send-email-e@80x24.org \
--to=e@80x24.org \
--cc=meta@public-inbox.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).