bugfix for returning edited stemma
[scpubgit/stemmaweb.git] / lib / stemmaweb / Controller / Root.pm
index 29e1414..7159680 100644 (file)
@@ -317,6 +317,10 @@ sub textinfo :Local :Args(1) {
                public => $tradition->public || 0,
                owner => $tradition->user ? $tradition->user->email : undef,
                witnesses => [ map { $_->sigil } $tradition->witnesses ],
+               # TODO Send them all with appropriate parameters so that the
+               # client side can choose what to display.
+               reltypes => [ map { $_->name } grep { !$_->is_weak && $_->is_colocation }
+                       $tradition->collation->relationship_types ]
        };
        ## TODO Make these into callbacks in the other controllers maybe?
        if( $tradition->can('language') ) {
@@ -445,7 +449,7 @@ sub stemma :Local :Args(2) {
                $c->stash->{'result'} = $stemma->as_svg();
                $c->forward('View::SVG');
        } else { # JSON
-               $c->stash->{'result'} = { _stemma_info( $stemma, $stemmaid ) };
+               $c->stash->{'result'} = _stemma_info( $stemma, $stemmaid );
                $c->forward('View::JSON');
        }
 }
@@ -532,8 +536,16 @@ sub download :Local :Args(2) {
        my $view = "View::$format";
        $c->stash->{'name'} = $tradition->name();
        $c->stash->{'download'} = 1;
+       my @outputargs;
+       if( $format eq 'SVG' ) {
+               # Send the list of colors through to the backend.
+               # TODO Think of some way not to hard-code this.
+               push( @outputargs, { 'show_relations' => 'all',
+                       'graphcolors' => [ "#5CCCCC", "#67E667", "#F9FE72", "#6B90D4", 
+                               "#FF7673", "#E467B3", "#AA67D5", "#8370D8", "#FFC173" ] } );
+       }
        try {
-               $c->stash->{'result'} = $tradition->collation->$outmethod();
+               $c->stash->{'result'} = $tradition->collation->$outmethod( @outputargs );
        } catch( Text::Tradition::Error $e ) {
                return _json_error( $c, 500, $e->message );
        }