}
last if $tradition;
}
- } elsif( $ext eq 'txt' || $ext eq 'csv' ) {
- my $sep_char = $ext eq 'txt' ? "\t" : ',';
+ } elsif( $ext eq 'txt' || $ext eq 'csv' || $ext eq 'xls' ) {
+ # If it's Excel we need to pass xls => [true value];
+ # otherwise we need to pass sep_char => [record separator].
+ # Good thing record separators are true values.
+ my $extrafield = $ext eq 'xls' ? 'xls' : 'sep_char';
+ my $extraarg = $ext eq 'txt' ? "\t" : ',';
try {
$tradition = Text::Tradition->new(
%newopts,
'input' => 'Tabular',
- 'sep_char' => $sep_char
+ $extrafield => $extraarg
);
} catch ( Text::Tradition::Error $e ) {
$errmsg = $e->message;
} catch {
$errmsg = "Unexpected parsing error";
}
- } elsif( $ext =~ /^xls(x)?$/ ) {
+ } elsif( $ext eq 'xlsx' ) {
$c->stash->{'result'} =
- { 'error' => "Excel parsing not supported yet" };
+ { 'error' => "Excel XML parsing not supported yet" };
$c->response->status( 500 );
} else {
# Error unless we have a recognized filename extension
if( $user ) {
return 'full' if ( $user->is_admin ||
( $tradition->has_user && $tradition->user->id eq $user->id ) );
- } elsif( $tradition->public ) {
- return 'readonly';
- }
- # else Forbidden!
+ }
+ # 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' );