From 00050970b3aee794325919116b4db554d5a2ee23 Mon Sep 17 00:00:00 2001 From: morimoto Date: Sun, 29 Aug 2004 11:21:02 +0000 Subject: [PATCH] added "recent", makes keitairc 1.24 --- ChangeLog | 5 +++ doc/index.html | 19 ++++++++--- keitairc | 103 +++++++++++++++++++++++++++++++++++++++++---------------- 3 files changed, 93 insertions(+), 34 deletions(-) diff --git a/ChangeLog b/ChangeLog index c4aec37..2bee364 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2004-08-29 Jun Morimoto + + * recent ($BA4%A%c%M%k$NL$FI$r$^$H$aFI$_(B) $BDI2C(B + * $B$A$g$C$H%3!<%I$rA]=|(B + 2004-08-18 Jun Morimoto * keitairc: $B%A%c%M%kL>$O>.J8;z$K@55,2=$7$FFbIt=hM}$K;H$&(B diff --git a/doc/index.html b/doc/index.html index 1098f61..4a28ee1 100644 --- a/doc/index.html +++ b/doc/index.html @@ -10,13 +10,13 @@

morimoto@xantia.citroen.org
-$Id: index.html,v 1.17 2004-08-18 14:29:46 morimoto Exp $ +$Id: index.html,v 1.18 2004-08-29 11:21:02 morimoto Exp $

ÀâÌÀ

-i-mode, EZweb, vodafone live! ¤Ê¤É¤Î¥Ö¥é¥¦¥¶¥Õ¥©¥ó¤«¤é irc ¤ò¤¹¤ë¤â¤Î¡£ +i-mode, EZweb, vodafone live!, AirH" Phone ¤Ê¤É¤Î¥Ö¥é¥¦¥¶¥Õ¥©¥ó¤«¤é irc ¤ò¤¹¤ë¤â¤Î¡£ plum ¤Ê¤É¤Î pirc (irc ¥×¥í¥­¥·) ¤ËÀܳ¤·¤Æ»È¤ï¤ì¤ë¤³¤È¤òÁÛÄꤷ¤Æ¤¤¤Þ¤¹¡£

@@ -148,6 +148,12 @@ keitairc ¤òÁªÂò¤¹¤ë¤È´ûÆÉÉôʬ¤â¸«¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£

+¤Þ¤¿¡¢Ì¤ÆÉÆâÍƤΤ¢¤ë¥Á¥ã¥Í¥ë¤¬¤Ò¤È¤Ä¤Ç¤â¤¢¤ë¾ì¹ç¤Ï¡¢ +¥Á¥ã¥Í¥ë¤Î¥ê¥¹¥È¤Ë recent ¥ê¥ó¥¯¤¬¤Ä¤­¤Þ¤¹¡£ +recent ¥ê¥ó¥¯¤Ï¡¢Ã¼Ëö¤Ë¤è¤Ã¤Æ¤Ï * ¥­¡¼¤ò²¡¤¹¤À¤±¤Ç¤â¹Ô¤¯¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£ +recent ¤ò¥¯¥ê¥Ã¥¯¤¹¤ë¤È¡¢Á´¥Á¥ã¥Í¥ë¤Î̤Æɤò¤Þ¤È¤áÆɤߤǤ­¤Þ¤¹¡£ + +

¥Á¥ã¥Í¥ë¤Îȯ¸ÀÆâÍƤòÆɤó¤Ç¤¤¤Æ¡¢ ȯ¸À¤·¤¿¤¤¾ì¹ç¤Ï¥Ú¡¼¥¸¤Î¤Æ¤Ã¤Ú¤ó¤Ë¤¢¤ë¥Æ¥­¥¹¥È¥¨¥ê¥¢¤Ëµ­Æþ¤·¡¢ OK ¥Ü¥¿¥ó¤ò²¡¤·¤Þ¤¹¡£ @@ -159,9 +165,9 @@ OK

-ÅÅÏõ¡¤Î 7 ¤ò²¡¤¹¤È¥Ú¡¼¥¸ÀèƬ¤Ø¡¢ -ÅÅÏõ¡¤Î 8 ¤ò²¡¤¹¤È¥Á¥ã¥Í¥ë¤Î¥ê¥¹¥È¤Ø¡¢ -ÅÅÏõ¡¤Î 9 ¤ò²¡¤¹¤È¥Ú¡¼¥¸ËöÈø¤ËÈô¤Ó¤Þ¤¹¡£ +üËö¤Î 7 ¤ò²¡¤¹¤È¥Ú¡¼¥¸ÀèƬ¤Ø¡¢ +üËö¤Î 8 ¤ò²¡¤¹¤È¥Á¥ã¥Í¥ë¤Î¥ê¥¹¥È¤Ø¡¢ +üËö¤Î 9 ¤ò²¡¤¹¤È¥Ú¡¼¥¸ËöÈø¤ËÈô¤Ó¤Þ¤¹¡£

³«È¯

@@ -174,6 +180,9 @@ OK

Changes

+
1.24 +
Á´¥Á¥ã¥Í¥ë¤Î̤ÆɤޤȤáÆɤßÄɲà +
1.23
¥Á¥ã¥Í¥ë̾¤ÎÆâÉô½èÍý¤Ï¾®Ê¸»ú¤ËÀµµ¬²½¤·¤Æ°·¤¦ (thanks to Akira Yamada) diff --git a/keitairc b/keitairc index 8b55a68..aa925f0 100755 --- a/keitairc +++ b/keitairc @@ -1,6 +1,6 @@ #!/usr/bin/perl # keitairc -# $Id: keitairc,v 1.23 2004-08-18 14:24:53 morimoto Exp $ +# $Id: keitairc,v 1.24 2004-08-29 11:21:02 morimoto Exp $ # # Copyright (c) 2003 Jun Morimoto # This program is covered by the GNU General Public License 2 @@ -8,7 +8,7 @@ # Depends: libjcode-pm-perl, libpoe-component-irc-perl, # liburi-perl, libwww-perl, libappconfig-perl -my $rcsid = q$Id: keitairc,v 1.23 2004-08-18 14:24:53 morimoto Exp $; +my $rcsid = q$Id: keitairc,v 1.24 2004-08-29 11:21:02 morimoto Exp $; my ($version) = $rcsid =~ m#,v ([0-9.]+)#; use strict; @@ -21,6 +21,9 @@ use URI::Escape; use HTTP::Response; use AppConfig qw(:argcount); +use constant true => 1; +use constant false => 0; + my $config = AppConfig->new( { CASE => 1, @@ -54,10 +57,10 @@ my (%channel_buffer, %channel_recent); my %mtime; # unread lines -my %unread; +my %unread_lines; # chk -my ($send_chk, $update_chk); +my ($message_added); # irc component POE::Component::IRC->new('keitairc'); @@ -190,10 +193,10 @@ sub add_message{ $mtime{$canon_channel} = time; # unread lines - $unread{$canon_channel} = scalar(@tmp2); + $unread_lines{$canon_channel} = scalar(@tmp2); - if ($unread{$canon_channel} > $config->web_lines) { - $unread{$canon_channel} = $config->web_lines; + if($unread_lines{$canon_channel} > $config->web_lines){ + $unread_lines{$canon_channel} = $config->web_lines; } } @@ -252,16 +255,21 @@ sub index_page{ $accesskey++; # $BL$FI9T?t(B - if($unread{$canon_channel} > 0){ - $buf .= sprintf(' %d', + if($unread_lines{$canon_channel}){ + $buf .= sprintf(' %d', $docroot, uri_escape($channel), - $unread{$canon_channel}); + $unread_lines{$canon_channel}); } $buf .= '
'; } $buf .= qq(0 refresh list
); + + if(grep($unread_lines{$_}, keys %unread_lines)){ + $buf .= qq(* recent
); + } + $buf .= qq( - keitairc $version); $buf; } @@ -335,12 +343,12 @@ sub on_web_request{ return; } - unless(defined($config->au_subscriber_id) && + # authorization + unless(defined($config->au_subscriber_id) && ($request->header('x-up-subno') eq $config->au_subscriber_id)) { if(defined($config->web_username)){ unless($request->headers->authorization_basic eq $config->web_username . ':' . $config->web_password){ - my $response = HTTP::Response->new(401); $response->push_header(WWW_Authenticate => qq(Basic Realm="keitairc")); @@ -350,6 +358,7 @@ sub on_web_request{ } } } + my $uri = $request->uri; my $content = ''; $content .= ''; @@ -370,24 +379,59 @@ sub on_web_request{ Jcode->new($message)->jis); &add_message($channel, $config->irc_nick, Jcode->new($message)->euc); - - # set flag for "send message" - $send_chk = 1; + $message_added = true; } } + # store and remove attached options from uri + my %option; + { + my @opts = split(',', $uri); + shift @opts; + grep($option{$_} = $_, @opts); + $uri =~ s/,.*//; + } + if($uri eq '/'){ - $content .= '' . $config->web_title . ''; - $content .= ''; - $content .= ''; + $content .= '' . $config->web_title . ''; + $content .= ''; + $content .= ''; + + if($option{recent}){ + # recent messages on every channel + for my $channel (sort keys %channel_name){ + my $canon_channel = &canon_name($channel); + if(defined($channel_name{$canon_channel}) && + length($channel_recent{$canon_channel})){ + $content .= "$channel_name{$canon_channel}"; + $content .= sprintf(' more..
', + $docroot, uri_escape($channel)); + $content .= &render($channel_recent{$canon_channel}); + $unread_lines{$canon_channel} = 0; + $channel_recent{$canon_channel} = ''; + } + } + $content .= qq(ch list[8]); + }else{ + # channel list $content .= &index_page; + } }else{ + # channel conversation $uri =~ s|^/||; - $update_chk = ($uri =~ /.*.update/); - if ($update_chk eq 1) { - $uri =~ s/.update//; - } + # RFC 2811: + # Apart from the the requirement that the first character + # being either '&', '#', '+' or '!' (hereafter called "channel + # prefix"). The only restriction on a channel name is that it + # SHALL NOT contain any spaces (' '), a control G (^G or ASCII + # 7), a comma (',' which is used as a list item separator by + # the protocol). Also, a colon (':') is used as a delimiter + # for the channel mask. The exact syntax of a channel name is + # defined in "IRC Server Protocol" [IRC-SERVER]. + # + # so we use white space as separator character of channel name + # and command argument. my $channel = uri_unescape($uri); @@ -402,7 +446,7 @@ sub on_web_request{ $docroot, uri_escape($channel)); $content .= ''; $content .= ''; - $content .= qq(back[8]
); + $content .= qq(ch list[8]
); # $content .= ''; $content .= ''; @@ -411,10 +455,11 @@ sub on_web_request{ if(defined($channel_buffer{$canon_channel}) && length($channel_buffer{$canon_channel})){ $content .= ''; - if ((($update_chk eq 1)||((defined $config->show_newmsgonly) && ($send_chk eq 1)))) { + if($option{recent} || + (defined($config->show_newmsgonly) && $message_added)){ $content .= &render($channel_recent{$canon_channel}); - $content .= sprintf(' - ..more[5]', $docroot, uri_escape($channel)); + $content .= sprintf('more[5]', + $docroot, uri_escape($channel)); } else { $content .= &render($channel_buffer{$canon_channel}); } @@ -423,14 +468,14 @@ sub on_web_request{ $content .= 'no message here yet'; } }else{ - $content .= "no such channel"; + $content .= 'no such channel'; } # clear check flags - $send_chk = 0; + $message_added = false; # clear unread counter - $unread{$canon_channel} = 0; + $unread_lines{$canon_channel} = 0; # clear recent messages buffer $channel_recent{$canon_channel} = ''; -- 2.11.0