From 08db04847b5a5ac701bae404337346f3f09ae3a5 Mon Sep 17 00:00:00 2001 From: martinahansen Date: Tue, 2 Mar 2010 11:35:32 +0000 Subject: [PATCH] BGB cleanup of hrefs git-svn-id: http://biopieces.googlecode.com/svn/trunk@881 74ccb610-7750-0410-82ae-013aeee3265d --- www/index.cgi | 156 ++++++++++++++++++++++++-------------------------- 1 file changed, 76 insertions(+), 80 deletions(-) diff --git a/www/index.cgi b/www/index.cgi index 81d133c..fb04e32 100755 --- a/www/index.cgi +++ b/www/index.cgi @@ -447,56 +447,6 @@ sub cookie_center } -sub cookie_href -{ - # Martin A. Hansen, November 2009. - - # Returns the href for a taxonomy path terminated at a given - # page using information stored in a cookie. - - my ( $cookie, # cookie hash - $page, # page - ) = @_; - - # Returns a string. - - my ( @href_list, %href_hash, $href ); - - $href_hash{ "user" } = $cookie->{ 'USER' } if $cookie->{ 'USER' }; - - while ( 1 ) - { - $href_hash{ "clade" } = $cookie->{ 'CLADE' } if $cookie->{ 'CLADE' }; - last if $page eq 'clade'; - $href_hash{ "genome" } = $cookie->{ 'GENOME' } if $cookie->{ 'GENOME' }; - last if $page eq 'genome'; - $href_hash{ "assembly" } = $cookie->{ 'ASSEMBLY' } if $cookie->{ 'ASSEMBLY' }; - last if $page eq 'assembly'; - $href_hash{ "contig" } = $cookie->{ 'CONTIG' } if $cookie->{ 'CONTIG' }; - last if $page eq 'contig'; - last; - } - - if ( defined $cookie->{ 'NAV_START' } and defined $cookie->{ 'NAV_END' } and $page !~ /clade|genome|assembly|contig|browse/ ) { - $href_hash{ "nav_search" } = "$cookie->{ 'NAV_START' }-$cookie->{ 'NAV_END' }"; - } - - $href_hash{ "q_id" } = URI::Escape::uri_escape( $cookie->{ 'Q_ID' } ) if defined $cookie->{ 'Q_ID' }; - $href_hash{ "s_beg" } = $cookie->{ 'S_BEG' } if defined $cookie->{ 'S_BEG' }; - $href_hash{ "s_end" } = $cookie->{ 'S_END' } if defined $cookie->{ 'S_END' }; - $href_hash{ "strand" } = $cookie->{ 'STRAND' } if defined $cookie->{ 'STRAND' }; - $href_hash{ "session_id" } = $cookie->{ 'SESSION_ID' } if defined $cookie->{ 'SESSION_ID' }; - - push @href_list, "$cookie->{ 'SCRIPT' }?page=$page"; - - foreach $href ( keys %href_hash ) { - push @href_list, "$href=$href_hash{ $href }"; - } - - return join "&", @href_list; -} - - sub cookie_page_next { # Martin A. Hansen, November 2009. @@ -732,7 +682,13 @@ sub section_taxonomy_table { last if $page eq $cookie->{ 'PAGE' } or $page eq 'browse'; - $href = cookie_href( $cookie, $page ); + $href = "$cookie->{ 'SCRIPT' }?page=$page"; + $href .= "&session_id=$cookie->{ 'SESSION_ID' }"; + $href .= "&user=$cookie->{ 'USER' }"; + $href .= "&clade=$cookie->{ 'CLADE' }" if $page !~ /clade/; + $href .= "&genome=$cookie->{ 'GENOME' }" if $page !~ /clade|genome/; + $href .= "&assembly=$cookie->{ 'ASSEMBLY' }" if $page !~ /clade|genome|assembly/; + $href .= "&contig=$cookie->{ 'CONTIG' }" if $page !~ /clade|genome|assembly|contig/; $txt = ": $cookie->{ uc $page }"; @@ -772,7 +728,13 @@ sub section_taxonomy_select { $cookie->{ uc $cookie->{ 'PAGE' } } = $item; - $href = cookie_href( $cookie, cookie_page_next( $cookie ) ); + $href = "$cookie->{ 'SCRIPT' }?page=" . cookie_page_next( $cookie ); + $href .= "&session_id=$cookie->{ 'SESSION_ID' }"; + $href .= "&user=$cookie->{ 'USER' }"; + $href .= "&clade=$cookie->{ 'CLADE' }"; + $href .= "&genome=$cookie->{ 'GENOME' }" if $cookie->{ 'GENOME' }; + $href .= "&assembly=$cookie->{ 'ASSEMBLY' }" if $cookie->{ 'ASSEMBLY' }; + $href .= "&contig=$cookie->{ 'CONTIG' }" if $cookie->{ 'CONTIG' }; push @html, Maasha::XHTML::table_row_simple( tr => [ Maasha::XHTML::ln( txt => $item, href => $href ) ] ); } @@ -882,31 +844,6 @@ sub section_browse push @img, Maasha::XHTML::map_beg( name => "browser_map", id => "browser_map" ); - foreach $feat ( @features ) - { - foreach $elem ( @{ $feat } ) - { - next if $elem->{ 'type' } eq 'text'; - next if $elem->{ 'type' } eq 'wiggle'; - - #$elem->{ 'strand' } = '+' if $elem->{ 'strand' } eq '+'; - - $cookie->{ 'Q_ID' } = $elem->{ 'q_id' }; - $cookie->{ 'S_BEG' } = $elem->{ 's_beg' }; - $cookie->{ 'S_END' } = $elem->{ 's_end' }; - $cookie->{ 'STRAND' } = $elem->{ 'strand' }; - - push @img, Maasha::XHTML::area( - href => cookie_href( $cookie, "export" ), - # href => cookie_href( $cookie, "export" ) . "&q_id=$elem->{ 'q_id' }&s_beg=$elem->{ 's_beg' }&s_end=$elem->{ 's_end' }&strand=$elem->{ 'strand' }", - shape => 'rect', - coords => "$elem->{ x1 }, $elem->{ y1 }, $elem->{ x2 }, $elem->{ y2 }", - title => "$elem->{ 'title' }", - ); - } - } - - $factor = $cookie->{ 'IMG_WIDTH' } / ( $cookie->{ 'NAV_END' } - $cookie->{ 'NAV_START' } + 1 ); $factor = ( $cookie->{ 'NAV_END' } - $cookie->{ 'NAV_START' } + 1 ) / $cookie->{ 'IMG_WIDTH' }; for ( $i = 0; $i < $cookie->{ 'IMG_WIDTH' }; $i += 5 ) @@ -919,7 +856,6 @@ sub section_browse $center = int( $cookie->{ 'NAV_START' } + $factor * $i ); push @img, Maasha::XHTML::area( - # href => cookie_href( $cookie, "browse" ) . "&nav_start=$cookie->{ 'NAV_START' }&nav_end=$cookie->{ 'NAV_END' }&nav_center=$center", href => join( "&", "$cookie->{ 'SCRIPT' }?page=browse", "session_id=$cookie->{ 'SESSION_ID' }", "user=$cookie->{ 'USER' }", @@ -937,6 +873,39 @@ sub section_browse ); } + foreach $feat ( @features ) + { + foreach $elem ( @{ $feat } ) + { + next if $elem->{ 'type' } eq 'text'; + next if $elem->{ 'type' } eq 'wiggle'; + + #$elem->{ 'strand' } = '+' if $elem->{ 'strand' } eq '+'; + + $cookie->{ 'Q_ID' } = $elem->{ 'q_id' }; + $cookie->{ 'S_BEG' } = $elem->{ 's_beg' }; + $cookie->{ 'S_END' } = $elem->{ 's_end' }; + $cookie->{ 'STRAND' } = $elem->{ 'strand' }; + + push @img, Maasha::XHTML::area( + href => join( "&", "$cookie->{ 'SCRIPT' }?page=export", + "session_id=$cookie->{ 'SESSION_ID' }", + "user=$cookie->{ 'USER' }", + "clade=$cookie->{ 'CLADE' }", + "genome=$cookie->{ 'GENOME' }", + "contig=$cookie->{ 'CONTIG' }", + "assembly=$cookie->{ 'ASSEMBLY' }", + "s_beg=$cookie->{ 'S_BEG' }", + "s_end=$cookie->{ 'S_END' }", + "strand=$cookie->{ 'STRAND' }", + ), + shape => 'rect', + coords => "$elem->{ x1 }, $elem->{ y1 }, $elem->{ x2 }, $elem->{ y2 }", + title => "$elem->{ 'title' }", + ); + } + } + push @img, Maasha::XHTML::map_end(); push @html, Maasha::XHTML::p( txt => join( "\n", @img ) ); @@ -1022,8 +991,35 @@ sub section_search $cookie->{ 'STRAND' } = $result->{ 'STRAND' }; $cookie->{ 'Q_ID' } = $result->{ 'Q_ID' }; - $browse = Maasha::XHTML::ln( txt => "browse", href => cookie_href( $cookie, "browse" ) ); - $export = Maasha::XHTML::ln( txt => "export", href => cookie_href( $cookie, "export" ) ); + $browse = Maasha::XHTML::ln( + txt => "browse", + href => join( "&", "$cookie->{ 'SCRIPT' }?page=browse", + "session_id=$cookie->{ 'SESSION_ID' }", + "user=$cookie->{ 'USER' }", + "clade=$cookie->{ 'CLADE' }", + "genome=$cookie->{ 'GENOME' }", + "contig=$cookie->{ 'CONTIG' }", + "assembly=$cookie->{ 'ASSEMBLY' }", + "nav_start=$cookie->{ 'NAV_START' }", + "nav_end=$cookie->{ 'NAV_END' }", + ), + ); + + + $export = Maasha::XHTML::ln( + txt => "export", + href => join( "&", "$cookie->{ 'SCRIPT' }?page=export", + "session_id=$cookie->{ 'SESSION_ID' }", + "user=$cookie->{ 'USER' }", + "clade=$cookie->{ 'CLADE' }", + "genome=$cookie->{ 'GENOME' }", + "contig=$cookie->{ 'CONTIG' }", + "assembly=$cookie->{ 'ASSEMBLY' }", + "s_beg=$cookie->{ 'S_BEG' }", + "s_end=$cookie->{ 'S_END' }", + "strand=$cookie->{ 'STRAND' }", + ), + ); push @html, Maasha::XHTML::table_row_advanced( tr => [ { td => $result->{ 'S_ID' } }, -- 2.39.5