OSDN Git Service

added "recent", makes keitairc 1.24
authormorimoto <morimoto@180c8125-5b33-4295-ad04-72a68a15b4cc>
Sun, 29 Aug 2004 11:21:02 +0000 (11:21 +0000)
committermorimoto <morimoto@180c8125-5b33-4295-ad04-72a68a15b4cc>
Sun, 29 Aug 2004 11:21:02 +0000 (11:21 +0000)
ChangeLog
doc/index.html
keitairc

index c4aec37..2bee364 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2004-08-29  Jun Morimoto  <morimoto@xantia.citroen.org>
+
+       * recent (\e$BA4%A%c%M%k$NL$FI$r$^$H$aFI$_\e(B) \e$BDI2C\e(B
+       * \e$B$A$g$C$H%3!<%I$rA]=|\e(B
+
 2004-08-18  Jun Morimoto  <morimoto@xantia.citroen.org>
 
        * keitairc: \e$B%A%c%M%kL>$O>.J8;z$K@55,2=$7$FFbIt=hM}$K;H$&\e(B
index 1098f61..4a28ee1 100644 (file)
 
 <p class="flushleft">
 morimoto@xantia.citroen.org<br>
-$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 $
 </p>
 
 <h2>ÀâÌÀ</h2>
 
 <p>
-i-mode, EZweb, vodafone live! ¤Ê¤É¤Î¥Ö¥é¥¦¥¶¥Õ¥©¥ó¤«¤é irc ¤ò¤¹¤ë¤â¤Î¡£
+i-mode, EZweb, vodafone live!, AirH" Phone ¤Ê¤É¤Î¥Ö¥é¥¦¥¶¥Õ¥©¥ó¤«¤é irc ¤ò¤¹¤ë¤â¤Î¡£
 plum ¤Ê¤É¤Î pirc (irc ¥×¥í¥­¥·) ¤ËÀܳ¤·¤Æ»È¤ï¤ì¤ë¤³¤È¤òÁÛÄꤷ¤Æ¤¤¤Þ¤¹¡£
 </p>
 
@@ -148,6 +148,12 @@ keitairc 
 ¤òÁªÂò¤¹¤ë¤È´ûÆÉÉôʬ¤â¸«¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£
 
 <p>
+¤Þ¤¿¡¢Ì¤ÆÉÆâÍƤΤ¢¤ë¥Á¥ã¥Í¥ë¤¬¤Ò¤È¤Ä¤Ç¤â¤¢¤ë¾ì¹ç¤Ï¡¢
+¥Á¥ã¥Í¥ë¤Î¥ê¥¹¥È¤Ë recent ¥ê¥ó¥¯¤¬¤Ä¤­¤Þ¤¹¡£
+recent ¥ê¥ó¥¯¤Ï¡¢Ã¼Ëö¤Ë¤è¤Ã¤Æ¤Ï * ¥­¡¼¤ò²¡¤¹¤À¤±¤Ç¤â¹Ô¤¯¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£
+recent ¤ò¥¯¥ê¥Ã¥¯¤¹¤ë¤È¡¢Á´¥Á¥ã¥Í¥ë¤Î̤Æɤò¤Þ¤È¤áÆɤߤǤ­¤Þ¤¹¡£
+
+<p>
 ¥Á¥ã¥Í¥ë¤Îȯ¸ÀÆâÍƤòÆɤó¤Ç¤¤¤Æ¡¢
 È¯¸À¤·¤¿¤¤¾ì¹ç¤Ï¥Ú¡¼¥¸¤Î¤Æ¤Ã¤Ú¤ó¤Ë¤¢¤ë¥Æ¥­¥¹¥È¥¨¥ê¥¢¤Ëµ­Æþ¤·¡¢
 OK ¥Ü¥¿¥ó¤ò²¡¤·¤Þ¤¹¡£
@@ -159,9 +165,9 @@ OK 
 </p>
 
 <p>
-ÅÅÏõ¡¤Î 7 ¤ò²¡¤¹¤È¥Ú¡¼¥¸ÀèƬ¤Ø¡¢
-ÅÅÏõ¡¤Î 8 ¤ò²¡¤¹¤È¥Á¥ã¥Í¥ë¤Î¥ê¥¹¥È¤Ø¡¢
-ÅÅÏõ¡¤Î 9 ¤ò²¡¤¹¤È¥Ú¡¼¥¸ËöÈø¤ËÈô¤Ó¤Þ¤¹¡£
+üËö¤Î 7 ¤ò²¡¤¹¤È¥Ú¡¼¥¸ÀèƬ¤Ø¡¢
+üËö¤Î 8 ¤ò²¡¤¹¤È¥Á¥ã¥Í¥ë¤Î¥ê¥¹¥È¤Ø¡¢
+üËö¤Î 9 ¤ò²¡¤¹¤È¥Ú¡¼¥¸ËöÈø¤ËÈô¤Ó¤Þ¤¹¡£
 </p>
 
 <h2>³«È¯</h2>
@@ -174,6 +180,9 @@ OK 
 <h2>Changes</h2>
 <dl>
 
+<dt>1.24
+<dd>Á´¥Á¥ã¥Í¥ë¤Î̤ÆɤޤȤáÆɤßÄɲÃ
+
 <dt>1.23
 <dd>¥Á¥ã¥Í¥ë̾¤ÎÆâÉô½èÍý¤Ï¾®Ê¸»ú¤ËÀµµ¬²½¤·¤Æ°·¤¦ (thanks to Akira Yamada)
 
index 8b55a68..aa925f0 100755 (executable)
--- 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 <morimoto@xantia.citroen.org>
 # 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++;
 
        # \e$BL$FI9T?t\e(B
-       if($unread{$canon_channel} > 0){
-               $buf .= sprintf(' <a href="%s%s.update">%d</a>',
+       if($unread_lines{$canon_channel}){
+               $buf .= sprintf(' <a href="%s%s,recent">%d</a>',
                                $docroot,
                                uri_escape($channel),
-                               $unread{$canon_channel});
+                               $unread_lines{$canon_channel});
        }
        $buf .= '<br>';
     }
 
     $buf .= qq(0 <a href="$docroot" accesskey="0">refresh list</a><br>);
+
+    if(grep($unread_lines{$_}, keys %unread_lines)){
+      $buf .= qq(* <a href="$docroot,recent" accesskey="*">recent</a><br>);
+    }
+
     $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 = '<html><head>';
     $content .= '<meta http-equiv="Cache-Control" content="max-age=0" />';
@@ -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 .= '<title>' . $config->web_title . '</title>';
-       $content .= '</head>';
-       $content .= '<body>';
+      $content .= '<title>' . $config->web_title . '</title>';
+      $content .= '</head>';
+      $content .= '<body>';
+
+      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 .= "<b>$channel_name{$canon_channel}</b>";
+           $content .= sprintf(' <a href="%s%s">more..</a><br>',
+                               $docroot, uri_escape($channel));
+           $content .= &render($channel_recent{$canon_channel});
+           $unread_lines{$canon_channel} = 0;
+           $channel_recent{$canon_channel} = '';
+         }
+       }
+        $content .= qq(<a accesskey="8" href="$docroot">ch list[8]</a>);
+      }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 .= '<input type="text" name="m" size="10">';
        $content .= '<input type="submit" accesskey="1" value="OK[1]">';
-        $content .= qq(<a accesskey="8" href="$docroot">back[8]</a><br>);
+        $content .= qq(<a accesskey="8" href="$docroot">ch list[8]</a><br>);
        # $content .= '<input type="submit" accesskey="1" value="&#63920;">';
        $content .= '</form>';
 
@@ -411,10 +455,11 @@ sub on_web_request{
            if(defined($channel_buffer{$canon_channel}) &&
               length($channel_buffer{$canon_channel})){
                $content .= '<a accesskey="9" href="#2"></a>';
-               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('<a accesskey="5" href="%s%s">
-                       ..more[5]</a>', $docroot, uri_escape($channel));
+                 $content .= sprintf('<a accesskey="5" href="%s%s">more[5]</a>',
+                                     $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} = '';