line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::Livedoor::Wiki::Plugin::Block; |
2
|
|
|
|
|
|
|
|
3
|
7
|
|
|
7
|
|
29263
|
use warnings; |
|
7
|
|
|
|
|
17
|
|
|
7
|
|
|
|
|
224
|
|
4
|
7
|
|
|
7
|
|
38
|
use strict; |
|
7
|
|
|
|
|
17
|
|
|
7
|
|
|
|
|
240
|
|
5
|
7
|
|
|
7
|
|
37
|
use base qw(Class::Data::Inheritable); |
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
3077
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
__PACKAGE__->mk_classdata('trigger'); |
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
1
|
54
|
sub check { die 'implement me'; } |
10
|
1
|
|
|
1
|
1
|
59
|
sub get { die 'implement me'; } |
11
|
12
|
|
|
12
|
1
|
60
|
sub mobile { shift->get(@_) } |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub trigger_check { |
14
|
257
|
|
|
257
|
1
|
375
|
my $class = shift; |
15
|
257
|
|
|
|
|
313
|
my $id = shift; |
16
|
257
|
|
|
|
|
428
|
my $line = shift; |
17
|
257
|
|
|
|
|
517
|
my $trigger = $Text::Livedoor::Wiki::scratchpad->{core}{block_trigger}; |
18
|
|
|
|
|
|
|
|
19
|
257
|
|
|
|
|
320
|
my $skip = 0; |
20
|
257
|
|
|
|
|
712
|
my $child_check = $class->get_child($id) ; |
21
|
|
|
|
|
|
|
|
22
|
257
|
100
|
|
|
|
541
|
if( $child_check ) { |
23
|
40
|
100
|
|
|
|
210
|
$skip = $trigger->{$child_check}{escape} ? 1 : 0; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
257
|
|
|
|
|
645
|
for my $key ( keys %$trigger ) { |
27
|
487
|
100
|
|
|
|
1013
|
last if $skip; |
28
|
|
|
|
|
|
|
# append stocks |
29
|
460
|
100
|
|
|
|
23500
|
if ( $line =~ m/\G($trigger->{$key}{start})/ ) { |
30
|
12
|
|
|
|
|
102
|
$class->push_children( $id, $key ); |
31
|
|
|
|
|
|
|
# warn 'size_up:' . $line . ':' .$id.':'. scalar @{$Text::Livedoor::Wiki::scratchpad->{block}{$id}{children}}; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
257
|
100
|
|
|
|
787
|
if ( my $child = $class->get_child($id) ) { |
36
|
49
|
100
|
|
|
|
347
|
if ( $line =~ m/\G($trigger->{$child}{end})/ ) { |
37
|
|
|
|
|
|
|
#warn 'killed:' . $id . ':' .$line ; |
38
|
12
|
|
|
|
|
67
|
$class->kill_child( $id ); |
39
|
12
|
|
|
|
|
125
|
return 0; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
else { |
42
|
37
|
|
|
|
|
336
|
return 0; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
208
|
|
|
|
|
2796
|
1; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub kill_child { |
51
|
12
|
|
|
12
|
1
|
21
|
my $class = shift; |
52
|
12
|
|
|
|
|
21
|
my $id = shift; |
53
|
12
|
|
|
|
|
66
|
pop @{$Text::Livedoor::Wiki::scratchpad->{block}{$id}{children}}; |
|
12
|
|
|
|
|
46
|
|
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub get_child { |
57
|
602
|
|
|
602
|
1
|
1259
|
my $class = shift; |
58
|
602
|
|
|
|
|
673
|
my $id = shift; |
59
|
602
|
100
|
|
|
|
2672
|
return unless $Text::Livedoor::Wiki::scratchpad->{block}{$id}{children}; |
60
|
|
|
|
|
|
|
|
61
|
115
|
|
|
|
|
6026
|
return $Text::Livedoor::Wiki::scratchpad->{block}{$id}{children}[-1]; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub push_children { |
65
|
12
|
|
|
12
|
1
|
22
|
my $class = shift; |
66
|
12
|
|
|
|
|
22
|
my $id = shift; |
67
|
12
|
|
|
|
|
18
|
my $key = shift; |
68
|
12
|
|
100
|
|
|
78
|
$Text::Livedoor::Wiki::scratchpad->{block}{$id}{children} ||= []; |
69
|
12
|
|
|
|
|
15
|
push @{ $Text::Livedoor::Wiki::scratchpad->{block}{$id}{children} }, $key; |
|
12
|
|
|
|
|
65
|
|
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub opts { |
73
|
15
|
|
|
15
|
1
|
71
|
return $Text::Livedoor::Wiki::opts; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
1; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 NAME |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Text::Livedoor::Wiki::Plugin::Block - Block Plugin Base Class |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 DESCRIPTION |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
you can use this class as base to create Base Plugin. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 SYNOPSIS |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
package Text::Livedoor::Wiki::Plugin::Block::Pre; |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
use warnings; |
90
|
|
|
|
|
|
|
use strict; |
91
|
|
|
|
|
|
|
use base qw(Text::Livedoor::Wiki::Plugin::Block); |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub check { |
94
|
|
|
|
|
|
|
my $self = shift; |
95
|
|
|
|
|
|
|
my $line = shift; |
96
|
|
|
|
|
|
|
my $args = shift; |
97
|
|
|
|
|
|
|
my $on_next = $args->{on_next}; |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
if( $line =~ /^\^/ ) { |
100
|
|
|
|
|
|
|
$line =~ s/^\^// unless $on_next;; |
101
|
|
|
|
|
|
|
return { line => $line . "\n" }; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
return; |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub get { |
108
|
|
|
|
|
|
|
my $self = shift; |
109
|
|
|
|
|
|
|
my $block = shift; |
110
|
|
|
|
|
|
|
my $inline = shift; |
111
|
|
|
|
|
|
|
my $items = shift; |
112
|
|
|
|
|
|
|
my $html = ''; |
113
|
|
|
|
|
|
|
$html .= $inline->parse( $_->{line} ) . "\n" for @$items; |
114
|
|
|
|
|
|
|
return "\n$html \n"; |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
1; |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 FUNCTION |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head2 trigger |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
for $class->trigger_check. If your plugin has start tag and end tag then you should set it , |
124
|
|
|
|
|
|
|
otherwise the other plugin does not know your plugin so , they may be mess up your block. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=over 4 |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=item start |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
regexp for start tag |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=item end |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
regexp for end tag |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=item escape |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
set 1 if your plugin escape Wiki parser in your block. |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=back |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head2 check |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
implement validation |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head2 get |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
implement Wiki to HTML. |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head2 mobile |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
if you did not use it , then $class->get() return. |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head2 trigger_check |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
use checking the other plugin status. |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=head2 kill_child |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
kill child block |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head2 get_child |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
get child block |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=head2 push_children |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
push new child |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=head2 opts |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
get opts |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=head1 AUTHOR |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
polocky |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=cut |