Add file extension to view link

This commit is contained in:
Luc Didry
2015-09-17 00:52:10 +02:00
parent 8b76684fcd
commit 1ad1929a0e
5 changed files with 13 additions and 4 deletions
+5 -1
View File
@@ -333,10 +333,14 @@ sub startup {
to('Controller#modify')->
name('modify');
$r->get('/:short')->
$r->get('/(:short).(:f)')->
to('Controller#short')->
name('short');
$r->get('/:short')->
to('Controller#short');
$r->get('/:short/(:key).(:f)')->
to('Controller#short');
$r->get('/:short/:key')->
to('Controller#short');
}
+5 -1
View File
@@ -7,7 +7,7 @@ use DateTime;
use Digest::file qw(digest_file_hex);
use Text::Unidecode;
use Data::Validate::URI qw(is_http_uri is_https_uri);
use File::MimeInfo::Magic;
use File::MimeInfo::Magic qw(mimetype extensions);
use IO::Scalar;
use Image::ExifTool;
@@ -253,6 +253,8 @@ sub add {
my $io_scalar = new IO::Scalar \$upload->slurp();
my $mediatype = mimetype($io_scalar);
my ($ext) = ($upload->filename =~ m/.*\.(.*)$/);
my $ip = $c->ip;
my ($msg, $short, $real_short, $token, $thumb);
@@ -375,6 +377,7 @@ sub add {
short => $short,
real_short => $real_short,
token => $token,
ext => $ext || extensions($mediatype),
thumb => $thumb
};
} else {
@@ -398,6 +401,7 @@ sub add {
$c->stash(short => $short) if (defined($short));
$c->stash(real_short => $real_short);
$c->stash(token => $token);
$c->stash(ext => $ext || extensions($mediatype));
$c->stash(thumb => $thumb);
$c->stash(filename => $upload->filename);
return $c->render(