Initial Commit
This commit is contained in:
44
database/perl/vendor/lib/MojoX/Log/Report.pm
vendored
Normal file
44
database/perl/vendor/lib/MojoX/Log/Report.pm
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
# Copyrights 2007-2021 by [Mark Overmeer <markov@cpan.org>].
|
||||
# For other contributors see ChangeLog.
|
||||
# See the manual pages for details on the licensing terms.
|
||||
# Pod stripped from pm file by OODoc 2.02.
|
||||
# This code is part of distribution Log-Report. Meta-POD processed with
|
||||
# OODoc into POD and HTML manual-pages. See README.md
|
||||
# Copyright Mark Overmeer. Licensed under the same terms as Perl itself.
|
||||
|
||||
package MojoX::Log::Report;
|
||||
use vars '$VERSION';
|
||||
$VERSION = '1.31';
|
||||
|
||||
use Mojo::Base 'Mojo::Log'; # implies use strict etc
|
||||
|
||||
use Log::Report 'log-report', import => 'report';
|
||||
|
||||
|
||||
sub new(@) {
|
||||
my $class = shift;
|
||||
my $self = $class->SUPER::new(@_);
|
||||
|
||||
# issue with Mojo, where the base-class registers a function --not
|
||||
# a method-- to handle the message.
|
||||
$self->unsubscribe('message'); # clean all listeners
|
||||
$self->on(message => '_message'); # call it OO
|
||||
$self;
|
||||
}
|
||||
|
||||
my %level2reason = qw/
|
||||
debug TRACE
|
||||
info INFO
|
||||
warn WARNING
|
||||
error ERROR
|
||||
fatal ALERT
|
||||
/;
|
||||
|
||||
sub _message($$@)
|
||||
{ my ($self, $level) = (shift, shift);
|
||||
|
||||
report +{is_fatal => 0} # do not die on errors
|
||||
, $level2reason{$level}, join('', @_);
|
||||
}
|
||||
|
||||
1;
|
||||
62
database/perl/vendor/lib/MojoX/Log/Report.pod
vendored
Normal file
62
database/perl/vendor/lib/MojoX/Log/Report.pod
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
=encoding utf8
|
||||
|
||||
=head1 NAME
|
||||
|
||||
MojoX::Log::Report - divert log messages into Log::Report
|
||||
|
||||
=head1 INHERITANCE
|
||||
|
||||
MojoX::Log::Report
|
||||
is a Mojo::Log
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
use MojoX::Log::Report;
|
||||
my $log = MojoX::Log::Report->new(%options);
|
||||
$app->log($log); # install logger in the Mojo::App
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
[Included since Log::Report v1.00]
|
||||
Mojo likes to log messages directly into a file, by default. Log::Report
|
||||
constructs a L<Log::Report::Exception|Log::Report::Exception> object first.
|
||||
|
||||
Be aware that this extension does catch the messages to be logged,
|
||||
but that the dispatching of the error follows a different route now.
|
||||
For instance, you cannot use C<$ENV{MOJO_LOG_LEVEL}> to control the output
|
||||
level, but you need to use L<Log::Report::dispatcher()|Log::Report/"Report Production and Configuration"> action C<mode>.
|
||||
|
||||
Mojo defines five "levels" of messages, which map onto Log::Report's
|
||||
reasons this way:
|
||||
|
||||
debug TRACE
|
||||
info INFO
|
||||
warn WARNING
|
||||
error ERROR
|
||||
fatal ALERT
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
=head2 Constructors
|
||||
|
||||
=over 4
|
||||
|
||||
=item MojoX::Log::Report-E<gt>B<new>(%options)
|
||||
|
||||
Inherited %options C<path> and C<level> are ignored.
|
||||
|
||||
=back
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
This module is part of Log-Report distribution version 1.31,
|
||||
built on January 15, 2021. Website: F<http://perl.overmeer.net/CPAN/>
|
||||
|
||||
=head1 LICENSE
|
||||
|
||||
Copyrights 2007-2021 by [Mark Overmeer <markov@cpan.org>]. For other contributors see ChangeLog.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the same terms as Perl itself.
|
||||
See F<http://dev.perl.org/licenses/>
|
||||
|
||||
85
database/perl/vendor/lib/MojoX/MIME/Types.pm
vendored
Normal file
85
database/perl/vendor/lib/MojoX/MIME/Types.pm
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
# Copyrights 1999-2020 by [Mark Overmeer <markov@cpan.org>].
|
||||
# For other contributors see ChangeLog.
|
||||
# See the manual pages for details on the licensing terms.
|
||||
# Pod stripped from pm file by OODoc 2.02.
|
||||
# This code is part of distribution MIME::Types. Meta-POD processed with
|
||||
# OODoc into POD and HTML manual-pages. See README.md
|
||||
# Copyright Mark Overmeer. Licensed under the same terms as Perl itself.
|
||||
|
||||
package MojoX::MIME::Types;
|
||||
use vars '$VERSION';
|
||||
$VERSION = '2.18';
|
||||
|
||||
use Mojo::Base -base;
|
||||
|
||||
use MIME::Types ();
|
||||
|
||||
|
||||
sub new(%)
|
||||
{ # base new() constructor incorrect: should call init()
|
||||
my $self = shift->SUPER::new(@_);
|
||||
$self->{MMT_mt} = delete $self->{mime_types} || MIME::Types->new;
|
||||
$self;
|
||||
}
|
||||
|
||||
#----------
|
||||
|
||||
sub mimeTypes() { shift->{MMT_mt} }
|
||||
|
||||
|
||||
sub mapping(;$)
|
||||
{ my $self = shift;
|
||||
return $self->{MMT_ext} if $self->{MMT_ext};
|
||||
|
||||
my %exttable;
|
||||
my $t = MIME::Types->_MojoExtTable;
|
||||
while(my ($ext, $type) = each %$t) { $exttable{$ext} = [$type] }
|
||||
$self->{MMT_ext} = \%exttable;
|
||||
}
|
||||
|
||||
*types = \&mapping; # renamed in release 6.0
|
||||
|
||||
#----------
|
||||
|
||||
sub detect($$;$)
|
||||
{ my ($self, $accept, $prio) = @_;
|
||||
my $mt = $self->mimeTypes;
|
||||
my @ext = map $_->extensions, grep defined, map $mt->type($_),
|
||||
grep !/\*/, $mt->httpAccept($accept);
|
||||
\@ext;
|
||||
}
|
||||
|
||||
|
||||
sub type($;$)
|
||||
{ my ($self, $ext, $types) = @_;
|
||||
|
||||
my $mt = $self->mimeTypes;
|
||||
defined $types
|
||||
or return $mt->mimeTypeOf($ext);
|
||||
|
||||
# stupid interface compatibility!
|
||||
$self;
|
||||
}
|
||||
|
||||
|
||||
sub file_type($) {
|
||||
my ($self, $fn) = @_;
|
||||
my $mt = $self->mimeTypes or return undef;
|
||||
$mt->mimeTypeOf($fn);
|
||||
}
|
||||
|
||||
|
||||
sub content_type($;$) {
|
||||
my ($self, $c, $opts) = @_;
|
||||
my $headers = $c->res->headers;
|
||||
return undef if $headers->content_type;
|
||||
|
||||
my $fn = $opts->{file} || $opts->{ext};
|
||||
|
||||
my $mt = $self->mimeTypes or return undef;
|
||||
$headers->content_type($mt->mimeTypeOf($fn) || $mt->mimeTypeOf('txt'));
|
||||
}
|
||||
|
||||
#---------------
|
||||
|
||||
1;
|
||||
227
database/perl/vendor/lib/MojoX/MIME/Types.pod
vendored
Normal file
227
database/perl/vendor/lib/MojoX/MIME/Types.pod
vendored
Normal file
@@ -0,0 +1,227 @@
|
||||
=encoding utf8
|
||||
|
||||
=head1 NAME
|
||||
|
||||
MojoX::MIME::Types - MIME Types for Mojolicious
|
||||
|
||||
=head1 INHERITANCE
|
||||
|
||||
MojoX::MIME::Types
|
||||
is a Mojo::Base
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
use MojoX::MIME::Types;
|
||||
|
||||
# set in Mojolicious as default
|
||||
$app->types(MojoX::MIME::Types->new);
|
||||
app->types(MojoX::MIME::Types->new); # ::Lite
|
||||
|
||||
# basic interface translated into pure MIME::Types
|
||||
$types->type(foo => 'text/foo');
|
||||
say $types->type('foo');
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
[Added to MIME::Types 2.07]
|
||||
This module is a drop-in replacement for Mojolicious::Types, but
|
||||
with a more correct handling plus a complete list of types... a huge
|
||||
list of types.
|
||||
|
||||
Some methods ignore information they receive: those parameters are
|
||||
accepted for compatibility with the Mojolicious::Types interface,
|
||||
but should not contain useful information.
|
||||
|
||||
Read the L</DETAILS> below, about how to connect this module into
|
||||
Mojolicious and the differences you get.
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
=head2 Constructors
|
||||
|
||||
=over 4
|
||||
|
||||
=item MojoX::MIME::Types-E<gt>B<new>(%options)
|
||||
|
||||
Create the 'type' handler for Mojolicious. When you do not specify your
|
||||
own MIME::Type object ($mime_type), it will be instantanted for you.
|
||||
You create one yourself when you would like to pass some parameter to
|
||||
the object constructor.
|
||||
|
||||
-Option --Default
|
||||
mime_types <created internally>
|
||||
types undef
|
||||
|
||||
=over 2
|
||||
|
||||
=item mime_types => MIME::Types-object
|
||||
|
||||
Pass your own prepared L<MIME::Types|MIME::Types> object, when you need some
|
||||
instantiation parameters different from the defaults.
|
||||
|
||||
=item types => HASH
|
||||
|
||||
Ignored.
|
||||
|
||||
=back
|
||||
|
||||
example:
|
||||
|
||||
$app->types(MojoX::MIME::Types->new);
|
||||
|
||||
# when you need to pass options to MIME::Types->new
|
||||
my $mt = MIME::Types->new(%opts);
|
||||
my $types = MojoX::MIME::Types->new(mime_types => $mt);
|
||||
$app->types($types);
|
||||
|
||||
=back
|
||||
|
||||
=head2 Attributes
|
||||
|
||||
=over 4
|
||||
|
||||
=item $obj-E<gt>B<mapping>( [\%table] )
|
||||
|
||||
In Mojolicious::Types, this attribute exposes the internal
|
||||
administration of types, offering to change it with using a clean
|
||||
abstract interface. That interface mistake bites now we have more
|
||||
complex internals.
|
||||
|
||||
B<Avoid this method!> The returned HASH is expensive to construct,
|
||||
changes passed via C<%table> are ignored: L<MIME::Types|MIME::Types> is very complete!
|
||||
|
||||
=item $obj-E<gt>B<mimeTypes>()
|
||||
|
||||
Returns the internal mime types object.
|
||||
|
||||
=back
|
||||
|
||||
=head2 Actions
|
||||
|
||||
=over 4
|
||||
|
||||
=item $obj-E<gt>B<content_type>($controller, \%options)
|
||||
|
||||
Set a content type on the controller when not yet set.
|
||||
The C<%options> contains C<ext> or C<file> specify an file extension or file
|
||||
name which is used to derive the content type.
|
||||
Added and marked EXPERIMENTAL in Mojo 7.94.
|
||||
|
||||
=item $obj-E<gt>B<detect>( $accept, [$prio] )
|
||||
|
||||
Returns a list of filename extensions. The $accept header in HTTP can
|
||||
contain multiple types, with a priority indication ('q' attributes).
|
||||
The returned list contains a list with extensions, the extensions related
|
||||
to the highest priority type first. The C<$prio>-flag is ignored.
|
||||
See L<MIME::Types::httpAccept()|MIME::Types/"HTTP support">.
|
||||
|
||||
This detect() function is not the correct approach for the Accept header:
|
||||
the "Accept" may contain wildcards ('*') in types for globbing, which
|
||||
does not produce extensions. Better use L<MIME::Types::httpAcceptBest()|MIME::Types/"HTTP support">
|
||||
or L<MIME::Types::httpAcceptSelect()|MIME::Types/"HTTP support">.
|
||||
|
||||
example:
|
||||
|
||||
my $exts = $types->detect('application/json;q=9');
|
||||
my $exts = $types->detect('text/html, application/json;q=9');
|
||||
|
||||
=item $obj-E<gt>B<file_type>($filename)
|
||||
|
||||
Return the mime type for a filename.
|
||||
Added and marked EXPERIMENTAL in Mojo 7.94.
|
||||
|
||||
=item $obj-E<gt>B<type>( $ext, [$type|\@types] )
|
||||
|
||||
Returns the first type name for an extension $ext, unless you specify
|
||||
type names.
|
||||
|
||||
When a single $type or an ARRAY of @types are specified, the C<$self>
|
||||
object is returned. Nothing is done with the provided info.
|
||||
|
||||
=back
|
||||
|
||||
=head1 DETAILS
|
||||
|
||||
=head2 Why?
|
||||
|
||||
The Mojolicious::Types module has only very little knowledge about
|
||||
what is really needed to treat types correctly, and only contains a tiny
|
||||
list of extensions. L<MIME::Types|MIME::Types> tries to follow the standards
|
||||
very closely and contains all types found in various lists on internet.
|
||||
|
||||
=head2 How to use with Mojolicious
|
||||
|
||||
Start your Mojo application like this:
|
||||
|
||||
package MyApp;
|
||||
use Mojo::Base 'Mojolicious';
|
||||
|
||||
sub startup {
|
||||
my $self = shift;
|
||||
...
|
||||
$self->types(MojoX::MIME::Types->new);
|
||||
}
|
||||
|
||||
If you have special options for L<MIME::Types::new()|MIME::Types/"Constructors">, then create
|
||||
your own MIME::Types object first:
|
||||
|
||||
my $mt = MIME::Types->new(%opts);
|
||||
my $types = MojoX::MIME::Types->new(mime_types => $mt);
|
||||
$self->types($types);
|
||||
|
||||
In any case, you can reach the smart L<MIME::Types|MIME::Types> object later as
|
||||
|
||||
my $mt = $app->types->mimeTypes;
|
||||
my $mime = $mt->mimeTypeOf($filename);
|
||||
|
||||
=head2 How to use with Mojolicious::Lite
|
||||
|
||||
The use in Mojolicious::Lite applications is only slightly different
|
||||
from above:
|
||||
|
||||
app->types(MojoX::MIME::Types->new);
|
||||
my $types = app->types;
|
||||
|
||||
=head2 Differences with Mojolicious::Types
|
||||
|
||||
There are a few major difference with Mojolicious::Types:
|
||||
|
||||
=over 4
|
||||
|
||||
=item *
|
||||
|
||||
the tables maintained by L<MIME::Types|MIME::Types> are complete. So: there shouldn't
|
||||
be a need to add your own types, not via MojoX::MIME::Types subroutine types, not via L<type()|MojoX::MIME::Types/"Actions">.
|
||||
All attempts to add types are ignored; better remove them from your code.
|
||||
|
||||
=item *
|
||||
|
||||
This plugin understands the experimental flag 'x-' in types and handles
|
||||
casing issues.
|
||||
|
||||
=item *
|
||||
|
||||
Updates to the internal hash via types() are simply ignored, because it
|
||||
is expensive to implement (and won't add something new).
|
||||
|
||||
=item *
|
||||
|
||||
The L<detect()|MojoX::MIME::Types/"Actions"> is implemented in a compatible way, but does not understand
|
||||
wildcards ('*'). You should use L<MIME::Types::httpAcceptBest()|MIME::Types/"HTTP support"> or
|
||||
L<MIME::Types::httpAcceptSelect()|MIME::Types/"HTTP support"> to replace this broken function.
|
||||
|
||||
=back
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
This module is part of MIME-Types distribution version 2.18,
|
||||
built on December 09, 2020. Website: F<http://perl.overmeer.net/CPAN/>
|
||||
|
||||
=head1 LICENSE
|
||||
|
||||
Copyrights 1999-2020 by [Mark Overmeer <markov@cpan.org>]. For other contributors see ChangeLog.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the same terms as Perl itself.
|
||||
See F<http://dev.perl.org/licenses/>
|
||||
|
||||
Reference in New Issue
Block a user