/[irc-logger]/trunk/bin/irc-logger.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/bin/irc-logger.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 73 by dpavlin, Sun Dec 16 20:06:47 2007 UTC revision 75 by dpavlin, Thu Dec 20 22:46:16 2007 UTC
# Line 507  sub add_tag { Line 507  sub add_tag {
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  }  }
# Line 520  Read all tags from database and create i Line 520  Read all tags from database and create i
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 );
# Line 979  sub root_handler { Line 979  sub root_handler {
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 ) {
# Line 995  sub root_handler { Line 995  sub root_handler {
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 );
# Line 1097  sub root_handler { Line 1099  sub root_handler {
1099          </body></html>};          </body></html>};
1100    
1101          $response->content( $html );          $response->content( $html );
1102          warn "<< ", $request->method, $request->uri, " created ", length($html), " bytes\n";          warn "<< ", $request->method, " ", $request->uri, " created ", length($html), " bytes\n";
1103          return RC_OK;          return RC_OK;
1104  }  }
1105    

Legend:
Removed from v.73  
changed lines
  Added in v.75

  ViewVC Help
Powered by ViewVC 1.1.26