Mojolicious-Plugin-StaticShare
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/Mojolicious/Plugin/StaticShare.pm view on Meta::CPAN
return unless $tx->req->method =~ /PUT|POST/;
my $url = $tx->req->url->to_abs;
my $match = Mojolicious::Routes::Match->new(root => $self->routes);
#~ weaken $tx;
#~ weaken $app;
#~ Mojolicious::Controller->new(app=>$app, tx=>$tx)
my $host = $self->host;
$match->find(undef, {method => $tx->req->method, path => $url->path->to_route});# websocket => $ws
$app->log->debug("TX ONCE CHUNK check path: [".$url->path->to_route."]",
"match route: ". (($match->endpoint && $match->endpoint->name) || 'none'),
$host ? ("match host: ". $tx->req->headers->host =~ /$host/) : () #, Mojo::Util::dumper($url)
) if $self->debug;
my $route = $match->endpoint
|| return;
$tx->req->max_message_size($self->max_upload_size)
if (($route->name eq $self->routes_names->[2]) || ($route->name eq $self->routes_names->[3]))
&& $host && $tx->req->headers->host =~ /$host/; # ХоÑÑ Ð»Ð¾Ð²Ð¸ÑÑÑ ÑолÑко Ñак, в $url неÑ(
# TODO admin session
});
});
}
sub _patch_emit_chunk {
Mojo::Util::monkey_patch 'Mojo::Transaction::HTTP', 'server_read' => sub {
my ($self, $chunk) = @_;
$self->emit('chunk before req parse'=>$chunk);### ÑолÑко одна ÑÑÑока паÑÑа ÑÑÐ¾Ñ ÑмиÑ
# Parse request
my $req = $self->req;
$req->parse($chunk) unless $req->error;
$self->emit('chunk'=>$chunk);### ÑолÑко одна ÑÑÑока паÑÑа ÑÑÐ¾Ñ ÑмиÑ
# Generate response
$self->emit('request') if $req->is_finished && !$self->{handled}++;
};
}
our $VERSION = '0.075';
##############################################
package __internal__::Markdown;
sub new {
my $class = shift;
my $pkg = shift;
return
unless eval "require $pkg; 1";#
#~ $pkg->import
#~ if $pkg->can('import');
return $pkg->new()
if $pkg->can('new') && $pkg->can('parse');
return
unless $pkg->can('markdown');
bless {pkg=>$pkg} => $class;
}
sub parse { my $self = shift; no strict 'refs'; ($self->{pkg}.'::markdown')->(@_); }
=pod
=encoding utf8
ÐобÑого вÑем
=head1 Mojolicious::Plugin::StaticShare
¡ ¡ ¡ ALL GLORY TO GLORIA ! ! !
=head1 NAME
Mojolicious::Plugin::StaticShare - browse, upload, copy, move, delete, edit, rename static files and dirs.
=head1 VERSION
0.075
=head1 SYNOPSIS
# Mojolicious
$app->plugin('StaticShare', <options>);
# Mojolicious::Lite
plugin 'StaticShare', <options>;
# oneliner
$ perl -MMojolicious::Lite -E 'plugin("StaticShare", root_url=>"/my/share",)->secrets([rand])->start' daemon
L</MULTI-PLUGIN> also.
=head1 DESCRIPTION
This plugin allow to share static files/dirs/markdown and has public and admin functionality:
=head2 Public interface
Can browse and upload files if name not exists.
=head2 Admin interface
Can copy, move, delete, rename and edit content of files/dirs.
Append param C<< admin=<admin_pass> option >> to any url inside B<root_url> requests (see below).
=head1 OPTIONS
=head2 host
host => 'local', # mean =~ /local/
host => qr/fobar\.com$/,
String or regexp C< qr// >. Allow routing for given host.
=head2 root_dir
view all matches for this distributionview release on metacpan - search on metacpan
( run in 0.932 second using v1.00-cache-2.02-grep-82fe00e-cpan-1925d2aa809 )