1 # -*- mode: perl; coding: utf-8 -*-
2 # $Id: 01index,v 1.1 2008-08-02 18:35:54 morimoto Exp $
3 # $Source: /home/ishikawa/work/keitairc/tmp/keitairc/t/02_Plugins/01index,v $
5 # WARNING: This file is a part of Keitairc::Plugins test suite, not
10 action_imprementation => sub {
11 my ($request, $name, $session_id, $param_string) = @_;
13 ::send_message($request);
15 my $unread_channels = 0;
18 my $format_mtime = sub{
21 return if($mtime <= 0);
22 my $timediff = time - $mtime;
24 return $timediff . '秒';
27 return int($timediff/60) . '分';
29 if($timediff < 86400){
30 return int($timediff/3600) . '時間';
32 if($timediff < 86400 * 30){
33 return int($timediff/86400) . '日';
35 if($timediff < 86400 * 365){
36 return int($timediff/86400/30) . 'ヶ月';
38 return int($timediff/86400/365) . '年';
43 for my $cid ($::ib->channels()){
45 my $channel = $::ib->cid2name($cid);
46 my $cname = $::ib->simple_escape(encode($::cf->web_charset(), $::ib->compact_channel_name($cid)));
49 sprintf('<a accesskey="%1d" href="all/%d">[%1d] %s</a>',
56 sprintf('<a href="all/%d"> %s</a>',
62 if($::ib->unread_lines($cid)){
64 sprintf(' <a href="unread/%d">%s</a>',
66 $::ib->unread_lines($cid));
70 $p->{mtime} = Encode::encode($::cf->web_charset(), $format_mtime->($::ib->mtime($cid)));
74 my $ci = new Keitairc::ClientInfo($request);
75 my $view = new Keitairc::View($::cf, $ci);
76 return $view->render('index.html',
79 unread => $unread_channels,