From 36da55326115cd905412ce127bf6ef4bac2b524d Mon Sep 17 00:00:00 2001 From: moritz Date: Sun, 21 Oct 2007 21:32:29 +0000 Subject: [PATCH] [irclog] cleanup: * moved *.pm to lib/ * added "use lib 'lib';" line to cgi scripts git-svn-id: http://svn.pugscode.org/pugs/misc/irclog@18537 c213334d-75ef-0310-aa23-eaa082d1ae64 --- TODO | 3 ++- cgi/index.pl | 3 ++- cgi/out.pl | 5 +++-- cgi/search.pl | 5 +++-- cgi/spam.pl | 5 +++-- cgi/text.pl | 5 +++-- ilbot2.pl | 9 +++++++-- IrcLog.pm => lib/IrcLog.pm | 0 {IrcLog => lib/IrcLog}/WWW.pm | 10 +++++----- t/decode.t | 6 +++--- 10 files changed, 31 insertions(+), 20 deletions(-) rename IrcLog.pm => lib/IrcLog.pm (100%) rename {IrcLog => lib/IrcLog}/WWW.pm (95%) diff --git a/TODO b/TODO index b58c255..2e35a50 100644 --- a/TODO +++ b/TODO @@ -1,8 +1,9 @@ -* maybe add context to search results? * links to colabti irclogs - but how to know for which channels? +* fix context in search results for adjacent hits Already done: * import of colabti irclogs +* add context to search results? * full text search 15:29 < [particle]> if you're in the mood for adding more, processing diff --git a/cgi/index.pl b/cgi/index.pl index 6993748..0a5752b 100755 --- a/cgi/index.pl +++ b/cgi/index.pl @@ -7,9 +7,10 @@ use HTML::Entities; use HTML::Template; use Config::File; +use HTML::Calendar::Simple; +use lib 'lib'; use IrcLog qw(get_dbh); use IrcLog::WWW qw(http_header); -use HTML::Calendar::Simple; my $conf = Config::File::read_config_file('cgi.conf'); my $base_url = $conf->{BASE_URL} || q{/}; diff --git a/cgi/out.pl b/cgi/out.pl index 1cdb3c4..12c2e68 100755 --- a/cgi/out.pl +++ b/cgi/out.pl @@ -3,8 +3,6 @@ use strict; use Carp qw(confess); use CGI::Carp qw(fatalsToBrowser); -use IrcLog qw(get_dbh gmt_today); -use IrcLog::WWW qw(http_header message_line my_encode); use Date::Simple qw(date); use Encode::Guess; use CGI; @@ -12,6 +10,9 @@ use HTML::Template; use Config::File; use File::Slurp; +use lib 'lib'; +use IrcLog qw(get_dbh gmt_today); +use IrcLog::WWW qw(http_header message_line my_encode); #use Data::Dumper; diff --git a/cgi/search.pl b/cgi/search.pl index b831ff3..c6c5f04 100755 --- a/cgi/search.pl +++ b/cgi/search.pl @@ -8,10 +8,11 @@ use Encode; use HTML::Entities; use HTML::Template; -use IrcLog qw(get_dbh); -use IrcLog::WWW qw(http_header message_line my_encode my_decode); use Config::File; use List::Util qw(min max); +use lib 'lib'; +use IrcLog qw(get_dbh); +use IrcLog::WWW qw(http_header message_line my_encode my_decode); use utf8; #use Data::Dumper; #$DATA::Dumper::indent = 0; diff --git a/cgi/spam.pl b/cgi/spam.pl index 72436e2..94267c1 100755 --- a/cgi/spam.pl +++ b/cgi/spam.pl @@ -4,12 +4,13 @@ use CGI::Carp qw(fatalsToBrowser); use Carp qw(confess); use lib '..'; -use IrcLog qw(get_dbh); -use IrcLog::WWW 'http_header'; use CGI; use Config::File; use Data::Dumper; use HTML::Template; +use lib 'lib'; +use IrcLog qw(get_dbh); +use IrcLog::WWW 'http_header'; my $q = CGI->new(); diff --git a/cgi/text.pl b/cgi/text.pl index 9cc8bc1..8407af2 100755 --- a/cgi/text.pl +++ b/cgi/text.pl @@ -3,13 +3,14 @@ use strict; use Carp qw(confess); use CGI::Carp qw(fatalsToBrowser); -use IrcLog qw(get_dbh gmt_today); -use IrcLog::WWW qw(my_encode); use CGI; use Encode; use HTML::Entities; # evil hack: Text::Table lies somewhere near /irclog/ on the server... use lib '../lib'; +use lib 'lib'; +use IrcLog qw(get_dbh gmt_today); +use IrcLog::WWW qw(my_encode); use Text::Table; my $default_channel = 'perl6'; diff --git a/ilbot2.pl b/ilbot2.pl index cc6a6b9..4c1638f 100755 --- a/ilbot2.pl +++ b/ilbot2.pl @@ -72,8 +72,8 @@ package IrcLogBot; } sub nick_change { - my ($self, $e) = @_; - print Dumper($e); + my $self = shift; + print Dumper(\@_); # XXX TODO return undef; } @@ -84,6 +84,11 @@ package IrcLogBot; dbwrite($e->{channel}, "", $e->{nick} . ' was kicked by ' . $e->{who} . ': ' . $e->{reason}); return undef; } + + sub help { + my $self = shift; + return "This is a passive irc logging bot. Homepage: http://moritz.faui2k3.org/en/ilbot"; + } } diff --git a/IrcLog.pm b/lib/IrcLog.pm similarity index 100% rename from IrcLog.pm rename to lib/IrcLog.pm diff --git a/IrcLog/WWW.pm b/lib/IrcLog/WWW.pm similarity index 95% rename from IrcLog/WWW.pm rename to lib/IrcLog/WWW.pm index 9c85f0e..eca18d5 100644 --- a/IrcLog/WWW.pm +++ b/lib/IrcLog/WWW.pm @@ -60,7 +60,7 @@ sub my_decode { my @encodings = qw(ascii utf-8 iso-8859-15 gb2312); my $encoder = guess_encoding($str, @encodings); if (ref $encoder){ - return $encoder->decode($str); + return $encoder->decode($str); } else { return decode("utf-8", $str); } @@ -356,9 +356,9 @@ sub break_apart { sub message_line { - my ($args_ref, $c) = @_; - my $nick = $args_ref->{nick}; - my $colors = $args_ref->{colors}; + my ($args_ref, $c) = @_; + my $nick = $args_ref->{nick}; + my $colors = $args_ref->{colors}; my %h = ( ID => $args_ref->{id}, TIME => format_time($args_ref->{timestamp}), @@ -366,7 +366,7 @@ sub message_line { LINE_NUMBER => ++$args_ref->{line_number}, LINK_URL => $args_ref->{link_url}, ); - $h{SEARCH_FOUND} = 'search_found' if ($args_ref->{search_found}); + $h{SEARCH_FOUND} = 'search_found' if ($args_ref->{search_found}); my @classes; my @msg_classes; diff --git a/t/decode.t b/t/decode.t index 9bc8711..e04087f 100644 --- a/t/decode.t +++ b/t/decode.t @@ -3,8 +3,8 @@ use warnings; use Encode qw(encode decode); #use Smart::Comments; -use Test::Base tests => 11; -BEGIN { use_ok('IrcLog'); } +use Test::Base tests => 10; +use IrcLog::WWW qw(my_encode); run { my $block = shift; @@ -14,7 +14,7 @@ run { my $utf8 = decode('utf8', $str); my $bytes = encode($enc, $utf8); ### $bytes - my $got = IrcLog::my_encode($bytes); + my $got = my_encode($bytes); is $got, $str, "$name - $enc"; } };