X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2Fstemmaweb%2FController%2FStexaminer.pm;h=264cef1dcdcbd70c178f2a3c5713984663b4cd1c;hb=dcd9e2a9fa590804ee1b3969faf9165fae2fcfdc;hp=86020a1530a25482db1e8a989d1f5cf535790b33;hpb=080f8a02e4af4c545e8ecff2166931e31b687683;p=scpubgit%2Fstemmaweb.git diff --git a/lib/stemmaweb/Controller/Stexaminer.pm b/lib/stemmaweb/Controller/Stexaminer.pm index 86020a1..264cef1 100644 --- a/lib/stemmaweb/Controller/Stexaminer.pm +++ b/lib/stemmaweb/Controller/Stexaminer.pm @@ -5,7 +5,6 @@ use Encode qw/ decode_utf8 /; use File::Temp; use JSON; use Text::Tradition::Analysis qw/ run_analysis wit_stringify /; -use Text::Tradition::Collation; use Text::Tradition::Stemma; BEGIN { extends 'Catalyst::Controller' } @@ -37,9 +36,10 @@ sub index :Path :Args(2) { my $ok = _check_permission( $c, $tradition ); return unless $ok; if( $tradition->stemma_count ) { - my $stemma = $tradition->stemma(0); + my $stemma = $tradition->stemma( $stemid ); $c->stash->{svg} = $stemma->as_svg( { size => [ 600, 350 ] } ); $c->stash->{graphdot} = $stemma->editable({ linesep => ' ' }); + $c->stash->{text_id} = $textid; $c->stash->{text_title} = $tradition->name; $c->stash->{template} = 'stexaminer.tt'; @@ -101,19 +101,16 @@ sub _check_permission { my( $c, $tradition ) = @_; my $user = $c->user_exists ? $c->user->get_object : undef; if( $user ) { - $c->stash->{'permission'} = 'full' - if( $user->is_admin || $tradition->user->id eq $user->id ); - return 1; - } - # Is it public? - if( $tradition->public ) { - $c->stash->{'permission'} = 'readonly'; - return 1; - } - # Forbidden! + return 'full' if ( $user->is_admin || + ( $tradition->has_user && $tradition->user->id eq $user->id ) ); + } + # Text doesn't belong to us, so maybe it's public? + return 'readonly' if $tradition->public; + + # ...nope. Forbidden! $c->response->status( 403 ); - $c->response->body( 'You do not have permission to view this tradition.' ); - $c->detach( 'View::Plain' ); + $c->response->body( 'You do not have permission to view this tradition' ); + $c->forward('View::Plain'); return 0; } @@ -134,9 +131,7 @@ sub graphsvg :Local { my @layerwits = $c->request->param('layerwits[]'); open my $stemma_fh, '<', \$dot; binmode( $stemma_fh, ':encoding(UTF-8)' ); - my $emptycoll = Text::Tradition::Collation->new(); - my $tempstemma = Text::Tradition::Stemma->new( - collation => $emptycoll, 'dot' => $stemma_fh ); + my $tempstemma = Text::Tradition::Stemma->new( 'dot' => $stemma_fh ); my $svgopts = { size => [ 600, 350 ] }; if( @layerwits ) { $svgopts->{'layerwits'} = \@layerwits;