507 |
} |
} |
508 |
|
|
509 |
if ( @tags ) { |
if ( @tags ) { |
510 |
shift @last_tags if $#last_tags == $last_x_tags; |
pop @last_tags if $#last_tags == $last_x_tags; |
511 |
push @last_tags, { tags => [ @tags ], %$arg }; |
unshift @last_tags, { tags => [ @tags ], %$arg }; |
512 |
} |
} |
513 |
|
|
514 |
} |
} |
520 |
=cut |
=cut |
521 |
|
|
522 |
sub seed_tags { |
sub seed_tags { |
523 |
my $sth = $dbh->prepare(qq{ select id,message,nick,me,time from log where message like '%//%' }); |
my $sth = $dbh->prepare(qq{ select id,message,nick,me,time from log where message like '%//%' order by time asc }); |
524 |
$sth->execute; |
$sth->execute; |
525 |
while (my $row = $sth->fetchrow_hashref) { |
while (my $row = $sth->fetchrow_hashref) { |
526 |
add_tag( %$row ); |
add_tag( %$row ); |
979 |
$response->content_type( 'application/' . lc($type) . '+xml' ); |
$response->content_type( 'application/' . lc($type) . '+xml' ); |
980 |
|
|
981 |
my $html = '<!-- error -->'; |
my $html = '<!-- error -->'; |
982 |
warn "create $type feed from ",dump( @last_tags ); |
#warn "create $type feed from ",dump( @last_tags ); |
983 |
|
|
984 |
my $feed = XML::Feed->new( $type ); |
my $feed = XML::Feed->new( $type ); |
985 |
|
|
986 |
$feed->title( "last $last_x_tags from $CHANNEL" ); |
$feed->title( "last $last_x_tags from $CHANNEL" ); |
987 |
# $feed->link( "http://$http_hostname:$http_port" ); |
$feed->link( $url ); |
988 |
$feed->description( "collects messages which have tags// in them" ); |
$feed->description( "collects messages which have tags// in them" ); |
989 |
|
|
990 |
foreach my $m ( @last_tags ) { |
foreach my $m ( @last_tags ) { |
995 |
$feed_entry->author( $m->{nick} ); |
$feed_entry->author( $m->{nick} ); |
996 |
$feed_entry->link( '/#' . $m->{id} ); |
$feed_entry->link( '/#' . $m->{id} ); |
997 |
$feed_entry->issued( DateTime::Format::Flexible->build( $m->{time} ) ); |
$feed_entry->issued( DateTime::Format::Flexible->build( $m->{time} ) ); |
998 |
|
|
999 |
|
my $message = $filter->{message}->( $m->{message} ); |
1000 |
|
$message .= "<br/>\n" unless $message =~ m!<(/p|br/?)>!; |
1001 |
|
warn "## message = $message\n"; |
1002 |
|
from_to( $message, $ENCODING, 'UTF-8' ); |
1003 |
|
|
1004 |
#$feed_entry->summary( |
#$feed_entry->summary( |
1005 |
$feed_entry->content( |
$feed_entry->content( |
1006 |
'<![CDATA[' . |
"<![CDATA[$message]]>" |
|
# $filter->{nick}->( $m->{nick} ) . |
|
|
# '<tt>' . $m->{nick} . '</tt> ' . |
|
|
$filter->{message}->( $m->{message} ) . |
|
|
"<br/>\n]]>" |
|
1007 |
); |
); |
1008 |
$feed_entry->category( join(', ', @{$m->{tags}}) ); |
$feed_entry->category( join(', ', @{$m->{tags}}) ); |
1009 |
$feed->add_entry( $feed_entry ); |
$feed->add_entry( $feed_entry ); |
1031 |
} . |
} . |
1032 |
$cloud->html(500) . |
$cloud->html(500) . |
1033 |
qq{<p>}; |
qq{<p>}; |
1034 |
if ($request->url =~ m#/history#) { |
|
1035 |
|
if ($request->url =~ m#/tags?#) { |
1036 |
|
# nop |
1037 |
|
} elsif ($request->url =~ m#/history#) { |
1038 |
my $sth = $dbh->prepare(qq{ |
my $sth = $dbh->prepare(qq{ |
1039 |
select date(time) as date,count(*) as nr,sum(length(message)) as len |
select date(time) as date,count(*) as nr,sum(length(message)) as len |
1040 |
from log |
from log |
1102 |
</body></html>}; |
</body></html>}; |
1103 |
|
|
1104 |
$response->content( $html ); |
$response->content( $html ); |
1105 |
warn "<< ", $request->method, $request->uri, " created ", length($html), " bytes\n"; |
warn "<< ", $request->method, " ", $request->uri, " created ", length($html), " bytes\n"; |
1106 |
return RC_OK; |
return RC_OK; |
1107 |
} |
} |
1108 |
|
|