line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::MimeTypes; |
2
|
1
|
|
|
1
|
|
617
|
use Mojo::Base 'Mojolicious::Plugin'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
5
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.04'; |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
177
|
use MIME::Types; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
42
|
|
7
|
1
|
|
|
1
|
|
14
|
use List::MoreUtils qw(uniq); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
13
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub register { |
10
|
1
|
|
|
1
|
1
|
33
|
my ($self, $app) = @_; |
11
|
1
|
|
|
|
|
4
|
my $mts = MIME::Types->new; |
12
|
1
|
|
|
|
|
29188
|
my %types = (); |
13
|
1
|
|
|
|
|
6
|
foreach my $type ( $mts->listTypes ) { |
14
|
2435
|
50
|
|
|
|
20805
|
my $mt = $mts->type($type) or next; |
15
|
2435
|
|
|
|
|
106091
|
foreach my $ext ( sort $mt->extensions ) { |
16
|
2163
|
|
|
|
|
5952
|
push @{$types{lc($ext)}}, $type; |
|
2163
|
|
|
|
|
7144
|
|
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
} |
19
|
1
|
|
|
|
|
1592
|
foreach my $ext ( sort keys %types ) { |
20
|
1724
|
|
|
|
|
79322
|
$app->types->type($ext => [uniq @{$types{$ext}}]); |
|
1724
|
|
|
|
|
17907
|
|
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
1; |
25
|
|
|
|
|
|
|
__END__ |