allow automatic sizing of stemma; put more data into the visualizer
[scpubgit/stemmatology.git] / TreeOfTexts / lib / TreeOfTexts / Controller / Root.pm
1 package TreeOfTexts::Controller::Root;
2 use Moose;
3 use namespace::autoclean;
4 use TreeOfTexts::Model::Analysis qw/ run_analysis /;
5
6 BEGIN { extends 'Catalyst::Controller' }
7
8 #
9 # Sets the actions in this controller to be registered with no prefix
10 # so they function identically to actions created in MyApp.pm
11 #
12 __PACKAGE__->config(namespace => '');
13
14 =head1 NAME
15
16 TreeOfTexts::Controller::Root - Root Controller for TreeOfTexts
17
18 =head1 DESCRIPTION
19
20 [enter your description here]
21
22 =head1 METHODS
23
24 =head2 index
25
26 The root page (/)
27
28 =cut
29
30 sub index :Path :Args(0) {
31     my ( $self, $c ) = @_;
32
33     my $m = $c->model('Analysis');
34     my $i = 0;
35     my @all_texts = map { $_->{'title'} } @{$m->{'data'}};
36     $c->stash->{texts} = \@all_texts;
37     $c->stash->{template} = 'frontpage.tt';
38 }
39
40 sub view_text :Local {
41     my( $self, $c ) = @_;
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'; 
51 }
52 =head2 default
53
54 Standard 404 error page
55
56 =cut
57
58 sub default :Path {
59     my ( $self, $c ) = @_;
60     $c->response->body( 'Page not found' );
61     $c->response->status(404);
62 }
63
64 =head2 end
65
66 Attempt to render a view, if needed.
67
68 =cut
69
70 sub end : ActionClass('RenderView') {}
71
72 =head1 AUTHOR
73
74 Tara L Andrews
75
76 =head1 LICENSE
77
78 This library is free software. You can redistribute it and/or modify
79 it under the same terms as Perl itself.
80
81 =cut
82
83 __PACKAGE__->meta->make_immutable;
84
85 1;