From 5f260b1a1e65d4fabaa6fbd23ee61ec1aeaeef2d Mon Sep 17 00:00:00 2001 From: franck cuny Date: Sun, 5 Apr 2009 17:34:44 +0200 Subject: 3 lasts clouds, set lang, store last template in session --- lib/intentioncloud/Controller/Root.pm | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'lib/intentioncloud') diff --git a/lib/intentioncloud/Controller/Root.pm b/lib/intentioncloud/Controller/Root.pm index dda0092..0fea5f9 100644 --- a/lib/intentioncloud/Controller/Root.pm +++ b/lib/intentioncloud/Controller/Root.pm @@ -29,13 +29,32 @@ sub how : Local { sub index : Local { my ( $self, $c ) = @_; $c->stash->{ template } = 'cloud/search.tt'; - $c->stash( last_clouds => - [ $c->model( 'DB::Search' )->search()->slice( 0, 2 ) ] ); + $c->stash( + last_clouds => [ $c->model( 'DB::Search' )->search()->slice( 0, 2 ) ] + ); +} + +sub lang : Regex('^lang/(\w{2})$') { + my ( $self, $c ) = @_; + + my $lang = $c->req->captures->[ 0 ]; + $c->languages( $lang ); + $c->session->{ lang } = $lang; + if ( $c->session->{ referer } ) { + $c->stash->{ template } = $c->session->{ referer }; + } else { + + $c->forward( '/index' ); + } } sub end : ActionClass('RenderView') { my ( $self, $c ) = @_; - $c->forward('intentioncloud::View::TT'); + $c->session->{referer} = $c->stash->{template}; + if (defined $c->session->{'lang'}){ + $c->languages( [ $c->session->{'lang'} ]); + } + $c->forward( 'intentioncloud::View::TT' ); } 1; -- cgit v1.2.3