requires 'Catalyst::Plugin::Static::Simple';
requires 'Catalyst::Plugin::Unicode::Encoding';
requires 'Catalyst::Action::RenderView';
-requires 'Catalyst::Model::Adaptor';
+requires 'Catalyst::Model::KiokuDB';
requires 'Moose';
requires 'namespace::autoclean';
requires 'Config::General'; # This should reflect the config file format you've chosen
package TreeOfTexts::Controller::Root;
use Moose;
use namespace::autoclean;
-use TreeOfTexts::Model::Analysis qw/ run_analysis /;
+use Text::Tradition::Analysis qw/ run_analysis /;
+
BEGIN { extends 'Catalyst::Controller' }
sub index :Path :Args(0) {
my ( $self, $c ) = @_;
- my $m = $c->model('Analysis');
- my $i = 0;
- my @all_texts = map { $_->{'title'} } @{$m->{'data'}};
+ my $m = $c->model('Directory');
+ my @all_texts;
+ foreach my $id ( $m->traditions ) {
+ my $data = {
+ 'id' => $id,
+ 'name' => $m->tradition( $id )->name,
+ 'has_stemma' => defined $m->stemma( $id ),
+ };
+ push( @all_texts, $data );
+ }
+
$c->stash->{texts} = \@all_texts;
$c->stash->{template} = 'frontpage.tt';
}
-sub view_text :Local {
+sub relationships :Local {
+ my( $self, $c ) = @_;
+ my $m = $c->model('Directory');
+ my $tradition = $m->tradition( $c->request->params->{'textid'} );
+ $c->stash->{alignment} = $tradition->collation->make_alignment_table( 'refs' );
+ $c->stash->{template} = 'relationships.tt';
+}
+
+sub stexaminer :Local {
my( $self, $c ) = @_;
- my $m = $c->model('Analysis');
- my $t = $m->{'data'}->[ $c->request->params->{'textid'} ];
- $c->stash->{svg} = $t->{'svg'};
+ my $m = $c->model('Directory');
+ my $id = $c->request->params->{'textid'};
+ my $tradition = $m->tradition( $id );
+ my $stemma = $m->stemma( $id );
+ my $t = run_analysis( $tradition, $stemma );
+ $c->stash->{svg} = $stemma->as_svg;
$c->stash->{variants} = $t->{'variants'};
- $c->stash->{text_title} = $t->{'title'};
+ $c->stash->{text_title} = $tradition->name;
$c->stash->{total} = $t->{'variant_count'};
$c->stash->{genealogical} = $t->{'genealogical_count'};
$c->stash->{conflict} = $t->{'conflict_count'};
sub view_table :Local {
my( $self, $c ) = @_;
- my $m = $c->model( 'Analysis' );
- my $t = $m->{'data'}->[ $c->request->params->{'textid'} ];
+ my $m = $c->model('Directory');
+ my $id = $c->request->params->{'textid'};
+ my $t = run_analysis( $m->tradition( $id ), $m->stemma( $id ) );
$c->stash->{variants} = $t->{'variants'};
$c->stash->{template} = 'table_gadget.tt';
}
sub view_svg :Local {
my( $self, $c ) = @_;
- my $m = $c->model( 'Analysis' );
- my $t = $m->{'data'}->[ $c->request->params->{'textid'} ];
- $c->stash->{svg} = $t->{'svg'};
+ my $m = $c->model('Directory');
+ my $stemma = $m->stemma( $c->request->params->{'textid'} );
+ if( $stemma ) {
+ $c->stash->{svg} = $stemma->as_svg;
+ }
$c->stash->{template} = 'stemma_gadget.tt';
}
-
=head2 default
Standard 404 error page
=head1 NAME
-TreeOfTexts::Controller::Root - Root Controller for TreeOfTexts
+TreeOfTexts::Controller::Stemmagraph - Simple controller for stemma display
=head1 DESCRIPTION
# The body is actually a File::Temp object; this is undocumented but
# so it seems to be.
my $dotfile;
- $DB::single = 1;
my $must_unlink = 0;
if( $c->request->params->{'dot'} ) {
# Make a File::Temp object.
+++ /dev/null
-package TreeOfTexts::Model::Analysis;
-
-use strict;
-use warnings;
-
-use base 'Catalyst::Model::Adaptor';
-
-__PACKAGE__->config(
- class => 'Text::Tradition::Analysis',
- 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', 'besoin.xml' ),
- 'stemmadot' => TreeOfTexts->path_to( 't', 'data', 'stemma_b.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' ) },
- { 'file' => TreeOfTexts->path_to( 't', 'data', 's158.xml' ),
- 'stemmadot' => TreeOfTexts->path_to( 't', 'data', 'stemma_s.dot' ) },
- ] },
- );
-
-1;
--- /dev/null
+package TreeOfTexts::Model::Directory;
+use strict;
+use warnings;
+use Moose;
+use Text::Tradition::Directory;
+
+extends 'Catalyst::Model::KiokuDB';
+
+has '+model_class' => ( default => 'Text::Tradition::Directory' );
+
+1;
<ul>
[% SET i = 0 -%]
[% FOREACH t IN texts -%]
- <li><a href="view_text?textid=[% i %]">[% t %]</a></li>
+ <li>[% t.name %] | <a href="relationships?textid=[% t.id %]">Relationship mapper</a>
+[% IF t.has_stemma -%]
+ | <a href="stexaminer?textid=[% t.id %]">Stexaminer</a>
+[% END -%]</li>
[% i = i + 1 -%]
[% END -%]
</table>
[% END -%]
</tr>
[% END -%]
-
+ <h1>Stexaminer</h1>
<h2>[% text_title %]</h2>
<div id="statistics">
<p>Analyzed [% total %] variant locations, of which [% genealogical %] entirely followed the stemma. [% conflict %] readings conflicted with the stemma.</p>
<link type="text/css" href="[% c.uri_for('css/cupertino/jquery-ui-1.8.13.custom.css') %]" rel="stylesheet" />
<link type="text/css" href="[% c.uri_for('css/style.css') %]" rel="stylesheet" />
[% INCLUDE js %]
- <title>Stexaminer</title>
+ <title>Text tradition tools</title>
</head>
<body>
- <h1>Stexaminer</h1>
[% content %]
</body>
</html>
--- /dev/null
+use strict;
+use warnings;
+use Test::More;
+
+
+BEGIN { use_ok 'TreeOfTexts::Model::Directory' }
+
+done_testing();
# rename this file to treeoftexts.yml and put a ':' after 'name' if
# you want to use YAML like in old versions of Catalyst
-name TreeOfTexts
+name = TreeOfTexts
+<Model Directory>
+ dsn dbi:SQLite:dbname=db/traditions.db
+</Model>
\ No newline at end of file
use vars qw/ @EXPORT_OK /;
@EXPORT_OK = qw/ run_analysis group_variants wit_stringify /;
-sub new {
- my( $class, $args ) = @_;
- my $self = {};
- bless( $self, $class );
- $self->{'data'} = [];
- foreach my $t ( @{$args->{'traditions'}} ) {
- $self->run_analysis( $t->{'file'}, $t->{'stemmadot'} );
- }
- return $self;
-}
-
sub run_analysis {
- my( $self, $file, $stemmadot ) = @_;
+ my( $tradition, $stemma ) = @_;
# What we will return
- my $svg;
my $variants = [];
my $data = {};
-
- # Read in the file and stemma
- my $tradition = Text::Tradition->new(
- 'input' => 'Self',
- 'file' => $file,
- 'linear' => 1,
- );
- $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( { 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.
my $wits = {};
$row->{'empty'} = $empty;
}
- # Populate self with our analysis data.
$data->{'variants'} = $variants;
$data->{'variant_count'} = $total;
$data->{'conflict_count'} = $conflicts;
$data->{'genealogical_count'} = $genealogical;
- push( @{$self->{'data'}}, $data );
+ return $data;
}
sub group_variants {
}
}
}
-
- return $self;
}
1;