From: Tara L Andrews Date: Fri, 20 Jan 2012 10:30:03 +0000 (+0100) Subject: start a real index page for traditions X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=cf9626aa522609c7905db938407b8ef41ab8c840;p=scpubgit%2Fstemmatology.git start a real index page for traditions --- diff --git a/lib/Text/Tradition/Directory.pm b/lib/Text/Tradition/Directory.pm index f10fda6..20c3301 100644 --- a/lib/Text/Tradition/Directory.pm +++ b/lib/Text/Tradition/Directory.pm @@ -115,11 +115,11 @@ has +typemap => ( has tradition_index => ( traits => ['Hash'], - isa => 'HashRef[Str]', + isa => 'HashRef[HashRef[Str]]', handles => { add_index => 'set', del_index => 'delete', - name => 'get', + info => 'get', tradition_ids => 'keys', }, default => sub { {} }, @@ -133,7 +133,8 @@ sub BUILD { foreach my $obj ( $stream->items ) { my $uuid = $self->object_to_id( $obj ); if( ref( $obj ) eq 'Text::Tradition' ) { - $self->add_index( $uuid => $obj->name ); + $self->add_index( $uuid => { 'name' => $obj->name, + 'id' => $uuid, 'has_stemma' => $obj->has_stemma } ); } else { warn "Found root object in DB that is not a Text::Tradition"; } @@ -167,7 +168,8 @@ sub save { return; } my $uuid = $self->store( $obj ); - $self->add_index( $uuid => $obj->name ) if $uuid; + $self->add_index( $uuid => { 'name' => $obj->name, + 'id' => $uuid, 'has_stemma' => $obj->has_stemma } ) if $uuid; return $uuid; } diff --git a/stemmaweb/lib/stemmaweb/Controller/Root.pm b/stemmaweb/lib/stemmaweb/Controller/Root.pm index 9d497c8..16075bd 100644 --- a/stemmaweb/lib/stemmaweb/Controller/Root.pm +++ b/stemmaweb/lib/stemmaweb/Controller/Root.pm @@ -51,17 +51,31 @@ sub directory :Local :Args(0) { my $user = $c->request->param( 'user' ) || 'ALL'; my @textlist; foreach my $id ( $m->tradition_ids ) { - my $data = { - 'id' => $id, - 'name' => $m->name( $id ), - }; - push( @textlist, $data ); + my $t = $m->info( $id ); + push( @textlist, $t ); } $c->stash->{texts} = \@textlist; $c->stash->{template} = 'directory.tt'; } +=head2 variantgraph + + GET /variantgraph/$textid + +Returns the variant graph for the text specified at $textid, in SVG form. + +=cut + +sub variantgraph :Local :Args(1) { + my( $self, $c, $textid ) = @_; + my $m = $c->model('Directory'); + my $collation = $m->tradition( $textid )->collation; + + $c->stash->{'result'} = $collation->as_svg; + $c->forward('View::SVG'); +} + =head2 alignment GET /alignment/$textid diff --git a/stemmaweb/root/css/style.css b/stemmaweb/root/css/style.css index 02984af..3a04989 100644 --- a/stemmaweb/root/css/style.css +++ b/stemmaweb/root/css/style.css @@ -1,4 +1,6 @@