Skip to content

Commit

Permalink
[irclog] cleanup:
Browse files Browse the repository at this point in the history
 * 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
  • Loading branch information
moritz committed Oct 21, 2007
1 parent 634efd3 commit 36da553
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 20 deletions.
3 changes: 2 additions & 1 deletion 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
Expand Down
3 changes: 2 additions & 1 deletion cgi/index.pl
Expand Up @@ -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{/};
Expand Down
5 changes: 3 additions & 2 deletions cgi/out.pl
Expand Up @@ -3,15 +3,16 @@
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;
use Encode;
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;


Expand Down
5 changes: 3 additions & 2 deletions cgi/search.pl
Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions cgi/spam.pl
Expand Up @@ -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();

Expand Down
5 changes: 3 additions & 2 deletions cgi/text.pl
Expand Up @@ -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';
Expand Down
9 changes: 7 additions & 2 deletions ilbot2.pl
Expand Up @@ -72,8 +72,8 @@ package IrcLogBot;
}

sub nick_change {
my ($self, $e) = @_;
print Dumper($e);
my $self = shift;
print Dumper(\@_);
# XXX TODO
return undef;
}
Expand All @@ -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";
}
}


Expand Down
File renamed without changes.
10 changes: 5 additions & 5 deletions IrcLog/WWW.pm → lib/IrcLog/WWW.pm
Expand Up @@ -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);
}
Expand Down Expand Up @@ -356,17 +356,17 @@ 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}),
MESSAGE => output_process(my_decode($args_ref->{message}), "nonprint_clean", $args_ref->{channel}),
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;
Expand Down
6 changes: 3 additions & 3 deletions t/decode.t
Expand Up @@ -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;
Expand All @@ -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";
}
};
Expand Down

0 comments on commit 36da553

Please sign in to comment.