1 package TreeOfTexts::Controller::Root;
3 use namespace::autoclean;
4 use TreeOfTexts::Model::Analysis qw/ run_analysis /;
6 BEGIN { extends 'Catalyst::Controller' }
9 # Sets the actions in this controller to be registered with no prefix
10 # so they function identically to actions created in MyApp.pm
12 __PACKAGE__->config(namespace => '');
16 TreeOfTexts::Controller::Root - Root Controller for TreeOfTexts
20 [enter your description here]
30 sub index :Path :Args(0) {
31 my ( $self, $c ) = @_;
33 my $m = $c->model('Analysis');
35 my @all_texts = map { $_->{'title'} } @{$m->{'data'}};
36 $c->stash->{texts} = \@all_texts;
37 $c->stash->{template} = 'frontpage.tt';
40 sub view_text :Local {
42 my $m = $c->model('Analysis');
43 my $t = $m->{'data'}->[ $c->request->params->{'textid'} ];
44 $c->stash->{svg} = $t->{'svg'};
45 $c->stash->{variants} = $t->{'variants'};
46 $c->stash->{text_title} = $t->{'title'};
47 $c->stash->{total} = $t->{'variant_count'};
48 $c->stash->{genealogical} = $t->{'genealogical_count'};
49 $c->stash->{conflict} = $t->{'conflict_count'};
50 $c->stash->{template} = 'index.tt';
53 sub view_table :Local {
55 my $m = $c->model( 'Analysis' );
56 my $t = $m->{'data'}->[ $c->request->params->{'textid'} ];
57 $c->stash->{variants} = $t->{'variants'};
58 $c->stash->{template} = 'table_gadget.tt';
63 my $m = $c->model( 'Analysis' );
64 my $t = $m->{'data'}->[ $c->request->params->{'textid'} ];
65 $c->stash->{result} = $t->{'svg'};
66 $c->forward( "View::SVG" );
72 Standard 404 error page
77 my ( $self, $c ) = @_;
78 $c->response->body( 'Page not found' );
79 $c->response->status(404);
84 Attempt to render a view, if needed.
88 sub end : ActionClass('RenderView') {}
96 This library is free software. You can redistribute it and/or modify
97 it under the same terms as Perl itself.
101 __PACKAGE__->meta->make_immutable;