line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::Notifications::HTML; |
2
|
8
|
|
|
8
|
|
4987
|
use Mojo::Base 'Mojolicious::Plugin::Notifications::Engine'; |
|
8
|
|
|
|
|
56
|
|
|
8
|
|
|
|
|
57
|
|
3
|
8
|
|
|
8
|
|
887
|
use Exporter 'import'; |
|
8
|
|
|
|
|
18
|
|
|
8
|
|
|
|
|
231
|
|
4
|
8
|
|
|
8
|
|
41
|
use Mojo::Util qw/xml_escape/; |
|
8
|
|
|
|
|
16
|
|
|
8
|
|
|
|
|
350
|
|
5
|
8
|
|
|
8
|
|
45
|
use Scalar::Util qw/blessed/; |
|
8
|
|
|
|
|
18
|
|
|
8
|
|
|
|
|
350
|
|
6
|
8
|
|
|
8
|
|
49
|
use Mojo::ByteStream 'b'; |
|
8
|
|
|
|
|
17
|
|
|
8
|
|
|
|
|
3778
|
|
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
|
2490
|
my $c = shift if blessed $_[0] && $_[0]->isa('Mojolicious::Controller'); |
23
|
54
|
|
|
|
|
126
|
my $type = shift; |
24
|
54
|
100
|
100
|
|
|
222
|
my $param = shift if ref $_[0] && ref $_[0] eq 'HASH'; |
25
|
54
|
|
|
|
|
103
|
my $msg = pop; |
26
|
|
|
|
|
|
|
|
27
|
54
|
|
|
|
|
130
|
my $str = qq{ }; |
28
|
54
|
100
|
66
|
|
|
259
|
$str .= blessed $msg && $msg->isa('Mojo::ByteStream') ? $msg : xml_escape($msg); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# Check for confirmation |
31
|
54
|
100
|
|
|
|
690
|
if ($param) { |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# Okay path is defined |
34
|
27
|
100
|
|
|
|
75
|
if ($param->{ok}) { |
35
|
10
|
|
|
|
|
63
|
$str .= ' |
36
|
10
|
100
|
|
|
|
1454
|
$str .= $c->csrf_field if $c; |
37
|
10
|
|
100
|
|
|
1263
|
$str .= ''; |
38
|
10
|
|
|
|
|
25
|
$str .= ''; |
39
|
|
|
|
|
|
|
}; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# Cancel path is defined |
42
|
27
|
100
|
|
|
|
74
|
if ($param->{cancel}) { |
43
|
10
|
|
|
|
|
73
|
$str .= ' |
44
|
10
|
50
|
|
|
|
1381
|
$str .= $c->csrf_field if $c; |
45
|
10
|
|
100
|
|
|
1304
|
$str .= ''; |
46
|
10
|
|
|
|
|
24
|
$str .= ''; |
47
|
|
|
|
|
|
|
}; |
48
|
|
|
|
|
|
|
}; |
49
|
54
|
|
|
|
|
209
|
return $str . "\n"; |
50
|
|
|
|
|
|
|
}; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# Notification method |
54
|
|
|
|
|
|
|
sub notifications { |
55
|
12
|
|
|
12
|
1
|
36
|
my ($self, $c, $notify_array) = @_; |
56
|
|
|
|
|
|
|
|
57
|
12
|
|
|
|
|
28
|
my $html = ''; |
58
|
12
|
|
|
|
|
28
|
foreach (@$notify_array) { |
59
|
21
|
|
|
|
|
34
|
$html .= notify_html($c, @{$_}); |
|
21
|
|
|
|
|
73
|
|
60
|
|
|
|
|
|
|
}; |
61
|
|
|
|
|
|
|
|
62
|
12
|
|
|
|
|
53
|
return b($html); |
63
|
|
|
|
|
|
|
}; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
1; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
__END__ |