]> Sergey Matveev's repositories - public-inbox.git/commitdiff
view: reduce clutter for attachments w/o description
authorEric Wong <e@80x24.org>
Thu, 19 May 2016 21:18:32 +0000 (21:18 +0000)
committerEric Wong <e@80x24.org>
Thu, 19 May 2016 21:24:58 +0000 (21:24 +0000)
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

index 2303a1fa9e0a10e414d5132a3ee8280e50798532..ec5f39076eccc64d15d87699ca8919e2b4d3200f 100644 (file)
@@ -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 {