From: Tara L Andrews Date: Wed, 8 Aug 2012 20:47:47 +0000 (+0200) Subject: let stemmaweb use interim analysis database X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ee53ab0d303f5aad58babaefde47a8e006906694;p=scpubgit%2Fstemmatology.git let stemmaweb use interim analysis database --- diff --git a/stemmaweb/lib/stemmaweb/Controller/Stexaminer.pm b/stemmaweb/lib/stemmaweb/Controller/Stexaminer.pm index 4b8bff6..3c8b7bd 100644 --- a/stemmaweb/lib/stemmaweb/Controller/Stexaminer.pm +++ b/stemmaweb/lib/stemmaweb/Controller/Stexaminer.pm @@ -32,6 +32,7 @@ Renders the application for the text identified by $textid. sub index :Path :Args(1) { my( $self, $c, $textid ) = @_; my $m = $c->model('Directory'); + my $am = $c->model('Analysis'); my $tradition = $m->tradition( $textid ); if( $tradition->stemma_count ) { my $stemma = $tradition->stemma(0); @@ -49,7 +50,7 @@ sub index :Path :Args(1) { $c->stash->{'show_type1'} = $use_type1; $c->stash->{'ignore_variant'} = $ignore_sort; # TODO Run the analysis as AJAX from the loaded page. - my %analysis_options; + my %analysis_options = ( calcdir => $am ); $analysis_options{'exclude_type1'} = !$use_type1; if( $ignore_sort eq 'spelling' ) { $analysis_options{'merge_types'} = [ qw/ spelling orthographic / ]; @@ -65,8 +66,8 @@ sub index :Path :Args(1) { foreach my $rhash ( @{$loc->{'readings'}} ) { my $gst = wit_stringify( $rhash->{'group'} ); $rhash->{'group'} = $gst; - my $roots = join( ', ', @{$rhash->{'independent_occurrence'}} ); - $rhash->{'independent_occurrence'} = $roots; + _stringify_element( $rhash, 'independent_occurrence' ); + _stringify_element( $rhash, 'reversions' ); unless( $rhash->{'text'} ) { $rhash->{'text'} = $rhash->{'readingid'}; } @@ -85,6 +86,12 @@ sub index :Path :Args(1) { } } +sub _stringify_element { + my( $hash, $key ) = @_; + my $str = join( ', ', @{$hash->{$key}} ); + $hash->{$key} = $str; +} + =head2 graphsvg POST stexaminer/graphsvg diff --git a/stemmaweb/lib/stemmaweb/Model/Analysis.pm b/stemmaweb/lib/stemmaweb/Model/Analysis.pm new file mode 100644 index 0000000..75e6732 --- /dev/null +++ b/stemmaweb/lib/stemmaweb/Model/Analysis.pm @@ -0,0 +1,11 @@ +package stemmaweb::Model::Analysis; +use strict; +use warnings; +use Moose; +use Text::Tradition::Directory; + +extends 'Catalyst::Model::KiokuDB'; + +has '+model_class' => ( default => 'Text::Tradition::Directory' ); + +1; diff --git a/stemmaweb/root/css/stexaminer.css b/stemmaweb/root/css/stexaminer.css index 703dfc1..a30416a 100644 --- a/stemmaweb/root/css/stexaminer.css +++ b/stemmaweb/root/css/stexaminer.css @@ -41,7 +41,7 @@ .readinglabel { font-weight: bold; } -.readingroots { +.readingroots .reversionroots { font-weight: bold; color: #488dd2; } @@ -63,6 +63,9 @@ .conflict { background: #ff6666; } +.reversion { + background: #ffd700; +} .active_variant_row { background: #c6dcf1; font-style: italic; diff --git a/stemmaweb/root/js/stexaminer.js b/stemmaweb/root/js/stexaminer.js index 7469615..b68c3c2 100644 --- a/stemmaweb/root/js/stexaminer.js +++ b/stemmaweb/root/js/stexaminer.js @@ -69,29 +69,45 @@ function show_stats( rs ) { rdgstats.find('.reading_changed').append( rdghash.not_followed ); rdgstats.find('.reading_unclear').append( rdghash.follow_unknown ); rdgstats.find('.readingroots').append( rdghash.independent_occurrence ); - if( ! $.isEmptyObject( rdghash.reading_parents ) ) { - var parentstats = $('#reading_parent_template').clone(); - $.each( rdghash.reading_parents, function( parentid, pdata ) { - var parentdesc = pdata.label; - if( pdata.relation ) { - parentdesc += ' - variant type ' + pdata.relation.type; - if( pdata.relation.annotation ) { - parentdesc += ' [ ' + pdata.relation.annotation + ' ]'; - } - } else { - parentdesc += ' - no syntactic relation'; - } - var parentitem = $('
  • ').append( parentdesc ); - parentstats.find('.reading_parent_list').append( parentitem ); - }); - rdgstats.find('.reading_statistics').append( parentstats.contents() ); + if( rdghash.is_reverted ) { + rdgstats.find('.reversionroots').append( rdghash.reversions ); + } else { + rdgstats.find('.readingreversions').empty(); } + rdgstats.find('.reading_statistics').append( + fill_parent_template( rdghash, 'source' ) ); + rdgstats.find('.reading_statistics').append( + fill_parent_template( rdghash, 'reversion' ) ); rshtml.append( rdgstats.contents() ); }); $('#row_statistics').empty(); $('#row_statistics').append( rshtml.contents() ); + }; +function fill_parent_template( rdghash, type ) { + var objname = type + '_parents'; + var template_id = '#reading_' + type + '_template'; + var list_class = '.reading_' + type + '_list'; + if( ! $.isEmptyObject( rdghash[objname] ) ) { + var parentstats = $( template_id ).clone(); + $.each( rdghash[objname], function( parentid, pdata ) { + var parentdesc = pdata.label; + if( pdata.relation ) { + parentdesc += ' - variant type ' + pdata.relation.type; + if( pdata.relation.annotation ) { + parentdesc += ' [ ' + pdata.relation.annotation + ' ]'; + } + } else { + parentdesc += ' - no syntactic relation'; + } + var parentitem = $('
  • ').append( parentdesc ); + parentstats.find( list_class ).append( parentitem ); + }); + return( parentstats.contents() ); + } +} + // Save the original unextended SVG for when we need it. $(document).ready(function () { original_svg = $('#stemma_graph > svg').clone(); diff --git a/stemmaweb/root/src/stexaminer.tt b/stemmaweb/root/src/stexaminer.tt index 63505f7..d122ca0 100644 --- a/stemmaweb/root/src/stexaminer.tt +++ b/stemmaweb/root/src/stexaminer.tt @@ -48,14 +48,22 @@ var graphdot = '[% graphdot %]';
    - copied time(s), changed time(s)
    Reading root(s) at
    - + Reading reversion(s) at
    + +
    -
    +
    Reading parent(s): -
      +
        +
        +
        +
        +
        + Reverted reading parent(s): +
          @@ -77,17 +85,15 @@ var graphdot = '[% graphdot %]'; [% BLOCK variantrow -%] +[% SET rowclass = 'class="coincidental"' -%] [% SET rowclass = 'class="genealogical"' IF row.genealogical -%] -[% SET rowclass = 'class="coincidental"' UNLESS row.genealogical -%] [% row.id %] [% FOREACH reading IN row.readings -%] -[% SET cellclass = 'clickable conflict' IF reading.conflict -%] -[% SET cellclass = 'clickable' IF !reading.conflict -%] +[% SET cellclass = 'clickable' -%] +[% SET cellclass = 'clickable reversion' IF reading.is_reverted -%] +[% SET cellclass = 'clickable conflict' IF reading.is_conflict -%] [% reading.text %] [% END -%] -[% FILTER repeat( row.empty ) -%] - -[% END -%] [% END -%] diff --git a/stemmaweb/stemmaweb.conf b/stemmaweb/stemmaweb.conf index a0169dc..7983257 100644 --- a/stemmaweb/stemmaweb.conf +++ b/stemmaweb/stemmaweb.conf @@ -1,6 +1,9 @@ # rename this file to stemmaweb.yml and put a ':' after 'name' if # you want to use YAML like in old versions of Catalyst name = stemmaweb + + dsn dbi:SQLite:dbname=db/analysis.db + dsn dbi:SQLite:dbname=db/traditions.db