line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MojoMojo::Formatter::IRCLog; |
2
|
|
|
|
|
|
|
|
3
|
27
|
|
|
27
|
|
67590
|
use parent qw/MojoMojo::Formatter/; |
|
27
|
|
|
|
|
304
|
|
|
27
|
|
|
|
|
195
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
MojoMojo::Formatter::IRCLog - format part of content as an IRC log |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 DESCRIPTION |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
This formatter will format content between {{irc}} and {{end}} as |
12
|
|
|
|
|
|
|
an IRC log |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 METHODS |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head2 format_content_order |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
Format order can be 1-99. The IRC log formatter runs on 14, |
19
|
|
|
|
|
|
|
just before the main formatter. |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=cut |
22
|
|
|
|
|
|
|
|
23
|
992
|
|
|
992
|
1
|
3543
|
sub format_content_order { 14 } |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head2 format_content |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
Calls the formatter. Takes a ref to the content as well as the |
28
|
|
|
|
|
|
|
context object. |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=cut |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub format_content { |
33
|
133
|
|
|
133
|
1
|
5283
|
my ( $class, $content ) = @_; |
34
|
133
|
|
|
|
|
366
|
my ( $in_log, %nicks, $longline, @newlines ); |
35
|
|
|
|
|
|
|
|
36
|
133
|
|
|
|
|
843
|
my @lines = split( /\n/, $$content ); |
37
|
133
|
|
|
|
|
373
|
$$content = ""; |
38
|
133
|
|
|
|
|
813
|
my $start_re=$class->gen_re(qr/irc/); |
39
|
133
|
|
|
|
|
722
|
my $end_re=$class->gen_re(qr/end/); |
40
|
|
|
|
|
|
|
|
41
|
133
|
|
|
|
|
718
|
foreach my $line (@lines) { |
42
|
704
|
100
|
|
|
|
1470
|
if ($in_log) { |
43
|
23
|
100
|
|
|
|
102
|
if ( $line =~ $end_re ) { |
|
|
100
|
|
|
|
|
|
44
|
10
|
|
|
|
|
16
|
$in_log = 0; |
45
|
10
|
50
|
|
|
|
22
|
if ($longline) { |
46
|
10
|
|
|
|
|
18
|
$longline .= "</dd>"; |
47
|
10
|
|
|
|
|
16
|
push( @newlines, $longline ); |
48
|
10
|
|
|
|
|
16
|
$longline = ""; |
49
|
|
|
|
|
|
|
} |
50
|
10
|
|
|
|
|
18
|
push @newlines, $line; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
elsif ( $line =~ /^[\d:]*\s*<[+\%\@ ]?(.*?)>\s*(.*)/ ) { |
53
|
10
|
50
|
|
|
|
24
|
if ($longline) { |
54
|
0
|
|
|
|
|
0
|
$longline .= "</dd>"; |
55
|
0
|
|
|
|
|
0
|
push( @newlines, $longline ); |
56
|
0
|
|
|
|
|
0
|
$longline = ""; |
57
|
|
|
|
|
|
|
} |
58
|
10
|
|
|
|
|
27
|
$nicks{$1} = 1; |
59
|
10
|
|
|
|
|
30
|
$longline = "<dt>$1</dt>\n<dd>$2"; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
else { |
62
|
3
|
|
|
|
|
8
|
$line =~ s/^\s*/ /; |
63
|
3
|
|
|
|
|
7
|
$longline .= $line; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
else { |
67
|
681
|
100
|
|
|
|
2280
|
if ( $line =~ $start_re ) { |
68
|
10
|
|
|
|
|
20
|
push @newlines, $line; |
69
|
10
|
|
|
|
|
14
|
$in_log = 1; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
else { |
72
|
671
|
|
|
|
|
1423
|
push( @newlines, $line ); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
} |
76
|
133
|
|
|
|
|
393
|
foreach my $line (@newlines) { |
77
|
701
|
100
|
|
|
|
1356
|
if ($in_log) { |
78
|
20
|
100
|
|
|
|
68
|
if ( $line =~ $end_re ) { |
79
|
10
|
|
|
|
|
16
|
$in_log = 0; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
# end the dl and the section not handled by textile |
82
|
10
|
|
|
|
|
42
|
$$content .= "</dl>\n==\n"; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
else { |
85
|
10
|
|
|
|
|
14
|
my $count = 0; |
86
|
10
|
|
|
|
|
30
|
my @colours=( 'navy', 'green' , 'maroon', 'blue', 'lime', 'red', 'silver', 'gray', 'teal', 'olive', 'purple', 'fuchsia' ); |
87
|
10
|
|
|
|
|
15
|
my $counter; |
88
|
10
|
|
|
|
|
23
|
foreach my $nick ( keys %nicks ) { |
89
|
10
|
|
|
|
|
19
|
$colour=$colours[$counter++]; |
90
|
10
|
|
|
|
|
89
|
$count += ( $line =~ s!(<d.>)$nick(</d.>)!$1<font color="$colour">[[$nick]]</font>$2!g ); |
91
|
|
|
|
|
|
|
} |
92
|
10
|
|
|
|
|
31
|
$$content .= "$line\n"; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
else { |
96
|
681
|
100
|
|
|
|
2345
|
if ( $line =~ $start_re ) { |
97
|
10
|
|
|
|
|
12
|
$in_log = 1; |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
# start a definition list in a section not handled by |
100
|
|
|
|
|
|
|
# textile |
101
|
10
|
|
|
|
|
18
|
$$content .= "==\n<dl>\n"; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
else { |
104
|
671
|
|
|
|
|
1932
|
$$content .= "$line\n"; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 SEE ALSO |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
L<MojoMojo> and L<Module::Pluggable::Ordered>. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 AUTHORS |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Martijn van Beers <martijn@eekeek.org> |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 LICENSE |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
This library is free software. You can redistribute it and/or modify |
121
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=cut |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
1; |