--- trunk/bin/irc-logger.pl 2007/12/16 20:06:47 73
+++ trunk/bin/irc-logger.pl 2008/02/07 17:48:51 77
@@ -507,8 +507,8 @@
}
if ( @tags ) {
- shift @last_tags if $#last_tags == $last_x_tags;
- push @last_tags, { tags => [ @tags ], %$arg };
+ pop @last_tags if $#last_tags == $last_x_tags;
+ unshift @last_tags, { tags => [ @tags ], %$arg };
}
}
@@ -520,7 +520,7 @@
=cut
sub seed_tags {
- 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 });
$sth->execute;
while (my $row = $sth->fetchrow_hashref) {
add_tag( %$row );
@@ -973,38 +973,64 @@
my $search = $q->param('search') || $q->param('grep') || '';
- if ($request->url =~ m#/rss#i) {
+ if ($request->url =~ m#/rss(?:/(tags)(?:=(\d+))?)#i) {
+ my $show = lc($1);
+ my $arg = $2 || 50;
+
my $type = 'RSS'; # Atom
$response->content_type( 'application/' . lc($type) . '+xml' );
my $html = '';
- warn "create $type feed from ",dump( @last_tags );
+ #warn "create $type feed from ",dump( @last_tags );
my $feed = XML::Feed->new( $type );
- $feed->title( "last $last_x_tags from $CHANNEL" );
-# $feed->link( "http://$http_hostname:$http_port" );
- $feed->description( "collects messages which have tags// in them" );
-
- foreach my $m ( @last_tags ) {
-# warn dump( $m );
- #my $tags = join(' ', @{$m->{tags}} );
+ if ( $show eq 'tags' ) {
+ $feed->title( "tags from $CHANNEL" );
+ $feed->link( "$url/tags" );
+ $feed->description( "tag cloud created from messages on channel $CHANNEL which have tags// in them" );
my $feed_entry = XML::Feed::Entry->new($type);
- $feed_entry->title( $m->{nick} . '@' . $m->{time} );
- $feed_entry->author( $m->{nick} );
- $feed_entry->link( '/#' . $m->{id} );
- $feed_entry->issued( DateTime::Format::Flexible->build( $m->{time} ) );
- #$feed_entry->summary(
+ $feed_entry->title( "$arg tags from $CHANNEL" );
+ $feed_entry->author( $NICK );
+ $feed_entry->link( '/#tags' );
+
$feed_entry->content(
- '{nick}->( $m->{nick} ) .
-# '' . $m->{nick} . ' ' .
- $filter->{message}->( $m->{message} ) .
- "
\n]]>"
+ qq{}
+ . $cloud->css
+ . qq{}
+ . $cloud->html( $arg )
+ . qq{]]>}
);
- $feed_entry->category( join(', ', @{$m->{tags}}) );
$feed->add_entry( $feed_entry );
+
+ } else {
+
+ $feed->title( "last $last_x_tags from $CHANNEL" );
+ $feed->link( $url );
+ $feed->description( "collects messages which have tags// in them" );
+
+ foreach my $m ( @last_tags ) {
+# warn dump( $m );
+ #my $tags = join(' ', @{$m->{tags}} );
+ my $feed_entry = XML::Feed::Entry->new($type);
+ $feed_entry->title( $m->{nick} . '@' . $m->{time} );
+ $feed_entry->author( $m->{nick} );
+ $feed_entry->link( '/#' . $m->{id} );
+ $feed_entry->issued( DateTime::Format::Flexible->build( $m->{time} ) );
+
+ my $message = $filter->{message}->( $m->{message} );
+ $message .= "
\n" unless $message =~ m!<(/p|br/?)>!;
+ warn "## message = $message\n";
+ from_to( $message, $ENCODING, 'UTF-8' );
+
+ #$feed_entry->summary(
+ $feed_entry->content(
+ ""
+ );
+ $feed_entry->category( join(', ', @{$m->{tags}}) );
+ $feed->add_entry( $feed_entry );
+ }
}
$response->content( $feed->as_xml );
@@ -1018,18 +1044,21 @@
$response->content_type("text/html; charset=$ENCODING");
my $html =
- qq{
}; - if ($request->url =~ m#/history#) { + } + . $cloud->html(500) + . qq{
}; + + if ($request->url =~ m#/tags?#) { + # nop + } elsif ($request->url =~ m#/history#) { my $sth = $dbh->prepare(qq{ select date(time) as date,count(*) as nr,sum(length(message)) as len from log @@ -1097,7 +1126,7 @@ }; $response->content( $html ); - warn "<< ", $request->method, $request->uri, " created ", length($html), " bytes\n"; + warn "<< ", $request->method, " ", $request->uri, " created ", length($html), " bytes\n"; return RC_OK; }