1 package stemmaweb::Controller::Stexaminer;
3 use namespace::autoclean;
6 use Text::Tradition::Analysis qw/ run_analysis /;
8 BEGIN { extends 'Catalyst::Controller' }
13 stemmaweb::Controller::Stexaminer - Simple controller for stemma display
17 The stemma analysis tool with the pretty colored table.
21 GET stexaminer/$textid
23 Renders the application for the text identified by $textid.
29 sub index :Path :Args(1) {
30 my( $self, $c, $textid ) = @_;
31 my $m = $c->model('Directory');
32 my $tradition = $m->tradition( $textid );
33 if( $tradition->stemma_count ) {
34 my $stemma = $tradition->stemma(0);
35 # TODO Think about caching the stemma in a session
36 $c->stash->{svg} = $stemma->as_svg;
37 $c->stash->{text_title} = $tradition->name;
38 $c->stash->{template} = 'stexaminer.tt';
39 # TODO Run the analysis as AJAX from the loaded page.
40 my $t = run_analysis( $tradition );
41 $c->stash->{variants} = $t->{'variants'};
42 $c->stash->{total} = $t->{'variant_count'};
43 $c->stash->{genealogical} = $t->{'genealogical_count'};
44 $c->stash->{conflict} = $t->{'conflict_count'};
46 $c->stash->{error} = 'Tradition ' . $tradition->name
47 . 'has no stemma for analysis.';
53 Attempt to render a view, if needed.
57 sub end : ActionClass('RenderView') {}
65 This library is free software. You can redistribute it and/or modify
66 it under the same terms as Perl itself.
70 __PACKAGE__->meta->make_immutable;