From b738069dddcb1137a4290afe20f4c3bbd085c9e3 Mon Sep 17 00:00:00 2001 From: martinahansen Date: Sat, 13 Mar 2010 13:45:48 +0000 Subject: [PATCH] added static link to BGB git-svn-id: http://biopieces.googlecode.com/svn/trunk@897 74ccb610-7750-0410-82ae-013aeee3265d --- www/index.cgi | 106 +++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 84 insertions(+), 22 deletions(-) diff --git a/www/index.cgi b/www/index.cgi index aa9842d..ec03bf6 100755 --- a/www/index.cgi +++ b/www/index.cgi @@ -61,7 +61,7 @@ push @html, Maasha::XHTML::form_end; push @html, Maasha::XHTML::body_end; push @html, Maasha::XHTML::html_end; -# push @html, Maasha::XHTML::hdump( [ $cgi->Vars ] ); # DEBUG +# push @html, Maasha::XHTML::hdump( { $cgi->Vars } ); # DEBUG # push @html, Maasha::XHTML::hdump( \%ENV ); # DEBUG # push @html, Maasha::XHTML::hdump( $cookie ); # DEBUG @@ -117,6 +117,16 @@ sub cookie_default cookie_login( $cookie ); $cookie->{ 'PAGE' } ||= $cgi->param( 'page' ) || 'login'; + + if ( $cookie->{ 'LOGIN' } eq 'OK' ) + { + if ( $cgi->param( 'genome' ) ) { + $cookie->{ 'PAGE' } = 'browse'; + } else { + $cookie->{ 'PAGE' } = 'clade'; + } + } + $cookie->{ 'CLADE' } = $cgi->param( 'clade' ) || ''; $cookie->{ 'GENOME' } = $cgi->param( 'genome' ) || ''; $cookie->{ 'ASSEMBLY' } = $cgi->param( 'assembly' ) || ''; @@ -155,18 +165,22 @@ sub cookie_default $cookie->{ 'FEAT_MAX' } = 5000; # TODO: Reduntant? $cookie->{ 'LIST_USER' } = Maasha::BGB::Track::list_users(); - $cookie->{ 'LIST_CLADE' } = Maasha::BGB::Track::list_clades( $cookie->{ 'USER' } ); - $cookie->{ 'LIST_GENOME' } = Maasha::BGB::Track::list_genomes( $cookie->{ 'USER' }, $cookie->{ 'CLADE' } ); - $cookie->{ 'LIST_ASSEMBLY' } = Maasha::BGB::Track::list_assemblies( $cookie->{ 'USER' }, $cookie->{ 'CLADE' }, $cookie->{ 'GENOME' } ); - $cookie->{ 'LIST_CONTIG' } = Maasha::BGB::Track::list_contigs( $cookie->{ 'USER' }, $cookie->{ 'CLADE' }, $cookie->{ 'GENOME' }, $cookie->{ 'ASSEMBLY' } ); - if ( $cookie->{ 'CONTIG' } ) + if ( $cookie->{ 'USER' } ) { - cookie_start( $cookie ); - cookie_end( $cookie ); - cookie_zoom( $cookie ); - cookie_move( $cookie ); - cookie_center( $cookie ); + $cookie->{ 'LIST_CLADE' } = Maasha::BGB::Track::list_clades( $cookie->{ 'USER' } ); + $cookie->{ 'LIST_GENOME' } = Maasha::BGB::Track::list_genomes( $cookie->{ 'USER' }, $cookie->{ 'CLADE' } ); + $cookie->{ 'LIST_ASSEMBLY' } = Maasha::BGB::Track::list_assemblies( $cookie->{ 'USER' }, $cookie->{ 'CLADE' }, $cookie->{ 'GENOME' } ); + $cookie->{ 'LIST_CONTIG' } = Maasha::BGB::Track::list_contigs( $cookie->{ 'USER' }, $cookie->{ 'CLADE' }, $cookie->{ 'GENOME' }, $cookie->{ 'ASSEMBLY' } ); + + if ( $cookie->{ 'CONTIG' } ) + { + cookie_start( $cookie ); + cookie_end( $cookie ); + cookie_zoom( $cookie ); + cookie_move( $cookie ); + cookie_center( $cookie ); + } } $cookie->{ 'STRAND' } = '+' if defined $cookie->{ 'STRAND' } and $cookie->{ 'STRAND' } eq ' '; # FIXME ugly HTML fix @@ -194,29 +208,29 @@ sub cookie_session # { # if ( $cookie->{ 'SESSION_ID' } ne $ENV{ 'SSL_SESSION_ID' } ) { # $cookie->{ 'PAGE' } = 'login'; - # print STDERR "HER1"; # DEBUG + # print STDERR "HER1\n"; # DEBUG # } # } # else # { # $cookie->{ 'PAGE' } = 'login'; # - # print STDERR "HER2"; # DEBUG + # print STDERR "HER2\n"; # DEBUG # } if ( exists $session->{ $cookie->{ 'USER' } } and $cookie->{ 'SESSION_ID' } ) { if ( $session->{ $cookie->{ 'USER' } }->{ 'SESSION_ID' } ne $cookie->{ 'SESSION_ID' } ) { $cookie->{ 'PAGE' } = 'login'; - print STDERR "HER3"; # DEBUG + print STDERR "HER3\n"; # DEBUG } } else { $cookie->{ 'PAGE' } = 'login'; - print STDERR "HER4"; # DEBUG - print STDERR "NO COOKIE SESSION ID\n" if not $cookie->{ 'SESSION_ID' }; # DEBUG - print STDERR "NO COOKIE USER\n" if not $cookie->{ 'USER' }; # DEBUG + print STDERR "HER4\n"; # DEBUG + print STDERR "NO COOKIE SESSION ID\n" if not $cookie->{ 'SESSION_ID' }; # DEBUG + print STDERR "NO COOKIE USER\n" if not $cookie->{ 'USER' }; # DEBUG print STDERR "NO SESSION USER\n" if not exists $session->{ $cookie->{ 'USER' } }; # DEBUG } } @@ -249,7 +263,6 @@ sub cookie_login $cookie->{ 'SESSION_ID' } = $session->{ $cookie->{ 'USER' } }->{ 'SESSION_ID' }; $cookie->{ 'LOGIN' } = "OK"; - $cookie->{ 'PAGE' } = 'clade'; Maasha::BGB::Session::session_store( "$cookie->{ 'SESSION_DIR' }/sessions.txt", $session ); } @@ -548,6 +561,7 @@ sub page_browse push @html, section_taxonomy_table( $cookie ); push @html, section_navigate( $cookie ); push @html, section_browse( $cookie ); + push @html, section_linkout( $cookie ); return wantarray ? @html : \@html; } @@ -641,6 +655,22 @@ sub section_login push @html, Maasha::XHTML::table_row_simple( tr => [ "", $login ] ); push @html, Maasha::XHTML::table_end; + if ( defined $cookie->{ 'CLADE' } and + defined $cookie->{ 'GENOME' } and + defined $cookie->{ 'ASSEMBLY' } and + defined $cookie->{ 'CONTIG' } and + defined $cookie->{ 'NAV_START' } and + defined $cookie->{ 'NAV_END' } + ) + { + push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "clade", value => $cookie->{ 'CLADE' } ) ); + push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "genome", value => $cookie->{ 'GENOME' } ) ); + push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "assembly", value => $cookie->{ 'ASSEMBLY' } ) ); + push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "contig", value => $cookie->{ 'CONTIG' } ) ); + push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "nav_start", value => $cookie->{ 'NAV_START' } ) ); + push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "nav_end", value => $cookie->{ 'NAV_END' } ) ); + } + if ( $cookie->{ 'LOGIN' } and $cookie->{ 'LOGIN' } eq 'ERROR' ) { push @html, Maasha::XHTML::h3( txt => "Bad user or password - please retry", class => 'error' ); } @@ -785,6 +815,38 @@ sub section_navigate } +sub section_linkout +{ + # Martin A. Hansen, March 2010. + + # Returns a HTML section for a static link based on information in the cookie. + + my ( $cookie, # cookie hash + ) = @_; + + # Returns a list. + + my ( $link, @html ); + + $link = Maasha::XHTML::ln( + txt => 'link', + href => join( "&", "$cookie->{ 'SCRIPT' }?page=browse", + "clade=$cookie->{ 'CLADE' }", + "genome=$cookie->{ 'GENOME' }", + "assembly=$cookie->{ 'ASSEMBLY' }", + "contig=$cookie->{ 'CONTIG' }", + "nav_start=$cookie->{ 'NAV_START' }", + "nav_end=$cookie->{ 'NAV_END' }", + ), + title => "Static link to this view", + ); + + push @html, Maasha::XHTML::p( txt => $link, class => 'center' ); + + return wantarray ? @html : \@html; +} + + sub section_browse { my ( $cookie, @@ -847,8 +909,8 @@ sub section_browse "user=$cookie->{ 'USER' }", "clade=$cookie->{ 'CLADE' }", "genome=$cookie->{ 'GENOME' }", - "contig=$cookie->{ 'CONTIG' }", "assembly=$cookie->{ 'ASSEMBLY' }", + "contig=$cookie->{ 'CONTIG' }", "nav_start=$cookie->{ 'NAV_START' }", "nav_end=$cookie->{ 'NAV_END' }", "nav_center=$center", @@ -879,8 +941,8 @@ sub section_browse "user=$cookie->{ 'USER' }", "clade=$cookie->{ 'CLADE' }", "genome=$cookie->{ 'GENOME' }", - "contig=$cookie->{ 'CONTIG' }", "assembly=$cookie->{ 'ASSEMBLY' }", + "contig=$cookie->{ 'CONTIG' }", "s_beg=$cookie->{ 'S_BEG' }", "s_end=$cookie->{ 'S_END' }", "strand=$cookie->{ 'STRAND' }", @@ -984,8 +1046,8 @@ sub section_search "user=$cookie->{ 'USER' }", "clade=$cookie->{ 'CLADE' }", "genome=$cookie->{ 'GENOME' }", - "contig=$cookie->{ 'CONTIG' }", "assembly=$cookie->{ 'ASSEMBLY' }", + "contig=$cookie->{ 'CONTIG' }", "nav_start=$cookie->{ 'NAV_START' }", "nav_end=$cookie->{ 'NAV_END' }", ), @@ -999,8 +1061,8 @@ sub section_search "user=$cookie->{ 'USER' }", "clade=$cookie->{ 'CLADE' }", "genome=$cookie->{ 'GENOME' }", - "contig=$cookie->{ 'CONTIG' }", "assembly=$cookie->{ 'ASSEMBLY' }", + "contig=$cookie->{ 'CONTIG' }", "s_beg=$cookie->{ 'S_BEG' }", "s_end=$cookie->{ 'S_END' }", "strand=$cookie->{ 'STRAND' }", -- 2.39.5