From: Tara L Andrews Date: Fri, 14 Sep 2012 22:51:40 +0000 (+0200) Subject: get relationship mapper to work even without morphology extension X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=scpubgit%2Fstemmaweb.git;a=commitdiff_plain;h=2be76d3f155342740db9bf4653059c0cb119c2e6 get relationship mapper to work even without morphology extension --- diff --git a/lib/stemmaweb/Controller/Relation.pm b/lib/stemmaweb/Controller/Relation.pm index 043a52f..89a7d23 100644 --- a/lib/stemmaweb/Controller/Relation.pm +++ b/lib/stemmaweb/Controller/Relation.pm @@ -264,9 +264,9 @@ sub _reading_struct { # Return a JSONable struct of the useful keys. Keys meant to be writable # have a true value; read-only keys have a false value. my $struct = {}; - map { $struct->{$_} = $reading->$_ } keys( %read_write_keys ); + map { $struct->{$_} = $reading->$_ if $reading->can( $_ ) } keys( %read_write_keys ); # Special case - $struct->{'lexemes'} = [ $reading->lexemes ]; + $struct->{'lexemes'} = $reading->can( 'lexemes' ) ? [ $reading->lexemes ] : []; # Look up any words related via spelling or orthography my $sameword = sub { my $t = $_[0]->type; diff --git a/root/js/relationship-full.js b/root/js/relationship-full.js index 3ca852c..b5a9f14 100644 --- a/root/js/relationship-full.js +++ b/root/js/relationship-full.js @@ -5,10 +5,6 @@ var start_element_height = 0; var reltypes = {}; var readingdata = {}; -function getRelativePath() { - return basepath; -} - function getTextURL( which ) { return basepath + textid + '/' + which; } @@ -200,7 +196,6 @@ function svgEnlargementLoaded() { } function add_relations( callback_fn ) { - var basepath = getRelativePath(); var textrelpath = getTextURL( 'relationships' ); $.getJSON( basepath + 'definitions', function(data) { var rel_types = data.types.sort(); @@ -657,8 +652,7 @@ $(document).ready(function () { create: function(event, ui) { $(this).data( 'relation_drawn', false ); //TODO? Err handling? - var basepath = getRelativePath(); - var jqjson = $.getJSON( basepath + '/definitions', function(data) { + var jqjson = $.getJSON( basepath + 'definitions', function(data) { var types = data.types.sort(); $.each( types, function(index, value) { $('#rel_type').append( $('