--- trunk/irc-logger.pl 2006/06/16 20:51:32 28 +++ trunk/irc-logger.pl 2006/06/24 22:15:47 33 @@ -18,13 +18,17 @@ ## CONFIG -my $NICK = 'irc-logger-dev'; +my $HOSTNAME = `hostname`; + +my $NICK = 'irc-logger'; +$NICK .= '-dev' if ($HOSTNAME =~ m/llin/); my $CONNECT = {Server => 'irc.freenode.net', Nick => $NICK, Ircname => "try /msg $NICK help", }; my $CHANNEL = '#razmjenavjestina'; +$CHANNEL = '#irc-logger' if ($HOSTNAME =~ m/llin/); my $IRC_ALIAS = "log"; my %FOLLOWS = @@ -44,7 +48,7 @@ use POE qw(Component::IRC Wheel::FollowTail Component::Server::HTTP); use HTTP::Status; use DBI; -use Encode qw/from_to/; +use Encode qw/from_to is_utf8/; use Regexp::Common qw /URI/; use CGI::Simple; use HTML::TagCloud; @@ -83,6 +87,7 @@ }); my $tags; +my $tag_regex = '\b([\w-_]+)//'; =head2 get_from_log @@ -290,6 +295,8 @@ print "$channel: <$nick> $msg\n"; $sth->execute($channel, 0, $nick, $msg); + add_tag( id => $dbh->last_insert_id(undef,undef,"log",undef), + message => $msg); }, irc_ctcp_action => sub { my $kernel = $_[KERNEL]; @@ -301,6 +308,8 @@ print "$channel ***$nick $msg\n"; $sth->execute($channel, 1, $nick, $msg); + add_tag( id => $dbh->last_insert_id(undef,undef,"log",undef), + message => $msg); }, irc_msg => sub { my $kernel = $_[KERNEL]; @@ -494,10 +503,15 @@ return unless ($arg->{id} && $arg->{message}); - while ($arg->{message} =~ s#\b(\S+)//##s) { + my $m = $arg->{message}; + from_to('UTF-8', 'iso-8859-2', $m) if (is_utf8($m)); + + while ($m =~ s#$tag_regex##s) { my $tag = $1; next if (! $tag || $tag =~ m/https?:/i); push @{ $tags->{$tag} }, $arg->{id}; + #warn "+tag $tag: $arg->{id}\n"; + $cloud->add($tag, "?tag=$tag", scalar @{$tags->{$tag}} + 1); } } @@ -544,6 +558,8 @@ .col-2 { background: #99ff99 } .col-3 { background: #ff9999 } .col-4 { background: #ff66ff } +a:link.tag, a:visited.tag { border: 1px dashed #ccc; backgound: #ccc; text-decoration: none } +a:hover.tag { border: 1px solid #eee } _END_OF_STYLE_ my $max_color = 4; @@ -572,18 +588,18 @@ $cloud->css . qq{} . qq{ - } . - qq{
} . $cloud->html(500) . qq{
} . + $cloud->html(500) . qq{

} . join("

", get_from_log( limit => $q->param('last') || 100, search => $search || undef, - tag => $q->param('tag'), + tag => $q->param('tag') || undef, fmt => { date => '


%s
', time => '%s ', @@ -597,6 +613,7 @@ my $m = shift || return; $m =~ s/($escape_re)/$escape{$1}/gs; $m =~ s#($RE{URI}{HTTP})#$1#gs; + $m =~ s#$tag_regex#$1#g; return $m; }, nick => sub {