The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Mojolicious::Plugin::Notifications::Humane - Event Notifications using Humane.js

SYNOPSIS

  # Register the engine
  plugin Notifications => {
    Humane => {
      base_class => 'libnotify'
    }
  };

  # In the template
  %= notifications 'Humane'

DESCRIPTION

This plugin is a notification engine using Humane.js.

If this does not suit your needs, you can easily write your own engine.

If you want to use Humane.js without Mojolicious::Plugin::Notifications, you should have a look at Mojolicious::Plugin::Humane, which was the original inspiration for this plugin.

METHODS

Mojolicious::Plugin::Notifications::Humane inherits all methods from Mojolicious::Plugin::Notifications::Engine and implements or overrides the following.

register

  plugin Notifications => {
    Humane => {
       base_class => 'libnotify'
    }
  };

Called when registering the main plugin. All parameters under the key Humane are passed to the registration.

Accepts the following parameters:

base_class

The base class for all humane notifications. Defaults to libnotify. See the Humane.js documentation for more information.

base_timeout

The base timeout for all humane notifications. Defaults to 3000 ms. Set to 0 for no timeout.

HELPERS

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 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 ok parameter is passed, this will create a notification that requires a click to be closed. The ok URL will receive a POST request on closing. The POST will have a csrf_token parameter to validate.

Confirmation is EXPERIMENTAL!

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 "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 -no_include. If you just don't want to render the stylesheet tag for the inclusion of the CSS, append -no_css.

All notifications are also rendered in a <noscript /> tag, following the notation described in the HTML engine.

SEE ALSO

Humane.js, Mojolicious::Plugin::Humane.

AVAILABILITY

  https://github.com/Akron/Mojolicious-Plugin-Notifications

COPYRIGHT AND LICENSE

Mojolicious::Plugin::Notifications::Humane

Copyright (C) 2014-2018, Nils Diewald.

This program is free software, you can redistribute it and/or modify it under the terms of the Artistic License version 2.0.

Humane.js (bundled)

Copyright (c) 2011, Marc Harter

See https://github.com/wavded/humane-js for further information.

Licensed under the terms of the MIT License.