small patch for display bug for other files

0 views
Skip to first unread message

jlker...@gmail.com

unread,
Mar 2, 2009, 5:32:15 AM3/2/09
to cpan-mini-webserver
Hi,
I have a small patch for the bug described here:
http://rt.cpan.org/Public/Bug/Display.html?id=38582, to handle images
and other files which have been displayed as binaries so far.

It would be nice if you could review it and include it to the next
version,

I don't know where to include the patch so here it goes, it concerns
the Templates.ppm file:

template 'raw' => sub {
my ( $self, $arguments ) = @_;
my $author = $arguments->{author};
my $distribution = $arguments->{distribution};
my $filename = $arguments->{filename};
my $pauseid = $arguments->{pauseid};
my $distvname = $arguments->{distvname};
my $contents = $arguments->{contents};
my $html = $arguments->{html};
html {
show( 'header',
$author->name . ' > ' . $distvname . ' > ' . $filename );
body {
div {
attr { class => 'container' };
div {
attr { class => 'span-24' };
show('searchbar');
h1 {
show( 'author_link', $author );
outs ' > ';
show( 'distribution_link', $distribution );
outs ' > ';
outs $filename;
};
if ($html) {
div {
attr { id => "code" };
code {
outs_raw $html;
};
};
}
else {

my @nn = split( /\./, $filename );
my $extension = pop(@nn);

if ( ( $extension eq "jpg" )
|| ( $extension eq "png" )
|| ( $extension eq "gif" )
|| ( $extension eq "jpeg" )
|| ( $extension eq "bmp" ) )
{
img {
attr { src => '/download/~'
. $author->pauseid
. "/$distvname/$filename" };

};

}

elsif (!( $extension eq "pdf" )
&& !( $extension eq "doc" )
&& !( $extension eq "tif" )
&& !( $extension eq "tiff" ) )
{
pre { $contents };
}
}
div {
attr { class => 'download-link' };
a {
attr { href => '/download/~'
. $author->pauseid
. "/$distvname/$filename" };
"Download as plain text";
};
};
show('footer');
};

};
};

}
};


The concerned section is in the else segment.

Thanks in advance,

JL


Reply all
Reply to author
Forward
0 new messages