move Translate to be Translator
[catagits/catbook-code.git] / lib / LolCatalyst / Lite / Controller / Root.pm
CommitLineData
cc003be0 1package LolCatalyst::Lite::Controller::Root;
2
3use strict;
4use warnings;
5use parent 'Catalyst::Controller';
6
7__PACKAGE__->config->{namespace} = '';
8
9sub index :Path :Args(0) {
10 my ( $self, $c ) = @_;
11}
12
13sub default :Path {
14 my ( $self, $c ) = @_;
15 $c->response->status(404);
16 $c->response->body( 'Page not found' );
17}
18
19sub translate :Local {
20 my ($self, $c) = @_;
21 my $lol = $c->req->body_params->{lol}; # only for a POST request
22 # $c->req->params->{lol} would catch GET or POST
23 # $c->req->query_params would catch GET params only
24 $c->stash(
25 lol => $lol,
2e909c0d 26 result => $c->model('Translator')->translate($lol),
cc003be0 27 template => 'index.tt',
28 );
29}
30
31sub translate_service : Local {
32 my ($self, $c) = @_;
33 $c->forward('translate');
34 $c->stash->{current_view} = 'Service';
35}
36
37sub end : ActionClass('RenderView') {
38 my ($self, $c) = @_;
39 my $errors = scalar @{$c->error};
40 if ($errors) {
41 $c->res->status(500);
42 $c->res->body('internal server error');
43 $c->clear_errors;
44 }
45}
46
471;