my ( $self, $c ) = @_;
my $m = $c->model('Analysis');
- $c->stash->{svg} = $m->{'svg'};
- $c->stash->{variants} = $m->{'variants'};
- $c->stash->{text_title} = $m->{'title'};
- $c->stash->{total} = $m->{'variant_count'};
- $c->stash->{genealogical} = $m->{'genealogical_count'};
- $c->stash->{conflict} = $m->{'conflict_count'};
- $c->stash->{template} = 'index.tt';
+ my $i = 0;
+ my @all_texts = map { $_->{'title'} } @{$m->{'data'}};
+ $c->stash->{texts} = \@all_texts;
+ $c->stash->{template} = 'frontpage.tt';
}
+sub view_text :Local {
+ my( $self, $c ) = @_;
+ my $m = $c->model('Analysis');
+ my $t = $m->{'data'}->[ $c->request->params->{'textid'} ];
+ $c->stash->{svg} = $t->{'svg'};
+ $c->stash->{variants} = $t->{'variants'};
+ $c->stash->{text_title} = $t->{'title'};
+ $c->stash->{total} = $t->{'variant_count'};
+ $c->stash->{genealogical} = $t->{'genealogical_count'};
+ $c->stash->{conflict} = $t->{'conflict_count'};
+ $c->stash->{template} = 'index.tt';
+}
=head2 default
Standard 404 error page
__PACKAGE__->config(
class => 'Text::Tradition::Analysis',
- args => { 'file' => TreeOfTexts->path_to( 't', 'data', 'florilegium.xml' ),
+ args => { 'traditions' => [
+ { 'file' => TreeOfTexts->path_to( 't', 'data', 'florilegium.xml' ),
'stemmadot' => TreeOfTexts->path_to( 't', 'data', 'stemma_a.dot' ) },
+ { 'file' => TreeOfTexts->path_to( 't', 'data', 'heinrichi.xml' ),
+ 'stemmadot' => TreeOfTexts->path_to( 't', 'data', 'stemma_h.dot' ) },
+ { 'file' => TreeOfTexts->path_to( 't', 'data', 'parzival.xml' ),
+ 'stemmadot' => TreeOfTexts->path_to( 't', 'data', 'stemma_p.dot' ) },
+ ] },
);
1;
\ No newline at end of file
--- /dev/null
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+ <head>
+ <META http-equiv="Content-Type" content="text/html; charset=utf-8">
+ <link type="text/css" href="[% c.uri_for('css/cupertino/jquery-ui-1.8.13.custom.css') %]" rel="stylesheet" />
+ [% INCLUDE style.tt2 %]
+ </head>
+ <body>
+ <h1>Stexaminer</h1>
+ <h2>Choose a text to examine</h2>
+ <div id="text_list">
+ <ul>
+[% SET i = 0 -%]
+[% FOREACH t IN texts -%]
+ <li><a href="view_text?textid=[% i %]">[% t %]</a></li>
+[% i = i + 1 -%]
+[% END -%]
+ </table>
+ </div>
+ </body>
+</html>
}
#svg_graph {
float: left;
- width: 450px;
- height: 550px;
+ width: 600pt;
+ height: 550pt;
border-right: 1px #c6dcf1 solid;
}
#variants_table {
my( $class, $args ) = @_;
my $self = {};
bless( $self, $class );
- $self->run_analysis( $args->{'file'}, $args->{'stemmadot'} );
+ $self->{'data'} = [];
+ foreach my $t ( @{$args->{'traditions'}} ) {
+ $self->run_analysis( $t->{'file'}, $t->{'stemmadot'} );
+ }
return $self;
}
# What we will return
my $svg;
my $variants = [];
+ my $data = {};
# Read in the file and stemma
my $tradition = Text::Tradition->new(
'file' => $file,
'linear' => 1,
);
- $self->{'title'} = $tradition->name;
+ $data->{'title'} = $tradition->name;
my $stemma = Text::Tradition::Stemma->new(
'collation' => $tradition->collation,
'dot' => $stemmadot,
);
# We will return the stemma picture
- $svg = $stemma->as_svg;
- ### DIRTY HACK
- $svg =~ s/transform=\"scale\(1 1\)/transform=\"scale\(0.7 0.7\)/;
- $self->{'svg'} = $svg;
+ $svg = $stemma->as_svg( { size => "8,7.5" } );;
+ $data->{'svg'} = $svg;
# We have the collation, so get the alignment table with witnesses in rows.
# Also return the reading objects in the table, rather than just the words.
}
# Populate self with our analysis data.
- $self->{'variants'} = $variants;
- $self->{'variant_count'} = $total;
- $self->{'conflict_count'} = $conflicts;
- $self->{'genealogical_count'} = $genealogical;
+ $data->{'variants'} = $variants;
+ $data->{'variant_count'} = $total;
+ $data->{'conflict_count'} = $conflicts;
+ $data->{'genealogical_count'} = $genealogical;
+ push( @{$self->{'data'}}, $data );
}
# variant_row -> genealogical
# Render the stemma as SVG.
sub as_svg {
- my $self = shift;
+ my( $self, $opts ) = @_;
# TODO add options for display, someday
my $dgraph = Graph::Convert->as_graph_easy( $self->graph );
# Set some class display attributes for 'hypothetical' and 'extant' nodes
}
# Render to svg via graphviz
+ my @lines = split( /\n/, $dgraph->as_graphviz() );
+ # Add the size attribute
+ if( $opts->{'size'} ) {
+ my $sizeline = " graph [ size=\"" . $opts->{'size'} . "\" ]";
+ splice( @lines, 1, 0, $sizeline );
+ }
my @cmd = qw/dot -Tsvg/;
my( $svg, $err );
my $dotfile = File::Temp->new();
## TODO REMOVE
# $dotfile->unlink_on_destroy(0);
binmode $dotfile, ':utf8';
- print $dotfile $dgraph->as_graphviz();
+ print $dotfile join( "\n", @lines );
push( @cmd, $dotfile->filename );
run( \@cmd, ">", binary(), \$svg );
$svg = decode_utf8( $svg );