OSDN Git Service

obsoletes show_newmsgonly option\rdefines plugin_xxx symbols at template expansion...
authormorimoto <morimoto@180c8125-5b33-4295-ad04-72a68a15b4cc>
Mon, 14 Jan 2008 05:21:09 +0000 (05:21 +0000)
committermorimoto <morimoto@180c8125-5b33-4295-ad04-72a68a15b4cc>
Mon, 14 Jan 2008 05:21:09 +0000 (05:21 +0000)
lib/Keitairc/Config.pm
lib/Keitairc/IrcBuffer.pm
lib/Keitairc/View.pm
lib/plugins/00all
lib/plugins/00location
lib/plugins/00location_receiver
lib/plugins/00postme
lib/plugins/00unread
lib/templates/all.html
lib/templates/location_receiver.html
lib/templates/unread.html

index 406bde8..cf1069c 100644 (file)
@@ -1,6 +1,6 @@
 # -*-perl-*-
 # Keitairc::Config
-# $Id: Config.pm,v 1.3 2008-01-13 12:12:55 morimoto Exp $
+# $Id: Config.pm,v 1.4 2008-01-14 05:21:09 morimoto Exp $
 # $Source: /home/ishikawa/work/keitairc/tmp/keitairc/lib/Keitairc/Config.pm,v $
 #
 # Copyright (c) 2008 Jun Morimoto <morimoto@mrmt.net>
