line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::Notifications::Humane; |
2
|
3
|
|
|
3
|
|
2975
|
use Mojo::Base 'Mojolicious::Plugin::Notifications::Engine'; |
|
3
|
|
|
|
|
24
|
|
|
3
|
|
|
|
|
19
|
|
3
|
3
|
|
|
3
|
|
1351
|
use Mojolicious::Plugin::Notifications::HTML qw/notify_html/; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
175
|
|
4
|
3
|
|
|
3
|
|
23
|
use Mojo::ByteStream 'b'; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
134
|
|
5
|
3
|
|
|
3
|
|
19
|
use Mojo::Util qw/xml_escape quote/; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
133
|
|
6
|
3
|
|
|
3
|
|
17
|
use Mojo::JSON qw/encode_json decode_json/; |
|
3
|
|
|
|
|
14
|
|
|
3
|
|
|
|
|
133
|
|
7
|
3
|
|
|
3
|
|
19
|
use File::Spec; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
78
|
|
8
|
3
|
|
|
3
|
|
16
|
use File::Basename; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
244
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has [qw/base_class base_timeout/]; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
state $path = '/humane/'; |
13
|
|
|
|
|
|
|
|
14
|
3
|
|
|
3
|
|
21
|
use constant CANCEL_WARN => 'Trying to use cancel with humane engine in M::P::Notifications'; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
2874
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# Register plugin |
17
|
|
|
|
|
|
|
sub register { |
18
|
3
|
|
|
3
|
1
|
9
|
my ($plugin, $app, $param) = @_; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# Set config |
21
|
3
|
|
50
|
|
|
32
|
$plugin->base_class( $param->{base_class} // 'libnotify' ); |
22
|
3
|
|
50
|
|
|
49
|
$plugin->base_timeout( $param->{base_timeout} // 3000 ); |
23
|
|
|
|
|
|
|
|
24
|
3
|
|
|
|
|
35
|
$plugin->scripts( $path . 'humane.min.js'); |
25
|
3
|
|
|
|
|
24
|
$plugin->styles( $path . $plugin->base_class . '.css'); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# Add static path to JavaScript |
28
|
3
|
|
|
|
|
7
|
push @{$app->static->paths}, |
|
3
|
|
|
|
|
16
|
|
29
|
|
|
|
|
|
|
File::Spec->catdir( File::Basename::dirname(__FILE__), 'Humane' ); |
30
|
|
|
|
|
|
|
}; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# Notification method |
34
|
|
|
|
|
|
|
sub notifications { |
35
|
9
|
|
|
9
|
1
|
24
|
my ($self, $c, $notify_array, $rule, @post) = @_; |
36
|
|
|
|
|
|
|
|
37
|
9
|
100
|
66
|
|
|
44
|
my $types = shift @post if ref $post[0] && ref $post[0] eq 'ARRAY'; |
38
|
|
|
|
|
|
|
|
39
|
9
|
50
|
66
|
|
|
29
|
return unless @$notify_array || @$types; |
40
|
|
|
|
|
|
|
|
41
|
9
|
|
66
|
|
|
43
|
my $base_class = shift @post // $self->base_class; |
42
|
|
|
|
|
|
|
|
43
|
9
|
|
|
|
|
51
|
my $js = ''; |
44
|
9
|
50
|
|
|
|
27
|
unless ($rule->{no_include}) { |
45
|
9
|
|
|
|
|
40
|
$js .= $c->javascript($self->scripts); |
46
|
|
|
|
|
|
|
|
47
|
9
|
50
|
|
|
|
7245
|
unless ($rule->{no_css}) { |
48
|
9
|
|
|
|
|
50
|
$js .= $c->stylesheet($path . $base_class . '.css'); |
49
|
|
|
|
|
|
|
}; |
50
|
|
|
|
|
|
|
}; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# Start JavaScript snippet |
53
|
9
|
|
|
|
|
6373
|
$js .= qq{\n" . $noscript . ''); |
117
|
|
|
|
|
|
|
}; |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
1; |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
__END__ |