X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2Fstemmaweb%2FController%2FRoot.pm;h=c77212269e40a148818483be1b5a78138e96476a;hb=8e26de0f2079f2b952536a2be1af1ba159eba5c5;hp=8fa2489ffc01d9b94e5b6c085a90d0e02aea5250;hpb=f60227e23c6222e1ddcc9755845bb7f803616574;p=scpubgit%2Fstemmaweb.git diff --git a/lib/stemmaweb/Controller/Root.pm b/lib/stemmaweb/Controller/Root.pm index 8fa2489..c772122 100644 --- a/lib/stemmaweb/Controller/Root.pm +++ b/lib/stemmaweb/Controller/Root.pm @@ -396,21 +396,6 @@ sub stemma :Local :Args(2) { if( $c->req->method eq 'POST' ) { if( $ok eq 'full' ) { my $dot = $c->request->body_params->{'dot'}; - # Graph::Reader::Dot does not handle bare unicode. We get around this - # by wrapping all words in double quotes, as long as they aren't already - # wrapped, and as long as they aren't the initial '(di)?graph .*'. - # Horrible HACK. - my @dlines = split( "\n", $dot ); - my $wdot = ''; - foreach( @dlines ) { - unless( /^(di)?graph/ ) { # Skip the first line - s/(?model('Directory')->tradition( $textid ); unless( $tradition ) { return _json_error( $c, 404, "No tradition with ID $textid" ); } my $ok = _check_permission( $c, $tradition ); return unless $ok; + + my $outmethod = "as_" . lc( $format ); + 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->as_graphml(); + $c->stash->{'result'} = $tradition->collation->$outmethod( @outputargs ); } catch( Text::Tradition::Error $e ) { return _json_error( $c, 500, $e->message ); } - $c->forward('View::GraphML'); + $c->forward( $view ); } ####################