user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 6/6] view: reduce clutter for attachments w/o description
Date: Thu, 19 May 2016 21:28:47 +0000	[thread overview]
Message-ID: <20160519212847.4822-6-e@80x24.org> (raw)
In-Reply-To: <20160519212847.4822-1-e@80x24.org>

For attachments without a filename or description, reduce
the amount of precious screen space required to display
a link to it.
---
 lib/PublicInbox/View.pm | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index 2303a1f..ec5f390 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -260,7 +260,6 @@ sub attach_link ($$$$) {
 	my $desc = $part->header('Content-Description');
 	$desc = $fn unless defined $desc;
 	$desc = '' unless defined $desc;
-	$desc = ': '.$desc if $desc;
 	my $sfn;
 	if (defined $fn && $fn =~ /\A[\w\.-]+[a-zA-Z0-9]\z/) {
 		$sfn = $fn;
@@ -269,8 +268,10 @@ sub attach_link ($$$$) {
 	} else {
 		$sfn = 'a.bin';
 	}
-	qq($nl<a\nhref="$upfx$idx-$sfn">[-- Attachment #$idx$desc --]\n) .
-	"[-- Type: $ct, Size: $size bytes --]</a>"
+	my @ret = qq($nl<a\nhref="$upfx$idx-$sfn">[-- Attachment #$idx: );
+	my $ts = "Type: $ct, Size: $size bytes";
+	push(@ret, ($desc eq '') ? "$ts --]" : "$desc --]\n[-- $ts --]");
+	join('', @ret, '</a>');
 }
 
 sub add_text_body {
-- 
EW


  parent reply	other threads:[~2016-05-19 21:28 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-19 21:25 [PATCH 1/7] view: rely on Email::MIME::body_str for decoding Eric Wong
2016-05-19 21:28 ` [PATCH 1/6] msg_iter: new internal API for iterating through MIME Eric Wong
2016-05-19 21:28   ` [PATCH 2/6] switch read-only uses of walk_parts to msg_iter Eric Wong
2016-05-19 21:28   ` [PATCH 3/6] www: support downloading attachments Eric Wong
2016-05-19 21:28   ` [PATCH 4/6] msg_iter: workaround broken Email::MIME versions Eric Wong
2016-05-19 21:28   ` [PATCH 5/6] www: validate and check filenames in URLs Eric Wong
2016-05-19 21:28   ` Eric Wong [this message]
2016-05-19 22:06     ` [PATCH 8/7] www: tighten up allowable filenames for attachments 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=20160519212847.4822-6-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.
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).