line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::MostTagHelpers; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
2229713
|
use Mojo::Base 'Mojolicious::Plugin'; |
|
3
|
|
|
|
|
14058
|
|
|
3
|
|
|
|
|
24
|
|
4
|
3
|
|
|
3
|
|
5126
|
use HTML::Tagset; |
|
3
|
|
|
|
|
4789
|
|
|
3
|
|
|
|
|
2433
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = eval 0.04; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our %skip = ( |
9
|
|
|
|
|
|
|
b => 1, #Mojo::Bytestream |
10
|
|
|
|
|
|
|
c => 1, #Controller |
11
|
|
|
|
|
|
|
title => 1, |
12
|
|
|
|
|
|
|
param => 1, |
13
|
|
|
|
|
|
|
); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub register { |
16
|
2
|
|
|
2
|
1
|
90
|
my ($plugin, $app) = @_; |
17
|
2
|
|
|
|
|
31
|
foreach my $tag (keys %HTML::Tagset::isKnown) { |
18
|
216
|
100
|
|
|
|
17448
|
next if $skip{$tag}; |
19
|
210
|
|
|
|
|
354
|
$app->helper( $tag => _tag($tag) ); |
20
|
|
|
|
|
|
|
} |
21
|
2
|
|
|
|
|
208
|
$app->helper( incremental => \&_incremental ); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub _tag { |
25
|
210
|
|
|
210
|
|
280
|
my $tag = shift; |
26
|
|
|
|
|
|
|
return sub { |
27
|
11
|
|
|
11
|
|
149672
|
my $self = shift; |
28
|
11
|
|
|
|
|
17
|
my $id; |
29
|
|
|
|
|
|
|
my @class; |
30
|
11
|
100
|
|
|
|
51
|
if ($_[0] =~ /^[#.]/) { |
31
|
1
|
|
|
|
|
3
|
my $sel = shift; |
32
|
1
|
|
|
|
|
7
|
($id) = $sel =~ /\#([^#. ]+)/; |
33
|
1
|
|
|
|
|
8
|
@class = $sel =~ /\.([^#. ]+)/g; |
34
|
|
|
|
|
|
|
} |
35
|
11
|
100
|
|
|
|
243
|
return $self->tag( |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
36
|
|
|
|
|
|
|
$tag, |
37
|
|
|
|
|
|
|
$id ? ( id => $id ) : (), |
38
|
|
|
|
|
|
|
@class ? ( class => join(' ', @class) ) : (), |
39
|
|
|
|
|
|
|
!$HTML::Tagset::emptyElement{$tag} ? @_ : undef |
40
|
|
|
|
|
|
|
); |
41
|
210
|
|
|
|
|
1324
|
}; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub _gen_pod_list { |
45
|
0
|
|
|
0
|
|
0
|
my @list = map { "=item $_\n\n" } sort grep { !$skip{$_} } keys %HTML::Tagset::isKnown; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
46
|
0
|
|
|
|
|
0
|
return '=over', @list, '=back'; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub _incremental { |
50
|
2
|
|
|
2
|
|
278
|
my $c = shift; |
51
|
2
|
|
|
|
|
4
|
my $text = pop; |
52
|
2
|
|
50
|
|
|
14
|
my $i = shift || 1; |
53
|
|
|
|
|
|
|
|
54
|
2
|
100
|
|
|
|
13
|
$text = $text->() if eval { ref $text eq 'CODE' }; |
|
2
|
|
|
|
|
13
|
|
55
|
|
|
|
|
|
|
|
56
|
2
|
|
|
|
|
128
|
require Mojo::DOM; |
57
|
2
|
|
|
|
|
19
|
my $dom = Mojo::DOM->new($text); |
58
|
2
|
|
|
|
|
885
|
$dom->xml(1); |
59
|
2
|
|
|
|
|
63
|
my $children = $dom->children; |
60
|
2
|
100
|
|
|
|
375
|
if ($children->size == 1) { |
61
|
1
|
|
|
|
|
44
|
$children = $children->[0]->children; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
$children->each(sub{ |
64
|
4
|
|
|
4
|
|
127
|
$_->{ms_overlay} = $i++ . '-'; |
65
|
2
|
|
|
|
|
209
|
}); |
66
|
|
|
|
|
|
|
|
67
|
2
|
|
|
|
|
85
|
require Mojo::ByteStream; |
68
|
2
|
|
|
|
|
8
|
return Mojo::ByteStream->new($dom->to_string); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
1; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
__END__ |