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]
27 The root page (/). Lists the traditions available in the DB to work on,
28 and should also eventually have an 'Upload new' interface.
32 sub index :Path :Args(0) {
33 my ( $self, $c ) = @_;
35 my $m = $c->model('Directory');
37 foreach my $id ( $m->tradition_ids ) {
40 'name' => $m->name( $id ),
42 push( @all_texts, $data );
45 $c->stash->{texts} = \@all_texts;
46 $c->stash->{template} = 'frontpage.tt';
49 =head2 tradition (TODO)
51 The main page for a tradition, with information about it and links to the
56 The relationship editor tool.
60 sub relationships :Local {
62 my $m = $c->model('Directory');
63 my $tradition = $m->tradition( $c->request->params->{'textid'} );
64 $c->stash->{alignment} = $tradition->collation->make_alignment_table( 'refs' );
65 $c->stash->{template} = 'relationships.tt';
70 The stemma analysis tool with the pretty colored table.
74 sub stexaminer :Local {
76 my $m = $c->model('Directory');
77 my $tradition = $m->tradition( $c->request->params->{'textid'} );
78 my $stemma = $tradition->stemma;
79 # TODO Think about caching the stemma in a session
80 $c->stash->{svg} = $stemma->as_svg;
81 $c->stash->{text_title} = $tradition->name;
82 $c->stash->{template} = 'index.tt';
83 # TODO Run the analysis as AJAX from the loaded page.
84 my $t = run_analysis( $tradition );
85 $c->stash->{variants} = $t->{'variants'};
86 $c->stash->{total} = $t->{'variant_count'};
87 $c->stash->{genealogical} = $t->{'genealogical_count'};
88 $c->stash->{conflict} = $t->{'conflict_count'};
91 =head1 OPENSOCIAL URLs
95 Simple gadget to return the analysis table for the stexaminer
99 sub view_table :Local {
100 my( $self, $c ) = @_;
101 my $m = $c->model('Directory');
102 my $id = $c->request->params->{'textid'};
103 my $t = run_analysis( $m->tradition( $id ), $m->stemma( $id ) );
104 $c->stash->{variants} = $t->{'variants'};
105 $c->stash->{template} = 'table_gadget.tt';
110 Simple gadget to return the SVG for a given stemma
114 sub view_svg :Local {
115 my( $self, $c ) = @_;
116 my $m = $c->model('Directory');
117 my $stemma = $m->tradition( $c->request->params->{'textid'} )->stemma;
119 $c->stash->{svg} = $stemma->as_svg;
121 $c->stash->{template} = 'stemma_gadget.tt';
126 Standard 404 error page
131 my ( $self, $c ) = @_;
132 $c->response->body( 'Page not found' );
133 $c->response->status(404);
138 Attempt to render a view, if needed.
142 sub end : ActionClass('RenderView') {}
150 This library is free software. You can redistribute it and/or modify
151 it under the same terms as Perl itself.
155 __PACKAGE__->meta->make_immutable;