line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::Notifications::HTML; |
2
|
8
|
|
|
8
|
|
4490
|
use Mojo::Base 'Mojolicious::Plugin::Notifications::Engine'; |
|
8
|
|
|
|
|
21
|
|
|
8
|
|
|
|
|
60
|
|
3
|
8
|
|
|
8
|
|
1150
|
use Exporter 'import'; |
|
8
|
|
|
|
|
24
|
|
|
8
|
|
|
|
|
259
|
|
4
|
8
|
|
|
8
|
|
46
|
use Mojo::Util qw/xml_escape/; |
|
8
|
|
|
|
|
18
|
|
|
8
|
|
|
|
|
418
|
|
5
|
8
|
|
|
8
|
|
56
|
use Scalar::Util qw/blessed/; |
|
8
|
|
|
|
|
17
|
|
|
8
|
|
|
|
|
338
|
|
6
|
8
|
|
|
8
|
|
63
|
use Mojo::ByteStream 'b'; |
|
8
|
|
|
|
|
16
|
|
|
8
|
|
|
|
|
4334
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our @EXPORT_OK = ('notify_html'); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# TODO: |
11
|
|
|
|
|
|
|
# Make the form have a class instead of the button! |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# TODO: |
14
|
|
|
|
|
|
|
# Maybe make the buttons be part of a single form. |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# TODO: |
17
|
|
|
|
|
|
|
# Add a redirect URL with ClosedRedirect, so it's ensured |
18
|
|
|
|
|
|
|
# a redirect won't be misused. |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# Exportable function |
21
|
|
|
|
|
|
|
sub notify_html { |
22
|
54
|
100
|
66
|
54
|
1
|
2649
|
my $c = shift if blessed $_[0] && $_[0]->isa('Mojolicious::Controller'); |
23
|
54
|
|
|
|
|
142
|
my $type = shift; |
24
|
54
|
100
|
100
|
|
|
258
|
my $param = shift if ref $_[0] && ref $_[0] eq 'HASH'; |
25
|
54
|
|
|
|
|
114
|
my $msg = pop; |
26
|
|
|
|
|
|
|
|
27
|
54
|
|
|
|
|
172
|
my $str = qq{ }; |
28
|
54
|
100
|
66
|
|
|
338
|
$str .= blessed $msg && $msg->isa('Mojo::ByteStream') ? $msg : xml_escape($msg); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# Check for confirmation |
31
|
54
|
100
|
|
|
|
853
|
if ($param) { |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# Okay path is defined |
34
|
27
|
100
|
|
|
|
148
|
if ($param->{ok}) { |
35
|
10
|
|
|
|
|
78
|
$str .= ' |
36
|
10
|
100
|
|
|
|
1677
|
$str .= $c->csrf_field if $c; |
37
|
10
|
|
100
|
|
|
1631
|
$str .= ''; |
38
|
10
|
|
|
|
|
33
|
$str .= ''; |
39
|
|
|
|
|
|
|
}; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# Cancel path is defined |
42
|
27
|
100
|
|
|
|
93
|
if ($param->{cancel}) { |
43
|
10
|
|
|
|
|
77
|
$str .= ' |
44
|
10
|
50
|
|
|
|
1692
|
$str .= $c->csrf_field if $c; |
45
|
10
|
|
100
|
|
|
1400
|
$str .= ''; |
46
|
10
|
|
|
|
|
32
|
$str .= ''; |
47
|
|
|
|
|
|
|
}; |
48
|
|
|
|
|
|
|
}; |
49
|
54
|
|
|
|
|
282
|
return $str . "\n"; |
50
|
|
|
|
|
|
|
}; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# Notification method |
54
|
|
|
|
|
|
|
sub notifications { |
55
|
12
|
|
|
12
|
1
|
39
|
my ($self, $c, $notify_array) = @_; |
56
|
|
|
|
|
|
|
|
57
|
12
|
|
|
|
|
29
|
my $html = ''; |
58
|
12
|
|
|
|
|
34
|
foreach (@$notify_array) { |
59
|
21
|
|
|
|
|
42
|
$html .= notify_html($c, @{$_}); |
|
21
|
|
|
|
|
82
|
|
60
|
|
|
|
|
|
|
}; |
61
|
|
|
|
|
|
|
|
62
|
12
|
|
|
|
|
62
|
return b($html); |
63
|
|
|
|
|
|
|
}; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
1; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
__END__ |