@@ -61,6 +61,11 @@ sub new{
 
        $me->args(\@argv);
 
+
+       if(defined $me->show_newmsgonly()){
+               ::log("show_newmsgonly has obsoleted from keitairc 2.0");
+       }
+
        if(defined $me->web_username()){
                ::log("web_username has obsoleted from keitairc 2.0");
        }
index 4c2a424..d5a67f8 100644 (file)
@@ -1,6 +1,6 @@
 # -*-perl-*-
 # Keitairc::IrcBuffer
-# $Id: IrcBuffer.pm,v 1.6 2008-01-13 15:31:09 morimoto Exp $
+# $Id: IrcBuffer.pm,v 1.7 2008-01-14 05:21:09 morimoto Exp $
 # $Source: /home/ishikawa/work/keitairc/tmp/keitairc/lib/Keitairc/IrcBuffer.pm,v $
 #
 # Copyright (c) 2008 Jun Morimoto <morimoto@mrmt.net>
@@ -303,14 +303,19 @@ sub colorize{
        do{
                if($colored){
                        s|\x03(\d{1,2})|sprintf('</font><font color="%s">', $ct{0+$1})|e;
+                       if(s|\x03|</font>|){
+                               $colored = 0;
+                       }
                }else{
-                       s|\x03(\d{1,2})|sprintf('<font color="%s">', $ct{0+$1})|e;
-                       $colored = 1;
+                       if(s|\x03(\d{1,2})|sprintf('<font color="%s">', $ct{0+$1})|e){
+                               $colored = 1;
+                       }
                }
        }while(m|\x03\d{1,2}|);
 
-       # s|\x03|</font>|g if $colored;
-       $_ .= '</font>' if $colored;
+       if($colored){
+               $_ .= '</font>';
+       }
 
        $_;
 }
index ae7d4ac..2356113 100644 (file)
@@ -1,6 +1,6 @@
 # -*-perl-*-
 # Keitairc::View
-# $Id: View.pm,v 1.5 2008-01-13 15:31:09 morimoto Exp $
+# $Id: View.pm,v 1.6 2008-01-14 05:21:09 morimoto Exp $
 # $Source: /home/ishikawa/work/keitairc/tmp/keitairc/lib/Keitairc/View.pm,v $
 #
 # Copyright (c) 2008 Jun Morimoto <morimoto@mrmt.net>
@@ -55,7 +55,7 @@ sub template_path{
 }
 
 ################################################################
-sub render{
+sub template{
        my $me = shift;
        my $template = shift;
        my $vars = shift;
@@ -63,12 +63,17 @@ sub render{
        my $p = {};
        $p->{title} = $me->{Config}->web_title();
        $p->{version} = $me->{Config}->version();
+       $p->{timestamp} = timestamp();
+
        $p->{viewport} = $me->{ClientInfo}->is_ipod();
        $p->{is_ipod} = $me->{ClientInfo}->is_ipod();
        $p->{is_docomo} = $me->{ClientInfo}->is_docomo();
        $p->{is_ezweb} = $me->{ClientInfo}->is_ezweb();
        $p->{is_softbank} = $me->{ClientInfo}->is_softbank();
-       $p->{timestamp} = timestamp();
+
+       map {
+               $p->{"plugin_$_"} = 1;
+       } $::pl->list_plugins();
 
        my $t = new HTML::Template(
                filename => $me->template_path($template),
@@ -79,9 +84,18 @@ sub render{
        if(defined $vars){
                $t->param($vars);
        }
+
+       $t->output();
+}
+
+################################################################
+sub render{
+       my $me = shift;
+       my $template = shift;
+       my $vars = shift;
        my $response = HTTP::Response->new(200);
        $response->push_header('Content-type', 'text/html; charset=Shift_JIS');
-       $response->content($t->output());
+       $response->content($me->template($template, $vars));
        $response;
 }
 
index c2e7917..bd9a255 100644 (file)
@@ -1,7 +1,7 @@
 # -*-perl-*-
 # keitairc/lib/plugins/00all
 # \83`\83\83\83l\83\8b\82Ì\91S\83\81\83b\83Z\81[\83W\89{\97\97
-# $Id: 00all,v 1.2 2008-01-13 15:31:09 morimoto Exp $
+# $Id: 00all,v 1.3 2008-01-14 05:21:09 morimoto Exp $
 # $Source: /home/ishikawa/work/keitairc/tmp/keitairc/lib/plugins/00all,v $
 
 $plugin = {
@@ -14,21 +14,10 @@ $plugin = {
                ::send_message($request, $channel);
 
                my $buf;
-               my $no_message_here_yet;
                if(defined($::ib->name($cid))){
                        if(length($::ib->buffer($cid))){
-                               if($::cf->show_newmsgonly() && $::ib->message_added()){
-                                       $buf = ::render_line($::ib->unread($cid), $session_id) ||
-                                               '(\96¢\93Ç\94­\8c¾\82Í\82 \82è\82Ü\82¹\82ñ)';
-                                       $buf .= sprintf('<br /><a accesskey="5" href="../all/%s">[5] \91S\94­\8c¾\82Ö</a>', $cid);
-                               }else{
-                                       $buf = ::render_line($::ib->buffer($cid), $session_id);
-                               }
-                       }else{
-                               $no_message_here_yet = 1;
+                               $buf = ::render_line($::ib->buffer($cid), $session_id);
                        }
-               }else{
-                       $buf = '\8ew\92è\82ÌÁ¬ÈÙ\82Í\91\8dÝ\82µ\82Ü\82¹\82ñ';
                }
 
                $::ib->message_added(0); # clear check flags
@@ -41,7 +30,6 @@ $plugin = {
                $p->{buf} = $buf;
                $p->{channel_compact} = $::ib->compact_channel_name($cid);
                $p->{cid} = $cid;
-               $p->{no_message_here_yet} = $no_message_here_yet;
                return $view->render('all.html', $p);
        }
 };
index c70081c..6d00890 100644 (file)
@@ -1,7 +1,9 @@
 # -*-perl-*-
 # keitairc/lib/plugins/00location
+# °ÌÃÖ¾ðÊóÁ÷¿®
+# ¸½ºß¤Þ¤À au ÀìÍÑ
 # 
-# $Id: 00location,v 1.1 2008-01-13 15:31:09 morimoto Exp $
+# $Id: 00location,v 1.2 2008-01-14 05:21:09 morimoto Exp $
 # $Source: /home/ishikawa/work/keitairc/tmp/keitairc/lib/plugins/00location,v $
 
 $plugin = {
index 4d0cfda..a895227 100644 (file)
@@ -1,18 +1,22 @@
 # -*-perl-*-
 # keitairc/lib/plugins/00location_receiver
+# °ÌÃÖ¾ðÊóÁ÷¿®¡¢¤Î¥³¡¼¥ë¥Ð¥Ã¥¯
+# ¸½ºß¤Þ¤À au ÀìÍÑ
+#
 # see KDDI au: µ»½Ñ¾ðÊó > ´Ê°×°ÌÃÖ¾ðÊó
 # http://www.au.kddi.com/ezfactory/tec/spec/eznavi.html
 #
-# $Id: 00location_receiver,v 1.1 2008-01-13 15:31:09 morimoto Exp $
+# $Id: 00location_receiver,v 1.2 2008-01-14 05:21:09 morimoto Exp $
 # $Source: /home/ishikawa/work/keitairc/tmp/keitairc/lib/plugins/00location_receiver,v $
-
-use Data::Dumper;
+#
+# $param_string comes in form like
+#   3/?datum=tokyo&unit=dms&lat=35.44.51.75&lon=139.35.15.0
 
 $plugin = {
        name => 'location_receiver',
        action_imprementation => sub {
                my ($request, $name, $session_id, $param_string) = @_;
-               my $cid = $param_string;
+               my ($cid) = ($param_string =~ /^(\d+)/);
                my $uri = $request->uri();;
                $uri =~ s/.*\?//;
                my %h;
index b8f2daf..84baca7 100644 (file)
@@ -1,6 +1,6 @@
 # -*-perl-*-
 # keitairc/lib/plugins/00postme
-# $Id: 00postme,v 1.1 2008-01-13 12:12:55 morimoto Exp $
+# $Id: 00postme,v 1.2 2008-01-14 05:21:09 morimoto Exp $
 # $Source: /home/ishikawa/work/keitairc/tmp/keitairc/lib/plugins/00postme,v $
 
 use Net::SMTP;
@@ -12,14 +12,16 @@ $plugin = {
                my $ci = new Keitairc::ClientInfo($request);
                my $view = new Keitairc::View($::cf, $ci);
 
-               my $error = {};
-               $error->{no_smtp_server} = 1 unless $::cf->smtp_server();
-               $error->{no_smtp_from} = 1 unless $::cf->smtp_from();
-               $error->{no_smtp_to} = 1 unless $::cf->smtp_to();
-               if(keys(%{$error})){
-                       $error->{has_error} = 1;
-                       $error->{session_id} = $session_id;
-                       return $view->render('postme.html', $error);
+               {
+                       my $error = {};
+                       $error->{no_smtp_server} = 1 unless $::cf->smtp_server();
+                       $error->{no_smtp_from} = 1 unless $::cf->smtp_from();
+                       $error->{no_smtp_to} = 1 unless $::cf->smtp_to();
+                       if(keys(%{$error})){
+                               $error->{has_error} = 1;
+                               $error->{session_id} = $session_id;
+                               return $view->render('postme.html', $error);
+                       }
                }
 
                my $message = $request->content();
@@ -31,13 +33,13 @@ $plugin = {
                $smtp->mail($::cf->smtp_from());
                $smtp->to($::cf->smtp_to());
                $smtp->data();
-               $smtp->datasend('To: ' . $::cf->smtp_to() . "\n");
-               $smtp->datasend("Subject: memo from keitairc\n");
-               $smtp->datasend("Content-Type: text/plain; charset=iso-2022-jp\n");
-               $smtp->datasend("MIME-Version: 1.0\n");
-               $smtp->datasend("\n");
-               $smtp->datasend($message);
-               $smtp->datasend("\n");
+               $smtp->datasend(
+                       $view->template('postme.eml', {
+                               from => $::cf->smtp_from(),
+                               to => $::cf->smtp_to(),
+                               message => $message,                    
+                               })
+                       );
                $smtp->dataend();
                $smtp->quit();
 
index 9bb73e1..3c58c15 100644 (file)
@@ -1,7 +1,7 @@
 # -*-perl-*-
 # keitairc/lib/plugins/00unread
 # \83`\83\83\83l\83\8b\82Ì\96¢\93Ç\83\81\83b\83Z\81[\83W\89{\97\97
-# $Id: 00unread,v 1.2 2008-01-13 15:31:09 morimoto Exp $
+# $Id: 00unread,v 1.3 2008-01-14 05:21:09 morimoto Exp $
 # $Source: /home/ishikawa/work/keitairc/tmp/keitairc/lib/plugins/00unread,v $
 
 $plugin = {
@@ -14,17 +14,10 @@ $plugin = {
                ::send_message($request, $channel);
 
                my $buf;
-               my $no_message_here_yet;
                if(defined($::ib->name($cid))){
                        if(length($::ib->buffer($cid))){
-                               $buf = ::render_line($::ib->unread($cid), $session_id) ||
-                                       '(\96¢\93Ç\94­\8c¾\82Í\82 \82è\82Ü\82¹\82ñ)';
-                               $buf .= sprintf('<hr /><a accesskey="5" href="../all/%d">[5] \91S\94­\8c¾\82Ö</a><br />', $cid);
-                       }else{
-                               $no_message_here_yet = 1;
+                               $buf = ::render_line($::ib->unread($cid), $session_id);
                        }
-               }else{
-                       $buf = '\8ew\92è\82ÌÁ¬ÈÙ\82Í\91\8dÝ\82µ\82Ü\82¹\82ñ';
                }
 
                $::ib->message_added(0); # clear check flags
@@ -36,7 +29,6 @@ $plugin = {
                        buf => $buf,
                        channel_compact => $::ib->compact_channel_name($cid),
                        cid => $cid,
-                       no_message_here_yet => $no_message_here_yet,
                             });
        }
 };
index 48928a0..92efc99 100644 (file)
@@ -10,9 +10,6 @@
   </head>
   <body>
     <!-- tmpl_var channel_compact -->\82Ì\94­\8c¾<br />
-    <a name="1"></a>
-    <a accesskey="7" href="#1"></a>
-
     <form action="<!-- tmpl_var cid -->" method="post">
       <tmpl_if is_ipod>
        <input type="text" name="m">
       <input type="submit" accesskey="1" value="[1] \94­\8c¾/\8dX\90V"><br />
     </form>
 
-    <tmpl_if no_message_here_yet>
+    <tmpl_if buf>
+      <!-- tmpl_var buf -->
+    <tmpl_else>
       (\82Ü\82¾\94­\8c¾\82ª\82 \82è\82Ü\82¹\82ñ)
     </tmpl_if>
-    <!-- tmpl_var buf -->
 
-    <a accesskey="9" href="#2"></a>
-    <a name="2"></a>
     <hr />
+
     <a accesskey="2" href="../nick/<!-- tmpl_var cid -->">[2] nickؽÄ</a><br />
     <a accesskey="8" href="../index">[8] Á¬ÈÙؽÄ</a><br />
-    <a accesskey="8" href="../location/<!-- tmpl_var cid -->">[9] \88Ê\92u\8fî\95ñ\91\97\90M</a><br />
+    <tmpl_if plugin_location>
+      <tmpl_if is_ezweb>
+       <a accesskey="9" href="../location/<!-- tmpl_var cid -->">[9] \88Ê\92u\8fî\95ñ\91\97\90M</a><br />
+      </tmpl_if>
+    </tmpl_if>
     <hr />
     <!-- tmpl_var timestamp --><br />
     keitairc <!-- tmpl_var version -->
index 81fb91f..502431d 100644 (file)
   </head>
   <body>
     <!-- tmpl_var channel_compact -->\82Ö\88Ê\92u\8fî\95ñ\82ð\94­\8c¾<br />
-    datum<!-- tmpl_var datum --><br />
-    unit<!-- tmpl_var unit --><br />
-    lat<!-- tmpl_var lat --><br />
-    lon<!-- tmpl_var lon --><br />
+    datum <!-- tmpl_var datum --><br />
+    unit <!-- tmpl_var unit --><br />
+    lat <!-- tmpl_var lat --><br />
+    lon <!-- tmpl_var lon --><br />
 
     <hr />
     <a accesskey="8" href="/<!-- tmpl_var session_id -->/index">[8] Á¬ÈÙؽÄ</a><br />
index 14d1dcf..f40ac37 100644 (file)
@@ -10,8 +10,6 @@
   </head>
   <body>
     <!-- tmpl_var channel_compact -->\82Ì\96¢\93Ç\94­\8c¾<br />
-    <a name="1"></a>
-    <a accesskey="7" href="#1"></a>
 
     <form action="<!-- tmpl_var cid -->" method="post">
       <tmpl_if is_ipod>
       <input type="submit" accesskey="1" value="[1] \94­\8c¾/\8dX\90V"><br />
     </form>
 
-    <tmpl_if no_message_here_yet>
+    <tmpl_if buf>
+      <!-- tmpl_var buf -->
+      <hr />
+      <a accesskey="5" href="../all/<!-- tmpl_var cid -->">[5] \91S\94­\8c¾\82Ö</a><br />
+    <tmpl_else>
       (\82Ü\82¾\94­\8c¾\82ª\82 \82è\82Ü\82¹\82ñ)
+      <hr />
     </tmpl_if>
-    <!-- tmpl_var buf -->
-    <a accesskey="9" href="#2"></a>
-    <a name="2"></a>
-    <hr />
+
     <a accesskey="2" href="../nick/<!-- tmpl_var cid -->">[2] nickؽÄ</a><br />
     <a accesskey="8" href="../index">[8] Á¬ÈÙؽÄ</a><br />
+    <tmpl_if plugin_location>
+      <tmpl_if is_ezweb>
+       <a accesskey="9" href="../location/<!-- tmpl_var cid -->">[9] \88Ê\92u\8fî\95ñ\91\97\90M</a><br />
+      </tmpl_if>
+    </tmpl_if>
     <hr />
     <!-- tmpl_var timestamp --><br />
     keitairc <!-- tmpl_var version -->