| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package App::MojoSlides::MoreTagHelpers; | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 5 |  |  | 5 |  | 4396 | use Mojo::Base 'Mojolicious::Plugin'; | 
|  | 5 |  |  |  |  | 8 |  | 
|  | 5 |  |  |  |  | 26 |  | 
| 4 |  |  |  |  |  |  |  | 
| 5 |  |  |  |  |  |  | # list stolen from HTML::Tags (Web::Simple) | 
| 6 |  |  |  |  |  |  | my @HTML_TAGS = qw( | 
| 7 |  |  |  |  |  |  | a | 
| 8 |  |  |  |  |  |  | aside | 
| 9 |  |  |  |  |  |  | audio | 
| 10 |  |  |  |  |  |  | blockquote | 
| 11 |  |  |  |  |  |  | body | 
| 12 |  |  |  |  |  |  | br | 
| 13 |  |  |  |  |  |  | button | 
| 14 |  |  |  |  |  |  | canvas | 
| 15 |  |  |  |  |  |  | caption | 
| 16 |  |  |  |  |  |  | cite | 
| 17 |  |  |  |  |  |  | code | 
| 18 |  |  |  |  |  |  | col | 
| 19 |  |  |  |  |  |  | colgroup | 
| 20 |  |  |  |  |  |  | div | 
| 21 |  |  |  |  |  |  | dd | 
| 22 |  |  |  |  |  |  | del | 
| 23 |  |  |  |  |  |  | dl | 
| 24 |  |  |  |  |  |  | dt | 
| 25 |  |  |  |  |  |  | em | 
| 26 |  |  |  |  |  |  | embed | 
| 27 |  |  |  |  |  |  | fieldset | 
| 28 |  |  |  |  |  |  | figcaption | 
| 29 |  |  |  |  |  |  | figure | 
| 30 |  |  |  |  |  |  | footer | 
| 31 |  |  |  |  |  |  | h1 | 
| 32 |  |  |  |  |  |  | h2 | 
| 33 |  |  |  |  |  |  | h3 | 
| 34 |  |  |  |  |  |  | h4 | 
| 35 |  |  |  |  |  |  | h5 | 
| 36 |  |  |  |  |  |  | h6 | 
| 37 |  |  |  |  |  |  | head | 
| 38 |  |  |  |  |  |  | header | 
| 39 |  |  |  |  |  |  | hr | 
| 40 |  |  |  |  |  |  | html | 
| 41 |  |  |  |  |  |  | i | 
| 42 |  |  |  |  |  |  | iframe | 
| 43 |  |  |  |  |  |  | img | 
| 44 |  |  |  |  |  |  | label | 
| 45 |  |  |  |  |  |  | legend | 
| 46 |  |  |  |  |  |  | li | 
| 47 |  |  |  |  |  |  | noscript | 
| 48 |  |  |  |  |  |  | object | 
| 49 |  |  |  |  |  |  | ol | 
| 50 |  |  |  |  |  |  | optgroup | 
| 51 |  |  |  |  |  |  | option | 
| 52 |  |  |  |  |  |  | output | 
| 53 |  |  |  |  |  |  | p | 
| 54 |  |  |  |  |  |  | pre | 
| 55 |  |  |  |  |  |  | rp | 
| 56 |  |  |  |  |  |  | rt | 
| 57 |  |  |  |  |  |  | ruby | 
| 58 |  |  |  |  |  |  | script | 
| 59 |  |  |  |  |  |  | span | 
| 60 |  |  |  |  |  |  | strong | 
| 61 |  |  |  |  |  |  | style | 
| 62 |  |  |  |  |  |  | table | 
| 63 |  |  |  |  |  |  | tbody | 
| 64 |  |  |  |  |  |  | td | 
| 65 |  |  |  |  |  |  | textarea | 
| 66 |  |  |  |  |  |  | tfoot | 
| 67 |  |  |  |  |  |  | th | 
| 68 |  |  |  |  |  |  | thead | 
| 69 |  |  |  |  |  |  | tr | 
| 70 |  |  |  |  |  |  | ul | 
| 71 |  |  |  |  |  |  | video | 
| 72 |  |  |  |  |  |  | ); | 
| 73 |  |  |  |  |  |  |  | 
| 74 |  |  |  |  |  |  | sub register { | 
| 75 | 4 |  |  | 4 | 1 | 168 | my ($plugin, $app) = @_; | 
| 76 | 4 |  |  |  |  | 8 | foreach my $tag (@HTML_TAGS) { | 
| 77 | 260 |  |  |  |  | 1959 | $app->helper( $tag => _tag($tag) ); | 
| 78 |  |  |  |  |  |  | } | 
| 79 | 4 |  |  |  |  | 36 | $app->helper( incremental => \&_incremental ); | 
| 80 |  |  |  |  |  |  | } | 
| 81 |  |  |  |  |  |  |  | 
| 82 |  |  |  |  |  |  | sub _tag { | 
| 83 | 260 |  |  | 260 |  | 186 | my $tag = shift; | 
| 84 |  |  |  |  |  |  | return sub { | 
| 85 | 16 |  |  | 16 |  | 63263 | my $self = shift; | 
| 86 | 16 |  |  |  |  | 20 | my $id; | 
| 87 |  |  |  |  |  |  | my @class; | 
| 88 | 16 | 100 |  |  |  | 62 | if ($_[0] =~ /^[#.]/) { | 
| 89 | 4 |  |  |  |  | 8 | my $sel = shift; | 
| 90 | 4 |  |  |  |  | 20 | ($id)  = $sel =~ /\#([^#. ]+)/; | 
| 91 | 4 |  |  |  |  | 13 | @class = $sel =~ /\.([^#. ]+)/g; | 
| 92 |  |  |  |  |  |  | } | 
| 93 | 16 | 100 |  |  |  | 151 | return $self->tag( | 
|  |  | 100 |  |  |  |  |  | 
| 94 |  |  |  |  |  |  | $tag, | 
| 95 |  |  |  |  |  |  | $id ? ( id => $id ) : (), | 
| 96 |  |  |  |  |  |  | @class ? ( class => join(' ', @class) ) : (), | 
| 97 |  |  |  |  |  |  | @_ | 
| 98 |  |  |  |  |  |  | ); | 
| 99 | 260 |  |  |  |  | 687 | }; | 
| 100 |  |  |  |  |  |  | } | 
| 101 |  |  |  |  |  |  |  | 
| 102 |  |  |  |  |  |  | sub _gen_pod_list { | 
| 103 | 0 |  |  | 0 |  | 0 | my @list = map { "=item $_" } @HTML_TAGS; | 
|  | 0 |  |  |  |  | 0 |  | 
| 104 | 0 |  |  |  |  | 0 | return '=over', @list, '=back'; | 
| 105 |  |  |  |  |  |  | } | 
| 106 |  |  |  |  |  |  |  | 
| 107 |  |  |  |  |  |  | sub _incremental { | 
| 108 | 2 |  |  | 2 |  | 126 | my $c = shift; | 
| 109 | 2 |  |  |  |  | 3 | my $text = pop; | 
| 110 | 2 |  | 50 |  |  | 11 | my $i = shift || 1; | 
| 111 |  |  |  |  |  |  |  | 
| 112 | 2 | 100 |  |  |  | 4 | $text = $text->() if eval { ref $text eq 'CODE' }; | 
|  | 2 |  |  |  |  | 10 |  | 
| 113 |  |  |  |  |  |  |  | 
| 114 | 2 |  |  |  |  | 66 | require Mojo::DOM; | 
| 115 | 2 |  |  |  |  | 10 | my $dom = Mojo::DOM->new($text); | 
| 116 | 2 |  |  |  |  | 461 | my $children = $dom->children; | 
| 117 | 2 | 100 |  |  |  | 138 | if ($children->size == 1) { | 
| 118 | 1 |  |  |  |  | 8 | $children = $children->[0]->children; | 
| 119 |  |  |  |  |  |  | } | 
| 120 |  |  |  |  |  |  | $children->each(sub{ | 
| 121 | 4 |  |  | 4 |  | 46 | $_->{ms_overlay} = $i++ . '-'; | 
| 122 | 2 |  |  |  |  | 74 | }); | 
| 123 |  |  |  |  |  |  |  | 
| 124 | 2 |  |  |  |  | 31 | require Mojo::ByteStream; | 
| 125 | 2 |  |  |  |  | 5 | return Mojo::ByteStream->new($dom->to_string); | 
| 126 |  |  |  |  |  |  | } | 
| 127 |  |  |  |  |  |  |  | 
| 128 |  |  |  |  |  |  | 1; | 
| 129 |  |  |  |  |  |  |  | 
| 130 |  |  |  |  |  |  | __END__ |