3 # $Id: View.pm,v 1.8 2008-02-26 00:41:09 morimoto Exp $
4 # $Source: /home/ishikawa/work/keitairc/tmp/keitairc/lib/Keitairc/View.pm,v $
6 # Copyright (c) 2008 Jun Morimoto <morimoto@mrmt.net>
7 # This program is covered by the GNU General Public License 2
9 package Keitairc::View;
14 use Keitairc::ClientInfo;
16 ################################################################
21 my $session_id = shift;
24 $me->{ClientInfo} = $ci;
25 if(defined $session_id){
26 $me->{session_id} = $session_id;
31 ################################################################
36 if($me->{Config}->web_root() eq '/'){
37 $path = sprintf('http://%s:%d%s%s',
38 $me->{Config}->web_host(),
39 $me->{Config}->web_port(),
44 $path = sprintf('http://%s%s%s',
45 $me->{Config}->web_host(),
46 $me->{Config}->web_root(),
50 ::log_debug("path [$path]");
52 my $response = HTTP::Response->new(302);
53 $response->push_header('Location', $path);
57 ################################################################
61 for my $template_dir (split(':', $me->{Config}->template_dir())){
62 if(-r "$template_dir/$template"){
63 return "$template_dir/$template";
68 ################################################################
75 $p->{root} = $me->{Config}->web_root();
76 $p->{title} = $me->{Config}->web_title();
77 $p->{version} = $me->{Config}->version();
78 $p->{timestamp} = timestamp();
80 $p->{viewport} = $me->{ClientInfo}->is_ipod();
81 $p->{is_ipod} = $me->{ClientInfo}->is_ipod();
82 $p->{is_docomo} = $me->{ClientInfo}->is_docomo();
83 $p->{is_ezweb} = $me->{ClientInfo}->is_ezweb();
84 $p->{is_softbank} = $me->{ClientInfo}->is_softbank();
87 $p->{"plugin_$_"} = 1;
88 } $::pl->list_plugins();
90 my $t = new HTML::Template(
91 filename => $me->template_path($template),
92 die_on_bad_params => 0,
103 ################################################################
106 my $template = shift;
108 my $response = HTTP::Response->new(200);
109 $vars->{content_type} |= 'text/html; charset=Shift_JIS';
110 $response->push_header('Content-type', $vars->{content_type});
111 $response->content($me->template($template, $vars));
115 ################################################################
117 my ($sec, $min, $hour, $day, $mon, $year) = localtime(time);
118 sprintf('%d/%d/%d %02d:%02d:%02d',
119 $year+1900, $mon+1, $day, $hour, $min, $sec);