[Bio] / FigWebServices / start.cgi Repository:
ViewVC logotype

View of /FigWebServices/start.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (download) (annotate)
Mon Aug 8 21:54:39 2005 UTC (14 years, 10 months ago) by olson
Branch: MAIN
More diagram changes.

Add new simple start page.

#
# New-style front end.
#
# User login
# Dropdown for subsystems.
# Dropdown for orgs.
# Text search 
# Pattern search.
#

use FIG;
use HTML;
use CGI;
use URI::Escape;

my $cgi = new CGI;
my $fig = new FIG;

my $html = [];

my $user = $cgi->param('user');

my $click_js = <<'EJS';
<script language="JavaScript">

haveClickedSearch = 0;

function check_first_search_click(what)
{
    if (!haveClickedSearch)
    {
	what.value = '';
	haveClickedSearch = 1;
    }
}
</script>
EJS
    
push(@$html, $cgi->start_head,
     $cgi->title("Wecome to the SEED"),
     $click_js,
     q(<body onload="document.search_form.search_string.focus(); document.search_form.search_string.value = 'Enter search terms'">));

push(@$html, $cgi->hidden("user"));

#
# Command handlers
#
handle_action('view_subsystem', \&do_view_subsystem, $cgi, $html);
handle_action('view_genome', \&do_view_genome, $cgi, $html);
handle_action('text_search', \&do_text_search, $cgi, $html);
handle_action('go_old', \&do_go_old_seed, $cgi, $html);


push(@$html, $cgi->start_form(-name => "search_form"));

gen_user_login($cgi, $html);

gen_text_search($cgi, $html);
push(@$html, $cgi->p);

gen_orglist_dropdown($cgi, $html);
push(@$html, $cgi->p);
gen_subsystem_dropdown($cgi, $html);

push(@$html,
     $cgi->p,
     $cgi->submit(-name => 'go_old',
		  -value => 'Advanced SEED entrypoint'),
     $cgi->p,
		  $cgi->a({href => "Html/help_front_page.html"}, "Help")
     );



push(@$html, $cgi->end_form());

my @hdr = &HTML::compute_html_header(undef, undef, no_fig_search => 1 );

push(@$html, $cgi->end_body);
open(T, ">/tmp/t.html");
print T join("", @$html);
close(T);

&HTML::show_page($cgi, $html, 1, \@hdr);

exit(0);

sub gen_user_login
{
    my($cgi, $html) = @_;

    push(@$html, $cgi->p("User id:",
		  $cgi->textfield(-name => 'user',
				  -default => ""),
		  " (of the form JohnDoe - <b>no spaces or special characters</b>)",
			 
		  $cgi->p,
		  ));
	 
	 
	 
}

sub gen_subsystem_dropdown
{
    my($cgi, $html) = @_;

#    push(@$html, $cgi->h2("Subsystems"));

    my @values = sort $fig->all_subsystems();

    my %labels;
    for my $v (@values)
    {
	my $l = $v;
	$l =~ s/_/ /g;
	$labels{$v} = $l;
    }

    $labels{_choose_sub} = "Pick a subsystem";
    unshift(@values, "_choose_sub");
    
    push (@$html,
	  $cgi->popup_menu(-name => 'sel_subsystem',
			   -style => "width: 4in",
			   -values => \@values,
			   -labels => \%labels),,
	  "&nbsp;",
	  $cgi->submit(-name => 'view_subsystem',
		       -value => "Go"),
	 );
	  
		   
}

sub gen_orglist_dropdown
{
    my($cgi, $html) = @_;

#    push(@$html, $cgi->h2("Metabolic Reconstructions"));
    
    my $res = $fig->db_handle()->SQL("select genome, gname from genome order by gname");

    my %labels;
    my @values;
    for my $ent (@$res)
    {
	my($genome, $gs) = @$ent;

	push(@values, $genome);
	$labels{$genome} = "$gs ($genome)";
    }


    unshift(@values, "_choose_org");
    $labels{_choose_org} = "Pick an organism";

    
    push (@$html, ($cgi->popup_menu(-name => 'sel_genome',
				    -style => "width: 4in",
				    -values => \@values,
				    -labels => \%labels),,
		  "&nbsp;",
		   $cgi->submit(-name => 'view_genome',
				-value => "Go"),
		   $cgi->p,
		   ));
}

sub gen_text_search
{
    my($cgi, $html) = @_;


    push(@$html, ($cgi->textfield(-name => 'search_string',
				  -default => 'Enter search terms',
				  -style => "width: 4in",
				  -override => 1,
				  -onClick => 'check_first_search_click(this)',
				  -size => 60),
		  "&nbsp;",
		  $cgi->submit(-name => 'text_search',
			       -value => 'Go'),
		 ));
	  
}

sub handle_action
{
    my($field, $sub, $cgi, $html) = @_;

    if ($cgi->param($field))
    {
	&$sub($cgi, $html);
    }
}

sub do_view_subsystem
{
    my($cgi, $html) = @_;

    #
    # Just redirect to the subsystem page.
    #

    my $sub = $cgi->param('sel_subsystem');
    if ($sub eq "_choose_sub")
    {
	return;
    }
    #
    # bring up clustered in phylogenetic sort
    #

    my $esc_ssa = uri_escape($sub);

    my @params;
    push(@params, "sort=by_phylo");
    push(@params, "show_clusters=1");
    push(@params, "request=show_ssa");
    push(@params, "user=$user");
    push(@params, "ssa_name=$esc_ssa");

    my $params = join("&", @params);
    my $sub_url = $fig->cgi_url() . "/subsys.cgi?$params";
    print $cgi->redirect($sub_url);
    exit 0;
}

sub do_view_genome
{
    my($cgi, $html) = @_;

    #
    # For now, redirect to the organism statistics page.
    #

    my $genome = $cgi->param('sel_genome');
    if ($genome eq "_choose_org")
    {
	return;
    }

    my $sub_url = $fig->cgi_url() . "/genome_statistics.cgi?user=$user&genome=$genome";
    warn "Redirect to $sub_url\n";
    print $cgi->redirect($sub_url);
    exit 0;
}

sub do_text_search
{
    my($cgi, $html) = @_;

    my $str = $cgi->param('search_string');

    my $esc_str = uri_escape($str);
    
    my $redir = $fig->cgi_url() . "/index.cgi?pattern=$esc_str&Search=1&user=$user";
    print $cgi->redirect($redir);
}
    
sub do_go_old_seed
{
    my($cgi, $html) = @_;
    
    my $url = $fig->cgi_url() . "/index.cgi?user=$user";
    print $cgi->redirect($url);
    exit 0;
}

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3