store tradition objects in a KiokuDB instance
[scpubgit/stemmatology.git] / TreeOfTexts / lib / TreeOfTexts / Controller / Root.pm
CommitLineData
dbcf12a6 1package TreeOfTexts::Controller::Root;
2use Moose;
3use namespace::autoclean;
4use TreeOfTexts::Model::Analysis qw/ run_analysis /;
5
6BEGIN { 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
16TreeOfTexts::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
26The root page (/)
27
28=cut
29
30sub index :Path :Args(0) {
31 my ( $self, $c ) = @_;
32
eb20780f 33 my $m = $c->model('Analysis');
e367f5c0 34 my $i = 0;
35 my @all_texts = map { $_->{'title'} } @{$m->{'data'}};
36 $c->stash->{texts} = \@all_texts;
37 $c->stash->{template} = 'frontpage.tt';
dbcf12a6 38}
39
e367f5c0 40sub 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}
a275e7e6 52
53sub view_table :Local {
54 my( $self, $c ) = @_;
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';
59}
60
61sub view_svg :Local {
62 my( $self, $c ) = @_;
63 my $m = $c->model( 'Analysis' );
64 my $t = $m->{'data'}->[ $c->request->params->{'textid'} ];
eb1ac99d 65 $c->stash->{svg} = $t->{'svg'};
66 $c->stash->{template} = 'stemma_gadget.tt';
a275e7e6 67}
68
69
dbcf12a6 70=head2 default
71
72Standard 404 error page
73
74=cut
75
76sub default :Path {
77 my ( $self, $c ) = @_;
78 $c->response->body( 'Page not found' );
79 $c->response->status(404);
80}
81
82=head2 end
83
84Attempt to render a view, if needed.
85
86=cut
87
88sub end : ActionClass('RenderView') {}
89
90=head1 AUTHOR
91
92Tara L Andrews
93
94=head1 LICENSE
95
96This library is free software. You can redistribute it and/or modify
97it under the same terms as Perl itself.
98
99=cut
100
101__PACKAGE__->meta->make_immutable;
102
1031;