58 |
|
|
59 |
my $sleep_on_error = 5; |
my $sleep_on_error = 5; |
60 |
|
|
61 |
|
my $http_port = $NICK =~ m/-dev/ ? 8001 : 8000; |
62 |
|
my $http_hostname = `hostname`; |
63 |
|
chomp( $http_hostname ); |
64 |
|
|
65 |
## END CONFIG |
## END CONFIG |
66 |
|
|
67 |
|
|
77 |
use HTML::CalendarMonthSimple; |
use HTML::CalendarMonthSimple; |
78 |
use Getopt::Long; |
use Getopt::Long; |
79 |
use DateTime; |
use DateTime; |
80 |
|
use URI::Escape; |
81 |
use Data::Dump qw/dump/; |
use Data::Dump qw/dump/; |
82 |
|
use DateTime::Format::ISO8601; |
83 |
|
use Carp qw/confess/; |
84 |
|
use XML::Feed; |
85 |
|
use DateTime::Format::Flexible; |
86 |
|
|
87 |
my $use_twitter = 1; |
my $use_twitter = 1; |
88 |
eval { require Net::Twitter; }; |
eval { require Net::Twitter; }; |
95 |
'log:s' => \$log_path, |
'log:s' => \$log_path, |
96 |
); |
); |
97 |
|
|
98 |
|
$SIG{__DIE__} = sub { |
99 |
|
confess "fatal error"; |
100 |
|
}; |
101 |
|
|
102 |
open(STDOUT, '>', $log_path) || warn "can't redirect log to $log_path: $!"; |
open(STDOUT, '>', $log_path) || warn "can't redirect log to $log_path: $!"; |
103 |
|
|
104 |
sub _log { |
sub _log { |
105 |
print strftime($TIMESTAMP,localtime()), ' ', join(" ",@_), $/; |
print strftime($TIMESTAMP,localtime()), ' ', join(" ",@_), $/; |
106 |
} |
} |
107 |
|
|
108 |
|
# HTML formatters |
109 |
|
|
110 |
|
my %escape = ('<'=>'<', '>'=>'>', '&'=>'&', '"'=>'"'); |
111 |
|
my $escape_re = join '|' => keys %escape; |
112 |
|
|
113 |
|
my $tag_regex = '\b([\w-_]+)//'; |
114 |
|
|
115 |
|
my %nick_enumerator; |
116 |
|
my $max_color = 0; |
117 |
|
|
118 |
|
my $filter = { |
119 |
|
message => sub { |
120 |
|
my $m = shift || return; |
121 |
|
|
122 |
|
# protect HTML from wiki modifications |
123 |
|
sub e { |
124 |
|
my $t = shift; |
125 |
|
return 'uri_unescape{' . uri_escape($t) . '}'; |
126 |
|
} |
127 |
|
|
128 |
|
$m =~ s/($escape_re)/$escape{$1}/gs; |
129 |
|
$m =~ s#($RE{URI}{HTTP})#e(qq{<a href="$1">$1</a>})#egs || |
130 |
|
$m =~ s#\/(\w+)\/#<i>$1</i>#gs; |
131 |
|
$m =~ s#$tag_regex#e(qq{<a href="?tag=$1" class="tag">$1</a>})#egs; |
132 |
|
$m =~ s#\*(\w+)\*#<b>$1</b>#gs; |
133 |
|
$m =~ s#_(\w+)_#<u>$1</u>#gs; |
134 |
|
|
135 |
|
$m =~ s#uri_unescape{([^}]+)}#uri_unescape($1)#egs; |
136 |
|
return $m; |
137 |
|
}, |
138 |
|
nick => sub { |
139 |
|
my $n = shift || return; |
140 |
|
if (! $nick_enumerator{$n}) { |
141 |
|
my $max = scalar keys %nick_enumerator; |
142 |
|
$nick_enumerator{$n} = $max + 1; |
143 |
|
} |
144 |
|
return '<span class="nick col-' . |
145 |
|
( $nick_enumerator{$n} % $max_color ) . |
146 |
|
'">' . $n . '</span>'; |
147 |
|
}, |
148 |
|
}; |
149 |
|
|
150 |
my $dbh = DBI->connect($DSN,"","", { RaiseError => 1, AutoCommit => 1 }) || die $DBI::errstr; |
my $dbh = DBI->connect($DSN,"","", { RaiseError => 1, AutoCommit => 1 }) || die $DBI::errstr; |
151 |
|
|
152 |
my $sql_schema = { |
my $sql_schema = { |
246 |
|
|
247 |
|
|
248 |
my $tags; |
my $tags; |
|
my $tag_regex = '\b([\w-_]+)//'; |
|
249 |
|
|
250 |
=head2 get_from_log |
=head2 get_from_log |
251 |
|
|
282 |
sub get_from_log { |
sub get_from_log { |
283 |
my $args = {@_}; |
my $args = {@_}; |
284 |
|
|
285 |
$args->{fmt} ||= { |
if ( ! $args->{fmt} ) { |
286 |
date => '[%s] ', |
$args->{fmt} = { |
287 |
time => '{%s} ', |
date => '[%s] ', |
288 |
time_channel => '{%s %s} ', |
time => '{%s} ', |
289 |
nick => '%s: ', |
time_channel => '{%s %s} ', |
290 |
me_nick => '***%s ', |
nick => '%s: ', |
291 |
message => '%s', |
me_nick => '***%s ', |
292 |
}; |
message => '%s', |
293 |
|
}; |
294 |
|
} |
295 |
|
|
296 |
my $sql_message = qq{ |
my $sql_message = qq{ |
297 |
select |
select |
314 |
|
|
315 |
my $sql = $context ? $sql_context : $sql_message; |
my $sql = $context ? $sql_context : $sql_message; |
316 |
|
|
317 |
$sql .= " where message ilike ? or nick ilike ? " if ($args->{search}); |
sub check_date { |
318 |
$sql .= " where id in (" . join(",", @{ $tags->{ $args->{tag} } }) . ") " if ($args->{tag} && $tags->{ $args->{tag} }); |
my $date = shift || return; |
319 |
$sql .= " where date(time) = ? " if ($args->{date}); |
my $new_date = eval { DateTime::Format::ISO8601->parse_datetime( $date )->ymd; }; |
320 |
$sql .= " order by log.time desc"; |
if ( $@ ) { |
321 |
$sql .= " limit " . $args->{limit} if ($args->{limit}); |
warn "invalid date $date\n"; |
322 |
|
$new_date = DateTime->now->ymd; |
323 |
|
} |
324 |
|
return $new_date; |
325 |
|
} |
326 |
|
|
327 |
|
my @where; |
328 |
|
my @args; |
329 |
|
|
|
my $sth = $dbh->prepare( $sql ); |
|
330 |
if (my $search = $args->{search}) { |
if (my $search = $args->{search}) { |
331 |
$search =~ s/^\s+//; |
$search =~ s/^\s+//; |
332 |
$search =~ s/\s+$//; |
$search =~ s/\s+$//; |
333 |
$sth->execute( ( '%' . $search . '%' ) x 2 ); |
push @where, 'message ilike ? or nick ilike ?'; |
334 |
_log "search for '$search' returned ", $sth->rows, " results ", $context || ''; |
push @args, ( ( '%' . $search . '%' ) x 2 ); |
335 |
} elsif (my $tag = $args->{tag}) { |
_log "search for '$search'"; |
|
$sth->execute(); |
|
|
_log "tag '$tag' returned ", $sth->rows, " results ", $context || ''; |
|
|
} elsif (my $date = $args->{date}) { |
|
|
$sth->execute($date); |
|
|
_log "found ", $sth->rows, " messages for date $date ", $context || ''; |
|
|
} else { |
|
|
$sth->execute(); |
|
336 |
} |
} |
337 |
|
|
338 |
|
if ($args->{tag} && $tags->{ $args->{tag} }) { |
339 |
|
push @where, 'id in (' . join(',', @{ $tags->{ $args->{tag} } }) . ')'; |
340 |
|
_log "search for tags $args->{tag}"; |
341 |
|
} |
342 |
|
|
343 |
|
if (my $date = $args->{date} ) { |
344 |
|
$date = check_date( $date ); |
345 |
|
push @where, 'date(time) = ?'; |
346 |
|
push @args, $date; |
347 |
|
_log "search for date $date"; |
348 |
|
} |
349 |
|
|
350 |
|
$sql .= " where " . join(" and ", @where) if @where; |
351 |
|
|
352 |
|
$sql .= " order by log.time desc"; |
353 |
|
$sql .= " limit " . $args->{limit} if ($args->{limit}); |
354 |
|
|
355 |
|
#warn "### sql: $sql ", dump( @args ); |
356 |
|
|
357 |
|
my $sth = $dbh->prepare( $sql ); |
358 |
|
eval { $sth->execute( @args ) }; |
359 |
|
return if $@; |
360 |
|
|
361 |
my $last_row = { |
my $last_row = { |
362 |
date => '', |
date => '', |
363 |
time => '', |
time => '', |
478 |
|
|
479 |
=head2 add_tag |
=head2 add_tag |
480 |
|
|
481 |
add_tag( id => 42, message => 'irc message' ); |
add_tag( id => 42, message => 'irc message', nick => 'foobar' [, me => 1 ] ); |
482 |
|
|
483 |
=cut |
=cut |
484 |
|
|
485 |
|
my $last_x_tags = 5; |
486 |
|
my @last_tags; |
487 |
|
|
488 |
sub add_tag { |
sub add_tag { |
489 |
my $arg = {@_}; |
my $arg = {@_}; |
490 |
|
|
493 |
my $m = $arg->{message}; |
my $m = $arg->{message}; |
494 |
from_to('UTF-8', 'iso-8859-2', $m) if (is_utf8($m)); |
from_to('UTF-8', 'iso-8859-2', $m) if (is_utf8($m)); |
495 |
|
|
496 |
|
my @tags; |
497 |
|
|
498 |
while ($m =~ s#$tag_regex##s) { |
while ($m =~ s#$tag_regex##s) { |
499 |
my $tag = $1; |
my $tag = $1; |
500 |
next if (! $tag || $tag =~ m/https?:/i); |
next if (! $tag || $tag =~ m/https?:/i); |
501 |
push @{ $tags->{$tag} }, $arg->{id}; |
push @{ $tags->{$tag} }, $arg->{id}; |
502 |
#warn "+tag $tag: $arg->{id}\n"; |
#warn "+tag $tag: $arg->{id}\n"; |
503 |
$cloud->add($tag, "?tag=$tag", scalar @{$tags->{$tag}} + 1); |
$cloud->add($tag, "?tag=$tag", scalar @{$tags->{$tag}} + 1); |
504 |
|
push @tags, $tag; |
505 |
|
|
506 |
} |
} |
507 |
|
|
508 |
|
if ( @tags ) { |
509 |
|
shift @last_tags if $#last_tags == $last_x_tags; |
510 |
|
push @last_tags, { tags => [ @tags ], %$arg }; |
511 |
|
} |
512 |
|
|
513 |
} |
} |
514 |
|
|
515 |
=head2 seed_tags |
=head2 seed_tags |
519 |
=cut |
=cut |
520 |
|
|
521 |
sub seed_tags { |
sub seed_tags { |
522 |
my $sth = $dbh->prepare(qq{ select id,message from log where message like '%//%' }); |
my $sth = $dbh->prepare(qq{ select id,message,nick,me,time from log where message like '%//%' }); |
523 |
$sth->execute; |
$sth->execute; |
524 |
while (my $row = $sth->fetchrow_hashref) { |
while (my $row = $sth->fetchrow_hashref) { |
525 |
add_tag( %$row ); |
add_tag( %$row ); |
539 |
channel => '#foobar', |
channel => '#foobar', |
540 |
me => 0, |
me => 0, |
541 |
nick => 'dpavlin', |
nick => 'dpavlin', |
542 |
msg => 'test message', |
message => 'test message', |
543 |
time => '2006-06-25 18:57:18', |
time => '2006-06-25 18:57:18', |
544 |
); |
); |
545 |
|
|
551 |
|
|
552 |
sub save_message { |
sub save_message { |
553 |
my $a = {@_}; |
my $a = {@_}; |
554 |
|
confess "have msg" if $a->{msg}; |
555 |
$a->{me} ||= 0; |
$a->{me} ||= 0; |
556 |
$a->{time} ||= strftime($TIMESTAMP,localtime()); |
$a->{time} ||= strftime($TIMESTAMP,localtime()); |
557 |
|
|
558 |
_log |
_log |
559 |
$a->{channel}, " ", |
$a->{channel}, " ", |
560 |
$a->{me} ? "***" . $a->{nick} : "<" . $a->{nick} . ">", |
$a->{me} ? "***" . $a->{nick} : "<" . $a->{nick} . ">", |
561 |
" " . $a->{msg}; |
" " . $a->{message}; |
562 |
|
|
563 |
from_to($a->{msg}, 'UTF-8', $ENCODING); |
from_to($a->{message}, 'UTF-8', $ENCODING); |
564 |
|
|
565 |
$sth->execute($a->{channel}, $a->{me}, $a->{nick}, $a->{msg}, $a->{time}); |
$sth->execute($a->{channel}, $a->{me}, $a->{nick}, $a->{message}, $a->{time}); |
566 |
add_tag( id => $dbh->last_insert_id(undef,undef,"log",undef), |
add_tag( id => $dbh->last_insert_id(undef,undef,"log",undef), %$a ); |
|
message => $a->{msg}); |
|
567 |
} |
} |
568 |
|
|
569 |
|
|
570 |
if ($import_dircproxy) { |
if ($import_dircproxy) { |
571 |
open(my $l, $import_dircproxy) || die "can't open $import_dircproxy: $!"; |
open(my $l, $import_dircproxy) || die "can't open $import_dircproxy: $!"; |
572 |
warn "importing $import_dircproxy...\n"; |
warn "importing $import_dircproxy...\n"; |
573 |
my $tz_offset = 2 * 60 * 60; # TZ GMT+2 |
my $tz_offset = 1 * 60 * 60; # TZ GMT+2 |
574 |
while(<$l>) { |
while(<$l>) { |
575 |
chomp; |
chomp; |
576 |
if (/^@(\d+)\s(\S+)\s(.+)$/) { |
if (/^@(\d+)\s(\S+)\s(.+)$/) { |
588 |
channel => $CHANNEL, |
channel => $CHANNEL, |
589 |
me => $me, |
me => $me, |
590 |
nick => $nick, |
nick => $nick, |
591 |
msg => $msg, |
message => $msg, |
592 |
time => $dt->ymd . " " . $dt->hms, |
time => $dt->ymd . " " . $dt->hms, |
593 |
) if ($nick !~ m/^-/); |
) if ($nick !~ m/^-/); |
594 |
|
|
630 |
my $channel = $_[ARG1]->[0]; |
my $channel = $_[ARG1]->[0]; |
631 |
my $msg = $_[ARG2]; |
my $msg = $_[ARG2]; |
632 |
|
|
633 |
save_message( channel => $channel, me => 0, nick => $nick, msg => $msg); |
save_message( channel => $channel, me => 0, nick => $nick, message => $msg); |
634 |
meta( $nick, $channel, 'last-msg', $msg ); |
meta( $nick, $channel, 'last-msg', $msg ); |
635 |
}, |
}, |
636 |
irc_ctcp_action => sub { |
irc_ctcp_action => sub { |
639 |
my $channel = $_[ARG1]->[0]; |
my $channel = $_[ARG1]->[0]; |
640 |
my $msg = $_[ARG2]; |
my $msg = $_[ARG2]; |
641 |
|
|
642 |
save_message( channel => $channel, me => 1, nick => $nick, msg => $msg); |
save_message( channel => $channel, me => 1, nick => $nick, message => $msg); |
643 |
|
|
644 |
if ( $use_twitter ) { |
if ( $use_twitter ) { |
645 |
if ( my $twitter = meta( $nick, $channel, 'twitter' ) ) { |
if ( my $twitter = meta( $nick, $NICK, 'twitter' ) ) { |
646 |
my ($login,$passwd) = split(/\s+/,$twitter,2); |
my ($login,$passwd) = split(/\s+/,$twitter,2); |
647 |
_log("sending twitter for $nick/$login on $channel "); |
_log("sending twitter for $nick/$login on $channel "); |
648 |
my $bot = Net::Twitter->new( username=>$login, password=>$passwd ); |
my $bot = Net::Twitter->new( username=>$login, password=>$passwd ); |
694 |
|
|
695 |
my $sth = $dbh->prepare(qq{ |
my $sth = $dbh->prepare(qq{ |
696 |
select |
select |
697 |
nick, |
trim(both '_' from nick) as nick, |
698 |
count(*) as count, |
count(*) as count, |
699 |
sum(length(message)) as len |
sum(length(message)) as len |
700 |
from log |
from log |
701 |
group by nick |
group by trim(both '_' from nick) |
702 |
order by len desc,count desc |
order by len desc,count desc |
703 |
limit $nr |
limit $nr |
704 |
}); |
}); |
912 |
# http server |
# http server |
913 |
|
|
914 |
my $httpd = POE::Component::Server::HTTP->new( |
my $httpd = POE::Component::Server::HTTP->new( |
915 |
Port => $NICK =~ m/-dev/ ? 8001 : 8000, |
Port => $http_port, |
916 |
ContentHandler => { '/' => \&root_handler }, |
ContentHandler => { '/' => \&root_handler }, |
917 |
Headers => { Server => 'irc-logger' }, |
Headers => { Server => 'irc-logger' }, |
918 |
); |
); |
919 |
|
|
|
my %escape = ('<'=>'<', '>'=>'>', '&'=>'&', '"'=>'"'); |
|
|
my $escape_re = join '|' => keys %escape; |
|
|
|
|
920 |
my $style = <<'_END_OF_STYLE_'; |
my $style = <<'_END_OF_STYLE_'; |
921 |
p { margin: 0; padding: 0.1em; } |
p { margin: 0; padding: 0.1em; } |
922 |
.time, .channel { color: #808080; font-size: 60%; } |
.time, .channel { color: #808080; font-size: 60%; } |
924 |
.nick { color: #000000; font-size: 80%; padding: 2px; font-family: courier, courier new, monospace ; } |
.nick { color: #000000; font-size: 80%; padding: 2px; font-family: courier, courier new, monospace ; } |
925 |
.message { color: #000000; font-size: 100%; } |
.message { color: #000000; font-size: 100%; } |
926 |
.search { float: right; } |
.search { float: right; } |
927 |
|
a:link.tag, a:visited.tag { border: 1px dashed #ccc; backgound: #ccc; text-decoration: none } |
928 |
|
a:hover.tag { border: 1px solid #eee } |
929 |
|
hr { border: 1px dashed #ccc; height: 1px; clear: both; } |
930 |
|
/* |
931 |
.col-0 { background: #ffff66 } |
.col-0 { background: #ffff66 } |
932 |
.col-1 { background: #a0ffff } |
.col-1 { background: #a0ffff } |
933 |
.col-2 { background: #99ff99 } |
.col-2 { background: #99ff99 } |
934 |
.col-3 { background: #ff9999 } |
.col-3 { background: #ff9999 } |
935 |
.col-4 { background: #ff66ff } |
.col-4 { background: #ff66ff } |
936 |
a:link.tag, a:visited.tag { border: 1px dashed #ccc; backgound: #ccc; text-decoration: none } |
*/ |
937 |
a:hover.tag { border: 1px solid #eee } |
.calendar { border: 1px solid red; width: 100%; } |
938 |
hr { border: 1px dashed #ccc; height: 1px; clear: both; } |
.month { border: 0px; width: 100%; } |
939 |
_END_OF_STYLE_ |
_END_OF_STYLE_ |
940 |
|
|
941 |
my $max_color = 4; |
$max_color = 0; |
942 |
|
|
943 |
my %nick_enumerator; |
my @cols = qw( |
944 |
|
#ffcccc #ccffe6 #ccccff #e6ccff #ffccff #ffcce6 #ff9999 #ffcc99 #ffff99 |
945 |
|
#ccff99 #99ff99 #99ffcc #99ccff #9999ff #cc99ff #ff6666 #ffb366 #ffff66 |
946 |
|
#66ff66 #66ffb3 #66b3ff #6666ff #ff3333 #33ff33 #3399ff #3333ff #ff3399 |
947 |
|
#a0a0a0 #ff0000 #ffff00 #80ff00 #0000ff #8000ff #ff00ff #ff0080 #994d00 |
948 |
|
#999900 #009900 #cc0066 #c0c0c0 #ccff99 #99ff33 #808080 #660033 #ffffff |
949 |
|
); |
950 |
|
|
951 |
|
foreach my $c (@cols) { |
952 |
|
$style .= ".col-${max_color} { background: $c }\n"; |
953 |
|
$max_color++; |
954 |
|
} |
955 |
|
warn "defined $max_color colors for users...\n"; |
956 |
|
|
957 |
sub root_handler { |
sub root_handler { |
958 |
my ($request, $response) = @_; |
my ($request, $response) = @_; |
959 |
$response->code(RC_OK); |
$response->code(RC_OK); |
|
$response->content_type("text/html; charset=$ENCODING"); |
|
960 |
|
|
961 |
my $q; |
my $q; |
962 |
|
|
970 |
|
|
971 |
my $search = $q->param('search') || $q->param('grep') || ''; |
my $search = $q->param('search') || $q->param('grep') || ''; |
972 |
|
|
973 |
|
if ($request->url =~ m#/(rss|atom)#) { |
974 |
|
my $type = uc($1); |
975 |
|
my $url = "http://$http_hostname:$http_port"; |
976 |
|
|
977 |
|
$response->content_type("application/$type+xml"); |
978 |
|
|
979 |
|
my $html = '<!-- error -->'; |
980 |
|
warn "create $type feed from ",dump( @last_tags ); |
981 |
|
|
982 |
|
my $feed = XML::Feed->new( $type ); |
983 |
|
|
984 |
|
$feed->title( "last $last_x_tags from $CHANNEL" ); |
985 |
|
$feed->link( "http://$http_hostname:$http_port" ); |
986 |
|
$feed->description( "collects messages which have tags// in them" ); |
987 |
|
|
988 |
|
foreach my $m ( @last_tags ) { |
989 |
|
warn dump( $m ); |
990 |
|
#my $tags = join(' ', @{$m->{tags}} ); |
991 |
|
my $feed_entry = XML::Feed::Entry->new($type); |
992 |
|
$feed_entry->title( $m->{nick} . '@' . $m->{time} ); |
993 |
|
$feed_entry->author( $m->{nick} ); |
994 |
|
# $feed_entry->link( ); |
995 |
|
$feed_entry->issued( DateTime::Format::Flexible->build( $m->{time} ) ); |
996 |
|
$feed_entry->summary( |
997 |
|
# $filter->{nick}->( $m->{nick} ) . |
998 |
|
# '<tt>' . $m->{nick} . '</tt> ' . |
999 |
|
$filter->{message}->( $m->{message} ) |
1000 |
|
); |
1001 |
|
$feed->add_entry( $feed_entry ); |
1002 |
|
} |
1003 |
|
|
1004 |
|
$response->content( $feed->as_xml ); |
1005 |
|
return RC_OK; |
1006 |
|
} |
1007 |
|
|
1008 |
|
if ( $@ ) { |
1009 |
|
warn "$@"; |
1010 |
|
} |
1011 |
|
|
1012 |
|
$response->content_type("text/html; charset=$ENCODING"); |
1013 |
|
|
1014 |
my $html = |
my $html = |
1015 |
qq{<html><head><title>$NICK</title><style type="text/css">$style} . |
qq{<html><head><title>$NICK</title><style type="text/css">$style} . |
1016 |
$cloud->css . |
$cloud->css . |
1025 |
qq{<p>}; |
qq{<p>}; |
1026 |
if ($request->url =~ m#/history#) { |
if ($request->url =~ m#/history#) { |
1027 |
my $sth = $dbh->prepare(qq{ |
my $sth = $dbh->prepare(qq{ |
1028 |
select date(time) as date,count(*) as nr |
select date(time) as date,count(*) as nr,sum(length(message)) as len |
1029 |
from log |
from log |
1030 |
group by date(time) |
group by date(time) |
1031 |
order by date(time) desc |
order by date(time) desc |
1032 |
}); |
}); |
1033 |
$sth->execute(); |
$sth->execute(); |
1034 |
my ($l_yyyy,$l_mm) = (0,0); |
my ($l_yyyy,$l_mm) = (0,0); |
1035 |
|
$html .= qq{<table class="calendar"><tr>}; |
1036 |
my $cal; |
my $cal; |
1037 |
|
my $ord = 0; |
1038 |
while (my $row = $sth->fetchrow_hashref) { |
while (my $row = $sth->fetchrow_hashref) { |
1039 |
# this is probably PostgreSQL specific, expects ISO date |
# this is probably PostgreSQL specific, expects ISO date |
1040 |
my ($yyyy,$mm,$dd) = split(/-/, $row->{date}); |
my ($yyyy,$mm,$dd) = split(/-/, $row->{date}); |
1041 |
if ($yyyy != $l_yyyy || $mm != $l_mm) { |
if ($yyyy != $l_yyyy || $mm != $l_mm) { |
1042 |
$html .= $cal->as_HTML() if ($cal); |
if ( $cal ) { |
1043 |
|
$html .= qq{<td valign="top">} . $cal->as_HTML() . qq{</td>}; |
1044 |
|
$ord++; |
1045 |
|
$html .= qq{</tr><tr>} if ( $ord % 3 == 0 ); |
1046 |
|
} |
1047 |
$cal = new HTML::CalendarMonthSimple('month'=>$mm,'year'=>$yyyy); |
$cal = new HTML::CalendarMonthSimple('month'=>$mm,'year'=>$yyyy); |
1048 |
$cal->border(2); |
$cal->border(1); |
1049 |
|
$cal->width('30%'); |
1050 |
|
$cal->cellheight('5em'); |
1051 |
|
$cal->tableclass('month'); |
1052 |
|
#$cal->cellclass('day'); |
1053 |
|
$cal->sunday('SUN'); |
1054 |
|
$cal->saturday('SAT'); |
1055 |
|
$cal->weekdays('MON','TUE','WED','THU','FRI'); |
1056 |
($l_yyyy,$l_mm) = ($yyyy,$mm); |
($l_yyyy,$l_mm) = ($yyyy,$mm); |
1057 |
} |
} |
1058 |
$cal->setcontent($dd, qq{ |
$cal->setcontent($dd, qq{ |
1059 |
<a href="/?date=$row->{date}">$row->{nr}</a> |
<a href="/?date=$row->{date}">$row->{nr}</a><br/>$row->{len} |
1060 |
}); |
}); |
1061 |
|
|
1062 |
} |
} |
1063 |
$html .= $cal->as_HTML() if ($cal); |
$html .= qq{<td valign="top">} . $cal->as_HTML() . qq{</td></tr></table>}; |
1064 |
|
|
1065 |
} else { |
} else { |
1066 |
$html .= join("</p><p>", |
$html .= join("</p><p>", |
1067 |
get_from_log( |
get_from_log( |
1068 |
limit => $q->param('last') || $q->param('date') ? undef : 100, |
limit => ( $q->param('last') || $q->param('date') ) ? undef : 100, |
1069 |
search => $search || undef, |
search => $search || undef, |
1070 |
tag => $q->param('tag') || undef, |
tag => $q->param('tag') || undef, |
1071 |
date => $q->param('date') || undef, |
date => $q->param('date') || undef, |
1080 |
me_nick => '***%s ', |
me_nick => '***%s ', |
1081 |
message => '<span class="message">%s</span>', |
message => '<span class="message">%s</span>', |
1082 |
}, |
}, |
1083 |
filter => { |
filter => $filter, |
|
message => sub { |
|
|
my $m = shift || return; |
|
|
$m =~ s/($escape_re)/$escape{$1}/gs; |
|
|
$m =~ s#($RE{URI}{HTTP})#<a href="$1">$1</a>#gs; |
|
|
$m =~ s#$tag_regex#<a href="?tag=$1" class="tag">$1</a>#g; |
|
|
return $m; |
|
|
}, |
|
|
nick => sub { |
|
|
my $n = shift || return; |
|
|
if (! $nick_enumerator{$n}) { |
|
|
my $max = scalar keys %nick_enumerator; |
|
|
$nick_enumerator{$n} = $max + 1; |
|
|
} |
|
|
return '<span class="nick col-' . |
|
|
( $nick_enumerator{$n} % $max_color ) . |
|
|
'">' . $n . '</span>'; |
|
|
}, |
|
|
}, |
|
1084 |
) |
) |
1085 |
); |
); |
1086 |
} |
} |