# -*- mode: perl; coding: utf-8 -*-
# $Id: 02topic,v 1.1 2008-08-02 18:35:54 morimoto Exp $
# $Source: /home/ishikawa/work/keitairc/tmp/keitairc/t/02_Plugins/02topic,v $

# WARNING: This file is a part of Keitairc::Plugins test suite, not
# actual working code.

$plugin = {
	name => 'topic',
	action_imprementation => sub {
		use encoding 'utf8';
		my ($request, $name, $session_id, $param_string) = @_;
		my $buf;

		for my $cid ($::ib->channels()){
			my $channel = $::ib->cid2name($cid);
			$buf .= sprintf(' <a href="all/%d">%s</a><br />',
					$cid,
					$::ib->simple_escape($::ib->compact_channel_name($cid)));
			my $topic = $::ib->simple_escape(Encode::decode($::cf->irc_charset(), $::ib->topic($cid)));
			if(!defined($topic) || !length($topic)){
				$topic = '(ﾄﾋﾟｯｸ未設定)';
			}
			$buf .= $topic;
			$buf .= "<br />\n";
		}

		$buf = Encode::encode($::cf->web_charset(), $buf);
		my $ci = new Keitairc::ClientInfo($request);
		my $view = new Keitairc::View($::cf, $ci);
		return $view->render('topic.html', { buf => $buf });
		no encoding 'utf8';
	}
};

1;
