1 package TreeOfTexts::Controller::Root;
3 use namespace::autoclean;
4 use Text::Tradition::Analysis qw/ run_analysis /;
7 BEGIN { extends 'Catalyst::Controller' }
10 # Sets the actions in this controller to be registered with no prefix
11 # so they function identically to actions created in MyApp.pm
13 __PACKAGE__->config(namespace => '');
17 TreeOfTexts::Controller::Root - Root Controller for TreeOfTexts
21 [enter your description here]
31 sub index :Path :Args(0) {
32 my ( $self, $c ) = @_;
34 my $m = $c->model('Directory');
36 foreach my $id ( $m->traditions ) {
39 'name' => $m->tradition( $id )->name,
40 'has_stemma' => defined $m->stemma( $id ),
42 push( @all_texts, $data );
45 $c->stash->{texts} = \@all_texts;
46 $c->stash->{template} = 'frontpage.tt';
49 sub relationships :Local {
51 my $m = $c->model('Directory');
52 my $tradition = $m->tradition( $c->request->params->{'textid'} );
53 $c->stash->{alignment} = $tradition->collation->make_alignment_table( 'refs' );
54 $c->stash->{template} = 'relationships.tt';
57 sub stexaminer :Local {
59 my $m = $c->model('Directory');
60 my $id = $c->request->params->{'textid'};
61 my $tradition = $m->tradition( $id );
62 my $stemma = $m->stemma( $id );
63 my $t = run_analysis( $tradition, $stemma );
64 $c->stash->{svg} = $stemma->as_svg;
65 $c->stash->{variants} = $t->{'variants'};
66 $c->stash->{text_title} = $tradition->name;
67 $c->stash->{total} = $t->{'variant_count'};
68 $c->stash->{genealogical} = $t->{'genealogical_count'};
69 $c->stash->{conflict} = $t->{'conflict_count'};
70 $c->stash->{template} = 'index.tt';
73 sub view_table :Local {
75 my $m = $c->model('Directory');
76 my $id = $c->request->params->{'textid'};
77 my $t = run_analysis( $m->tradition( $id ), $m->stemma( $id ) );
78 $c->stash->{variants} = $t->{'variants'};
79 $c->stash->{template} = 'table_gadget.tt';
84 my $m = $c->model('Directory');
85 my $stemma = $m->stemma( $c->request->params->{'textid'} );
87 $c->stash->{svg} = $stemma->as_svg;
89 $c->stash->{template} = 'stemma_gadget.tt';
94 Standard 404 error page
99 my ( $self, $c ) = @_;
100 $c->response->body( 'Page not found' );
101 $c->response->status(404);
106 Attempt to render a view, if needed.
110 sub end : ActionClass('RenderView') {}
118 This library is free software. You can redistribute it and/or modify
119 it under the same terms as Perl itself.
123 __PACKAGE__->meta->make_immutable;