Mojolicious-Plugin-Notifications
view release on metacpan or search on metacpan
lib/Mojolicious/Plugin/Notifications/Humane.pm view on Meta::CPAN
=head1 METHODS
L<Mojolicious::Plugin::Notifications::Humane> inherits all methods
from L<Mojolicious::Plugin::Notifications::Engine> and implements or overrides
the following.
=head2 register
plugin Notifications => {
Humane => {
base_class => 'libnotify'
}
};
Called when registering the main plugin.
All parameters under the key C<Humane> are passed to the registration.
Accepts the following parameters:
=over 4
=item B<base_class>
The base class for all humane notifications.
Defaults to C<libnotify>. See the
L<Humane.js documentation|http://wavded.github.io/humane-js/>
for more information.
=item B<base_timeout>
The base timeout for all humane notifications. Defaults to C<3000 ms>.
Set to C<0> for no timeout.
=back
=head1 HELPERS
=head2 notify
# In controllers
$c->notify(warn => 'Something went wrong');
$c->notify(success => {
clickToClose => Mojo::JSON->true
} => 'Everything went fine');
Notify the user on certain events.
See the documentation for your chosen class
at L<Humane.js|http://wavded.github.io/humane-js/> to see,
which notification types are presupported.
In addition to types and messages, further refinements can
be passed at the second position.
In case an C<ok> parameter is passed, this will create a
notification that requires a click to be closed.
The C<ok> URL will receive a POST request on closing.
The POST will have a L<csrf_token|Mojolicious::Plugin::TagHelpers/csrf_token>
parameter to validate.
B<Confirmation is EXPERIMENTAL!>
=head2 notifications
# In tempates
%= notifications 'humane';
%= notifications 'humane' => [qw/warn success/];
%= notifications 'humane' => [qw/warn success/], -no_css;
%= notifications 'humane' => [qw/warn success/], 'jackedup', -no_css;
Include humane notifications in your template.
You can add notification types in a list reference to ensure, they are
established (even if they were not called by L</notify>), in case you
want them to be used in conjunction with JavaScript in your application.
If you want to use a class different to the defined base class, you can
pass this as a string attribute.
If you don't want to include the javascript and css assets for Humane.js,
append C<-no_include>. If you just don't want to render the
stylesheet tag for the inclusion of the CSS, append C<-no_css>.
All notifications are also rendered in a C<E<lt>noscript /E<gt>> tag,
following the notation described in the
L<HTML|Mojolicious::Plugin::Notifications::HTML> engine.
=head1 SEE ALSO
L<Humane.js|http://wavded.github.io/humane-js/>,
L<Mojolicious::Plugin::Humane>.
=head1 AVAILABILITY
https://github.com/Akron/Mojolicious-Plugin-Notifications
=head1 COPYRIGHT AND LICENSE
=head2 Mojolicious::Plugin::Notifications::Humane
Copyright (C) 2014-2018, L<Nils Diewald|http://nils-diewald.de/>.
This program is free software, you can redistribute it
and/or modify it under the terms of the Artistic License version 2.0.
=head2 Humane.js (bundled)
Copyright (c) 2011, Marc Harter
See L<https://github.com/wavded/humane-js> for further information.
Licensed under the terms of the
L<MIT License|http://opensource.org/licenses/MIT>.
( run in 0.591 second using v1.01-cache-2.11-cpan-75ffa21a3d4 )