From: morimoto Date: Wed, 9 Jan 2008 18:49:17 +0000 (+0000) Subject: abandoned web_root option X-Git-Tag: tag20080719~89 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=b42201545339c1f798fcee8e9132bb09d971b430;hp=fceae1752a1d7941db3dce2d2a9eba39575a448f;p=keitairc%2Fkeitairc.git abandoned web_root option now template_dir works as search path --- diff --git a/lib/Keitairc/View.pm b/lib/Keitairc/View.pm index 2e5fd03..fd7f7c3 100644 --- a/lib/Keitairc/View.pm +++ b/lib/Keitairc/View.pm @@ -1,6 +1,6 @@ # -*-perl-*- # Keitairc::View -# $Id: View.pm,v 1.1 2008-01-08 05:52:14 morimoto Exp $ +# $Id: View.pm,v 1.2 2008-01-09 18:49:17 morimoto Exp $ # $Source: /home/ishikawa/work/keitairc/tmp/keitairc/lib/Keitairc/View.pm,v $ # # Copyright (c) 2008 Jun Morimoto @@ -33,11 +33,9 @@ sub redirect{ my $me = shift; my $path = shift; - $path =~ s|^/+||; $path = sprintf('http://%s:%d%s%s', $me->{Config}->web_host(), $me->{Config}->web_port(), - $me->{Config}->web_root(), $path); ::log_debug("path [$path]"); my $response = HTTP::Response->new(302); @@ -46,16 +44,25 @@ sub redirect{ } ################################################################ +sub template_path{ + my $me = shift; + my $template = shift; + for my $template_dir (split(':', $me->{Config}->template_dir())){ + if(-r "$template_dir/$template"){ + return "$template_dir/$template"; + } + } +} + +################################################################ sub render{ my $me = shift; my $template = shift; my $vars = shift; - my $t = new HTML::Template( - filename => $me->{Config}->template_dir() . '/' . $template, + filename => $me->template_path($template), die_on_bad_params => 0, cache => 1); - $t->param(web_root => $me->{Config}->web_root()); $t->param(title => $me->{Config}->web_title()); $t->param(version => $me->{Config}->version()); $t->param(viewport => $me->{ClientInfo}->is_ipod());