line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Kwiki::IRCMode; |
2
|
|
|
|
|
|
|
our $VERSION = '0.302'; |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
=head1 NAME |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
Kwiki::IRCMode - colorized IRC conversations in your Kwiki |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 VERSION |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
version 0.302 |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 SYNOPSIS |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
$ cpan Kwiki::IRCMode |
15
|
|
|
|
|
|
|
$ cd /path/to/kwiki |
16
|
|
|
|
|
|
|
$ kwiki -add Kwiki::IRCMode |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 DESCRIPTION |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
This module registers a ".irc" block, which will format IRC conversations like |
21
|
|
|
|
|
|
|
the following: |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
.irc |
24
|
|
|
|
|
|
|
Hey, is there an IRC block for Kwiki? |
25
|
|
|
|
|
|
|
No. Why don't you shut up and write one? |
26
|
|
|
|
|
|
|
Maybe I will! |
27
|
|
|
|
|
|
|
Maybe you should! |
28
|
|
|
|
|
|
|
FINE! |
29
|
|
|
|
|
|
|
.irc |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=cut |
32
|
|
|
|
|
|
|
|
33
|
1
|
|
|
1
|
|
22469
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
38
|
|
34
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
40
|
|
35
|
1
|
|
|
1
|
|
390
|
use Kwiki::Plugin '-Base'; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
use Kwiki::Installer '-Base'; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
const class_id => 'irc'; |
39
|
|
|
|
|
|
|
const css_file => 'irc.css'; |
40
|
|
|
|
|
|
|
const class_title => 'Kwiki IRC Log Waffle'; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub register { |
43
|
|
|
|
|
|
|
my $registry = shift; |
44
|
|
|
|
|
|
|
$registry->add(wafl => irc => 'Kwiki::IRCMode::Wafl' ); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
package Kwiki::IRCMode::Wafl; |
48
|
|
|
|
|
|
|
use base qw(Spoon::Formatter::WaflBlock); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
use Parse::IRCLog; |
51
|
|
|
|
|
|
|
my $p = Parse::IRCLog->new; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head2 C<< $self->to_html() >> |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
This converts IRC log messages to HTML. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=cut |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub to_html { |
60
|
|
|
|
|
|
|
my (@msgs, %nicks); |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
my $html = "\n"; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
for (split("\n", $self->block_text)) { |
65
|
|
|
|
|
|
|
my $event = $p->parse_line($_); $event->{nick_prefix} ||= ''; |
66
|
|
|
|
|
|
|
defined $nicks{$event->{nick}} or $nicks{$event->{nick}} = scalar keys %nicks; |
67
|
|
|
|
|
|
|
$html .= " "; |
68
|
|
|
|
|
|
|
if (defined $event->{timestamp}) { $html .= "[$event->{timestamp}]"; } |
69
|
|
|
|
|
|
|
if ($event->{type} eq 'msg') { |
70
|
|
|
|
|
|
|
$html .= |
71
|
|
|
|
|
|
|
"<$event->{nick_prefix}$event->{nick}> $event->{text}"; |
72
|
|
|
|
|
|
|
} elsif ($event->{type} eq 'action') { |
73
|
|
|
|
|
|
|
$html .= |
74
|
|
|
|
|
|
|
" * $event->{nick} $event->{text}"; |
75
|
|
|
|
|
|
|
} else { |
76
|
|
|
|
|
|
|
$html .= "$event->{text}"; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
$html .= "\n"; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
$html .= "\n"; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
return $html; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 TODO |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 AUTHOR |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Ricardo SIGNES, > |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 COPYRIGHT |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
This code is Copyright 2004, Ricardo SIGNES. It is licensed under the same |
95
|
|
|
|
|
|
|
terms as Perl itself. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=cut |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
package Kwiki::IRCMode; |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
__DATA__ |