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