use simpler Directory interface
Tara L Andrews [Sat, 21 Jan 2012 23:44:14 +0000 (00:44 +0100)]
stemmaweb/lib/stemmaweb/Controller/Root.pm

index 16075bd..4b4e5e8 100644 (file)
@@ -50,11 +50,11 @@ sub directory :Local :Args(0) {
     # TODO not used yet, will load user texts later
     my $user = $c->request->param( 'user' ) || 'ALL';
     my @textlist;
-    foreach my $id ( $m->tradition_ids ) {
-       my $t = $m->info( $id );
-       push( @textlist, $t );
-    }
-    
+    $m->scan( sub { 
+       push( @textlist, {
+               'id' => $m->object_to_id( @_ ),
+               'name' => $_[0]->name } ) 
+       } );    
     $c->stash->{texts} = \@textlist;
        $c->stash->{template} = 'directory.tt';
 }
@@ -128,7 +128,9 @@ sub stemma :Local :Args(1) {
                $m->store( $tradition );
        }
        
-       $c->stash->{'result'} = $tradition->stemma->as_svg;
+       $c->stash->{'result'} = $tradition->stemma
+               ? $tradition->stemma->as_svg
+               : '';
        $c->forward('View::SVG');
 }