#!/usr/bin/perl
# keitairc
-# $Id: keitairc,v 1.9 2004-03-21 11:03:19 morimoto Exp $
+# $Id: keitairc,v 1.10 2004-03-21 11:03:38 morimoto Exp $
#
# Copyright (c) 2003 Jun Morimoto <morimoto@xantia.citroen.org>
# This program is covered by the GNU General Public License 2
# Depends: libjcode-pm-perl, libpoe-component-irc-perl,
# liburi-perl, libwww-perl, libappconfig-perl
-my $rcsid = q$Id: keitairc,v 1.9 2004-03-21 11:03:19 morimoto Exp $;
+my $rcsid = q$Id: keitairc,v 1.10 2004-03-21 11:03:38 morimoto Exp $;
my ($version) = $rcsid =~ m#,v ([0-9.]+)#;
use strict;
my %channel_name;
# \e$B%A%c%M%k$N2qOCFbMF$r5-O?$9$k%O%C%7%e\e(B
-my %channel_buffer;
+my (%channel_buffer, %channel_recent);
# \e$B3F%A%c%M%k$N:G=*%"%/%;%9;~9o!":G?7H/8@;~9o\e(B
my %mtime;
my @tmp = split("\n", $channel_buffer{$channel});
push @tmp, sprintf('%s %s> %s', &now, $who, $msg);
+ my @tmp2 = split("\n", $channel_recent{$channel});
+ push @tmp2, sprintf('%s %s> %s', &now, $who, $msg);
+
if(@tmp > $config->web_lines){
$channel_buffer{$channel} = join("\n", splice(@tmp, -$config->web_lines));
+ $channel_recent{$channel} = join("\n", splice(@tmp2, -$config->web_lines));
}else{
$channel_buffer{$channel} = join("\n", @tmp);
+ $channel_recent{$channel} = join("\n", @tmp2);
}
$mtime{$channel} = time;
$accesskey++;
if($unread{$channel} > 0){
- $buf .= sprintf(' (%d)', $unread{$channel});
+ $buf .= sprintf(' <a href="%s%s.update">(%d)</a>',
+ $docroot,
+ uri_escape($channel),
+ $unread{$channel});
}
$buf .= '<br>';
}
$buf .= qq(<a href="$docroot" accesskey="0"></a>);
- $buf .= qq( - keitairc $version +);
+ $buf .= qq( - keitairc $version +++);
$buf;
}
################################################################
sub on_web_request{
+ local($_);
my ($kernel, $heap, $request) = @_[KERNEL, HEAP, ARG0];
# Filter::HTTPD sometimes generates HTTP::Response objects.
Jcode->new($message)->jis);
&add_message($channel, $config->irc_nick,
Jcode->new($message)->euc);
+
}
}
$content .= &index_page;
}else{
$uri =~ s|^/||;
+
+ my $update_chk = ($uri =~ /.*.update/);
+ if ($update_chk eq 1) {
+ $uri =~ s/.update//;
+ }
+
my $channel = uri_unescape($uri);
$content .= '<title>' . $config->web_title . ": $channel</title>";
length($channel_buffer{$channel})){
$content .= qq(<a accesskey="8" href="$docroot"></a>);
$content .= '<a accesskey="9" href="#2"></a>';
- $content .= &render($channel_buffer{$channel});
+ if ($update_chk eq 1) {
+ $content .= &render($channel_recent{$channel});
+ $content .= sprintf('<a accesskey="5" href="%s%s">
+ ..more(push 5)</a>', "../", uri_escape($channel));
+ } else {
+ $content .= &render($channel_buffer{$channel});
+ }
$content .= '<a name="2"></a>';
}else{
$content .= 'no message here yet';
}
$unread{$channel} = 0;
+ $channel_recent{$channel} = "";
}
$content .= '</body></html>';