1 package TreeOfTexts::Controller::Stemmagraph;
3 use namespace::autoclean;
5 use Text::Tradition::Collation;
6 use Text::Tradition::Stemma;
8 BEGIN { extends 'Catalyst::Controller' }
11 # Sets the actions in this controller to be registered with no prefix
12 # so they function identically to actions created in MyApp.pm
14 __PACKAGE__->config(namespace => '');
18 TreeOfTexts::Controller::Root - Root Controller for TreeOfTexts
22 [enter your description here]
26 sub get_graph :Local {
28 # If called interactively, we have params 'display', 'output', 'witnesses'
29 # If called non-interactively, we look at headers and content.
30 # The body is actually a File::Temp object; this is undocumented but
35 if( $c->request->params->{'dot'} ) {
36 # Make a File::Temp object.
37 my $tmpfile = File::Temp->new( UNLINK => 0 );
38 print $tmpfile $c->request->params->{'dot'};
39 $dotfile = $tmpfile->filename;
42 $dotfile = $c->request->body;
46 # Render the dot in the given format.
47 my $collation = Text::Tradition::Collation->new();
48 my $stemma = Text::Tradition::Stemma->new( 'collation' => $collation, 'dot' => $dotfile );
49 unlink( $dotfile ) if $must_unlink;
50 $c->stash->{result} = $stemma->as_svg;
51 $c->forward( "View::SVG" );
56 Standard 404 error page
61 my ( $self, $c ) = @_;
62 $c->response->body( 'Page not found' );
63 $c->response->status(404);
68 Attempt to render a view, if needed.
72 sub end : ActionClass('RenderView') {}
80 This library is free software. You can redistribute it and/or modify
81 it under the same terms as Perl itself.
85 __PACKAGE__->meta->make_immutable;