# -*- mode: perl; coding: utf-8 -*-
# keitairc/lib/plugins/20mail
# メールアドレス

# The line number (1 incremented) and filename below must be
# actual. see perlsyn.
# line 10 "keitairc/lib/plugins/20mail"

$plugin = {
	name => 'mail',

	message_replace_regexp => '\b(\w[\w.+=-]*\@[\w.-]+[\w]\.[\w]{2,4})\b',
	message_replace_imprementation => sub {
		my ($request, $session_id, $param) = @_;
                my $ci = new Keitairc::ClientInfo($request);
		if ($ci->is_webkit()) {
			# ipod/iphone は mailto リンクにして keitairc側で
			# 余計な処理をしないで ブラウザ側処理に任せる
			# http://sourceforge.jp/ticket/browse.php?group_id=1057&tid=17740
			sprintf('<a target="_self" class="inline" href="mailto:%s">%s</a>',
				$param, $param);
		} else {
			sprintf('<a target="_self" class="inline" href="%s%s/mail/%s">%s</a>',
				$::cf->web_root(), $session_id, $param, $param);
		}
	},

	action_imprementation => sub {
		my ($request, $name, $session_id, $param_string) = @_;
		my $ci = new Keitairc::ClientInfo($request);
		my $view = new Keitairc::View($::cf, $ci);
		return $view->render('mail.html', {
			session_id => $session_id,
			mail => $param_string,
			     });
	}
};

1;
