OSDN Git Service

*** empty log message ***
[keitairc/keitairc.git] / lib / plugins / 00index
1 # -*-perl-*-
2 # keitairc/lib/plugins/00index
3\83`\83\83\83l\83\8b\88ê\97\97
4 # $Id: 00index,v 1.1 2008-01-09 19:30:34 morimoto Exp $
5 # $Source: /home/ishikawa/work/keitairc/tmp/keitairc/lib/plugins/00index,v $
6
7 $plugin = {
8         name => 'index',
9         action_imprementation => sub {
10                 my ($request, $name, $session_id, $param_string) = @_;
11                 my $unread_channels = 0;
12                 my $accesskey = 1;
13                 my $buf;
14
15                 for my $channel ($::ib->channels()){
16                         if($accesskey < 10){
17                                 $buf .= sprintf('<a accesskey="%1d" href="all/%s">[%1d] %s</a>',
18                                                 $accesskey,
19                                                 ::uri_escape($channel),
20                                                 $accesskey,
21                                                 $::ib->compact_channel_name($::ib->name($channel)));
22                         }else{
23                                 $buf .= sprintf('<a href="all/%s">    %s</a>',
24                                                 ::uri_escape($channel),
25                                                 $::ib->compact_channel_name($::ib->name($channel)));
26                         }
27                         $accesskey++;
28
29                         # \96¢\93Ç\8ds\90\94
30                         if($::ib->unread_lines($channel)){
31                                 $buf .= sprintf(' <a href="unread/%s">%s</a>',
32                                                 ::uri_escape($channel),
33                                                 $::ib->unread_lines($channel));
34                                 $unread_channels++;
35                         }
36                         $buf .= "<br />\n";
37                 }
38
39                 my $ci = new Keitairc::ClientInfo($request);
40                 my $view = new Keitairc::View($::cf, $ci);
41                 return $view->render('index.html',
42                                      {
43                                              buf => $buf,
44                                              unread => $unread_channels,
45                                      });
46         }
47 };
48
49 1;