| 1 | package Kwiki::IRCMode; | ||||||||||||||
| 2 | 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 | <rjbs> Hey, is there an IRC block for Kwiki? | ||||||||||||||
| 25 | <z00s> No. Why don't you shut up and write one? | ||||||||||||||
| 26 | <rjbs> Maybe I will! | ||||||||||||||
| 27 | <z00s> Maybe you should! | ||||||||||||||
| 28 | <rjbs> FINE! | ||||||||||||||
| 29 | .irc | ||||||||||||||
| 30 | |||||||||||||||
| 31 | =cut | ||||||||||||||
| 32 | |||||||||||||||
| 33 | 2 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 34 | 2 | ▶ | use warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 35 | 2 | ▶ | use Kwiki::Plugin '-Base'; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 36 | 2 | ▶ | use Kwiki::Installer '-Base'; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 37 | |||||||||||||||
| 38 | 2 | const class_id => 'irc'; | |||||||||||||
| 39 | 2 | const css_file => 'irc.css'; | |||||||||||||
| 40 | 2 | const class_title => 'Kwiki IRC Log Waffle'; | |||||||||||||
| 41 | |||||||||||||||
| 42 | 0 | ▶ | sub register { | ||||||||||||
|
Subroutine
register: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||
| 43 | 0 | my $registry = shift; | |||||||||||||
| 44 | 0 | $registry->add(wafl => irc => 'Kwiki::IRCMode::Wafl' ); | |||||||||||||
| 45 | } | ||||||||||||||
| 46 | |||||||||||||||
| 47 | package Kwiki::IRCMode::Wafl; | ||||||||||||||
| 48 | 2 | ▶ | use base qw(Spoon::Formatter::WaflBlock); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 49 | |||||||||||||||
| 50 | 2 | ▶ | use Parse::IRCLog; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 51 | 2 | 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 | 0 | ▶ | sub to_html { | ||||||||||||
|
Subroutine
to_html: not called CC=7 SCAR=40.3
| |||||||||||||||
| 60 | 0 | my (@msgs, %nicks); | |||||||||||||
| 61 | |||||||||||||||
| 62 | 0 | my $html = "<blockquote class='irc'>\n"; | |||||||||||||
| 63 | |||||||||||||||
| 64 | 0 | for (split("\n", $self->block_text)) { | |||||||||||||
| 65 | 0 | ▶ | my $event = $p->parse_line($_); $event->{nick_prefix} ||= ''; | ||||||||||||
|
Condition0%0/2
$event->{"nick_prefix"} ||= ""
MC/DC0%0/1
$event->{"nick_prefix"} ||= ""
$event->{"nick_prefix"}
Truth table0%0/2
A
A= $event->{"nick_prefix"}
| |||||||||||||||
| 66 | 0 | ▶ | defined $nicks{$event->{nick}} or $nicks{$event->{nick}} = scalar keys %nicks; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 67 | 0 | $html .= "<p>"; | |||||||||||||
| 68 | 0 | ▶ | if (defined $event->{timestamp}) { $html .= "[$event->{timestamp}]"; } | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 69 | 0 | ▶ | if ($event->{type} eq 'msg') { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 70 | 0 | $html .= | |||||||||||||
| 71 | "<$event->{nick_prefix}<span class='u$nicks{$event->{nick}}'>$event->{nick}</span>> $event->{text}"; | ||||||||||||||
| 72 | } elsif ($event->{type} eq 'action') { | ||||||||||||||
| 73 | 0 | $html .= | |||||||||||||
| 74 | " * <span class='u$nicks{$event->{nick}}'>$event->{nick}</span> $event->{text}"; | ||||||||||||||
| 75 | } else { | ||||||||||||||
| 76 | 0 | $html .= "$event->{text}"; | |||||||||||||
| 77 | } | ||||||||||||||
| 78 | 0 | $html .= "</p>\n"; | |||||||||||||
| 79 | } | ||||||||||||||
| 80 | |||||||||||||||
| 81 | 0 | $html .= "</blockquote>\n"; | |||||||||||||
| 82 | |||||||||||||||
| 83 | 0 | return $html; | |||||||||||||
| 84 | } | ||||||||||||||
| 85 | |||||||||||||||
| 86 | =head1 TODO | ||||||||||||||
| 87 | |||||||||||||||
| 88 | =head1 AUTHOR | ||||||||||||||
| 89 | |||||||||||||||
| 90 | Ricardo SIGNES, <C<rjbs@cpan.org>> | ||||||||||||||
| 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 | 2 | __DATA__ | |||||||||||||