Доброго всем
Mojolicious::Plugin::StaticShare
¡ ¡ ¡ ALL GLORY TO GLORIA ! ! !
NAME
Mojolicious::Plugin::StaticShare - browse, upload, copy, move, delete, edit, rename static files and dirs.
VERSION
0.075
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
"MULTI-PLUGIN" also.
DESCRIPTION
This plugin allow to share static files/dirs/markdown and has public and admin functionality:
Public interface
Can browse and upload files if name not exists.
Admin interface
Can copy, move, delete, rename and edit content of files/dirs.
Append param admin=<admin_pass> option
to any url inside root_url requests (see below).
OPTIONS
host
host => 'local', # mean =~ /local/
host => qr/fobar\.com$/,
String or regexp qr//
. Allow routing for given host.
root_dir
Absolute or relative file system path root directory. Defaults to '.'.
root_dir => '/mnt/usb',
root_dir => 'foo',
root_url
This prefix to url path. Defaults to '/'.
root_url => '/', # mean route '/*pth'
root_url => '', # mean also route '/*pth'
root_url => '/my/share', # mean route '/my/share/*pth'
See Mojolicious::Guides::Routing#Wildcard-placeholders.
admin_pass
Admin password (be sure https) for admin tasks. None defaults.
admin_pass => '$%^!!9nes--', #
Sign into admin interface by pass param admin to shares paths https://<...
?admin=$%^!!9nes-- >
render_dir
Template path, format, handler, etc which render directory index. Defaults to builtin things.
render_dir => 'foo/dir_index',
render_dir => {template => 'foo/my_directory_index', foo=>...},
# Disable directory index rendering
render_dir => 0,
Usefull stash variables
Plugin make any stash variables for rendering: pth
, url_path
, file_path
, language
, dirs
, files
, index
pth
Path of request exept root_url
option, as Mojo::Path object.
url_path
Path of request with root_url
option, as Mojo::Path object.
language
Req header AcceptLanguage as HTTP::AcceptLanguage object.
dirs
List of scalars dirnames. Not sorted.
files
List of hashrefs (name, size, mtime
keys) files. Not sorted.
index
Filename for markdown or pod rendering in page below the column dirs and column files.
templates_dir
String or arrayref strings. Simply push @{$app->renderer->paths}, <templates_dir>;
. None defaults.
Mainly needs for layouting markdown. When you set this option then you can define layout inside markdown/pod files like syntax:
% layouts/foo.html.ep
# Foo header
render_markdown
Same as render_dir but for markdown files. Defaults to builtin things.
render_markdown => 'foo/markdown',
render_markdown => {template => 'foo/markdown', foo=>...},
# Disable markdown rendering
render_markdown => 0,
markdown_pkg
Module name for render markdown. Must contains sub markdown($str)
or method parse($str)
. Defaults to Text::Markdown::Hoedown.
markdown_pkg => 'Foo::Markup';
Does not need to install if render_markdown => 0
or never render md files.
render_pod
Template path, format, handler, etc which render pod files. Defaults to builtin things.
render_pod=>'foo/pod',
render_pod => {template => 'foo/pod', layout=>'pod', foo=>...},
# Disable pod rendering
render_pod => 0,
dir_index
Arrayref to match files to include to directory index page. Defaults to [qw(README.md INDEX.md README.pod INDEX.pod)]
.
dir_index => [qw(DIR.md)],
dir_index => 0, # disable include markdown to index dir page
public_uploads
Boolean to disable/enable uploads for public users. Defaults to undef (disable).
public_uploads=>1, # enable
max_upload_size
max_upload_size=>0, # unlimited POST
Numeric value limiting uploads size for route. Defaults to Mojolicious setting. EXPIRIMENTAL patching of the Mojo::Transaction::HTTP#server_read for emit chunk event.
See also Mojolicious#max_request_size, Mojolicious#build_tx.
Extended MARKDOWN & POD
You can place attributes like:
id (# as prefix)
classnames (dot as prefix and separator)
css-style rules (key:value; colon separator and semicolon terminator)
to markup elements as below.
In MARKDOWN:
# {#foo123 .class1 .class2 padding: 0 0.5rem;} Header 1
{.brown-text} brown paragraph text ...
In POD:
=head2 {.class1.blue-text border-bottom: 1px dotted;} Header 2
{.red-text} red color text...
METHODS
Mojolicious::Plugin::StaticShare inherits all methods from parent Mojolicious::Plugin and implements the following new ones.
register
$plugin->register(Mojolicious->new);
Register plugin in Mojolicious application.
MULTI PLUGIN
Yep, possible:
# Mojolicious
$app->config(...)
->plugin('StaticShare', ...)
->plugin('StaticShare', ...); # and so on ...
# Mojolicious::Lite
app->config(...)
->plugin('StaticShare', ...)
->plugin('StaticShare', ...) # and so on ...
UTF-8
Everywhere and everything: module, files, content.
WINDOWS OS
It was not tested but I hope you dont worry and have happy.
SEE ALSO
Mojolicious::Plugin::Directory
Mojolicious, Mojolicious::Guides, http://mojolicious.org.
AUTHOR
Михаил Че (Mikhail Che), <mche[-at-]cpan.org>
BUGS / CONTRIBUTING
Please report any bugs or feature requests at https://github.com/mche/Mojolicious-Plugin-StaticShare/issues. Pull requests also welcome.
COPYRIGHT
Copyright 2017+ Mikhail Che.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.