[Bio] / SeedViewer / seedviewer.cgi Repository:
ViewVC logotype

Diff of /SeedViewer/seedviewer.cgi

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.20, Fri May 9 06:20:03 2008 UTC revision 1.32, Wed Aug 26 20:33:50 2009 UTC
# Line 2  Line 2 
2  use warnings;  use warnings;
3  no warnings 'once';  no warnings 'once';
4    
5    my $have_fcgi;
6    eval {
7        require CGI::Fast;
8        $have_fcgi = 1;
9    };
10    
11    use IO::Handle;
12    #open(TICKLOG, ">/dev/pts/9") or open(TICKLOG, ">&STDERR");
13    #TICKLOG->autoflush(1);
14    
15    use Time::HiRes 'gettimeofday';
16    my $start = gettimeofday;
17    my $time_last;
18    sub tick {
19        my($w) = @_;
20        my $now = gettimeofday;
21        my $t = $now - $start;
22        my $tms = int(($now - $time_last) * 1000);
23        $time_last = $now;
24        my ($package, $filename, $line) = caller;
25        if (1)
26        {
27            $filename =~ s,.*/common/lib,/lib,;
28            $filename =~ s,.*/CGI,/CGI,;
29            $filename =~ s/WebApplication/WA/;
30            $filename =~ s/WebComponent/WC/;
31        }
32    
33        printf TICKLOG "$$ %-40s %5d %8d %.3f\n", $filename, $line, $tms, $t;
34        TICKLOG->flush();
35    }
36    
37    
38  use DBMaster;  use DBMaster;
39  use WebApplication;  use WebApplication;
40  use WebMenu;  use WebMenu;
# Line 9  Line 42 
42  use Tracer;  use Tracer;
43  use FIGRules;  use FIGRules;
44  use FIG_Config;  use FIG_Config;
45    use WebConfig;
46    
47    #
48    # If no CGI vars, assume we are invoked as a fastcgi service.
49    #
50    my $n_requests = 0;
51    if ($have_fcgi && $ENV{REQUEST_METHOD} eq '')
52    {
53        #
54        # Precompile modules. Find where we found one, and use that path
55        # to walk for the rest.
56        #
57    
58        my $mod_path = $INC{"WebComponent/Ajax.pm"};
59        if ($mod_path && $mod_path =~ s,WebApplication/WebComponent/Ajax\.pm$,,)
60        {
61            local $SIG{__WARN__} = sub {};
62            for my $what (qw(SeedViewer RAST WebApplication))
63            {
64                for my $which (qw(WebPage WebComponent DataHandler))
65                {
66                    opendir(D, "$mod_path/$what/$which") or next;
67                    my @x = grep { /^[^.]/ } readdir(D);
68                    for my $mod (@x)
69                    {
70                        $mod =~ s/\.pm$//;
71                        my $fullmod = join("::", $what, $which, $mod);
72                        eval " require $fullmod; ";
73                    }
74                    closedir(D);
75                }
76            }
77        }
78        my $max_requests = 100;
79        while ((my $cgi = new CGI::Fast()) &&
80               ($max_requests == 0 || $n_requests++ < $max_requests))
81        {
82  eval {  eval {
83      &main;              &main($cgi);
84  };  };
   
85  if ($@)  if ($@)
86  {  {
87                if ($@ =~ /^cgi_exit/)
88                {
89                    # this is ok.
90                }
91                elsif (ref($@) ne 'ARRAY')
92                {
93                    warn "code died, cgi=$cgi returning error\n";
94                    print $cgi->header(-status => '500 error in body of cgi processing');
95                    print $@;
96                }
97            }
98        endloop:
99        }
100    }
101    else
102    {
103        my $cgi = new CGI();
104        eval { &main($cgi); };
105    
106        if ($@ && $@ !~ /^cgi_exit/)
107        {
108      my $error = $@;      my $error = $@;
109      Warn("Script error: $error") if T(SeedViewer => 0);      Warn("Script error: $error") if T(SeedViewer => 0);
110    
# Line 28  Line 117 
117      print CGI::end_html();      print CGI::end_html();
118    
119  }  }
120    }
121    
122  sub main {  sub main {
123        my($cgi) = @_;
124      # initialize cgi      ETracing($cgi);
125      my $cgi = new CGI();      if (FIGRules::nmpdr_mode($cgi)) {
126            Trace("NMPDR mode selected.") if T(3);
127            my $parms = $cgi->query_string();
128            if ($parms) {
129                $parms = "?$parms";
130            } else {
131                $parms = "?page=Home";
132            }
133            print CGI::redirect(-uri => "$FIG_Config::cgi_url/wiki/rest.cgi/NmpdrPlugin/SeedViewer$parms",
134                                -status => 301);
135        } else {
136    
137      # initialize layout      # initialize layout
138      # Use the template file for the current mode-- NMPDR or SEED      # Use the template file for the current mode-- NMPDR or SEED
139      my $templateFile = (FIGRules::nmpdr_mode($cgi) ? './Html/NmpdrViewer.tmpl' : './Html/SeedViewer.tmpl');          my $templateFile = TMPL_PATH . "/SeedViewer.tmpl";
140      Trace("Template file is $templateFile") if T(3);      Trace("Template file is $templateFile") if T(3);
141      my $layout = WebLayout->new($templateFile);      my $layout = WebLayout->new($templateFile);
142      # Choose the body/header style sheet according to the mode.      # Choose the body/header style sheet according to the mode.
143      if (FIGRules::nmpdr_mode($cgi)) {          $layout->add_css("$FIG_Config::cgi_url/Html/seedviewer.css");
144          # NMPDR mode.          $layout->add_css("$FIG_Config::cgi_url/Html/commonviewer.css");
145          $layout->add_css('./Html/nmpdrviewer.css');          $layout->add_css("$FIG_Config::cgi_url/Html/web_app_default.css");
         # Display the official NMPDR icon for this machine.  
         $layout->add_metatag("<link rel=\"icon\" href=\"${FIG_Config::cgi_base}wiki/pub/logos/nmpdr.ico\" type=\"image/x-icon\" />");  
         $layout->add_metatag("<link rel=\"shortcut icon\" href=\"${FIG_Config::cgi_base}wiki/pub/logos/nmpdr.ico\" type=\"image/x-icon\" />");  
     } else {  
         # SEED mode.  
         $layout->add_css('./Html/seedviewer.css');  
    }  
     # Add the common styles.  
     $layout->add_css('./Html/commonviewer.css');  
     # Add the normal style.  
     $layout->add_css('./Html/default.css');  
146      # build menu      # build menu
147      my $menu;      my $menu;
148      $menu = WebMenu->new();      $menu = WebMenu->new();
     if (FIGRules::nmpdr_mode($cgi)) {  
         $menu->add_category('&raquo;Navigate', '?page=Home');  
         $menu->add_entry('&raquo;Navigate', 'NMPDR home', "$FIG_Config::nmpdr_site_url/index.php");  
         $menu->add_entry('&raquo;Navigate', 'Organisms', "$FIG_Config::nmpdr_site_url/content/organisms.php");  
         $menu->add_entry('&raquo;Navigate', 'Subsystems', "$FIG_Config::nmpdr_site_url/content/subsystems.php");  
         $menu->add_entry('&raquo;Navigate', 'FigFams', '?page=FigFamViewer');  
     } else {  
149          $menu->add_category('&raquo;Navigate', '?page=Home');          $menu->add_category('&raquo;Navigate', '?page=Home');
150          $menu->add_entry('&raquo;Navigate', 'Startpage', '?page=Home');          $menu->add_entry('&raquo;Navigate', 'Startpage', '?page=Home');
151          $menu->add_entry('&raquo;Navigate', 'Organisms', '?page=OrganismSelect');          $menu->add_entry('&raquo;Navigate', 'Organisms', '?page=OrganismSelect');
152          $menu->add_entry('&raquo;Navigate', 'Subsystems', '?page=SubsystemSelect');          $menu->add_entry('&raquo;Navigate', 'Subsystems', '?page=SubsystemSelect');
153            $menu->add_entry('&raquo;Navigate', 'Scenarios', '?page=Scenarios');
154          $menu->add_entry('&raquo;Navigate', 'FigFams', '?page=FigFamViewer');          $menu->add_entry('&raquo;Navigate', 'FigFams', '?page=FigFamViewer');
155          $menu->add_entry('&raquo;Navigate', '<a>Jump to Feature by</a>');          $menu->add_entry('&raquo;Navigate', 'BLAST Search', '?page=BlastRun');
         $menu->add_entry('&raquo;Navigate', '&nbsp;&nbsp;BLAST Search', '?page=BlastRun');  
         $menu->add_entry('&raquo;Navigate', "<form style='margin: 0px 0px 0px 6px;'>&nbsp;&nbsp;ID&nbsp;&nbsp;<input type='text' name='pattern' style='border: 1px solid #5da668; width: 100px; height: 17px; margin-top: 2px; font-size: 11px;'><input type='hidden' name='page' value='SearchResult'><input type='hidden' name='action' value='check_search'><input type='submit' style='display:none;'></form>");  
     }  
156      if (defined($FIG_Config::teacher_db)) {      if (defined($FIG_Config::teacher_db)) {
157          $menu->add_category('&raquo;Teacher', '?page=Teach', undef, ['edit', 'problem_list'], 96);          $menu->add_category('&raquo;Teacher', '?page=Teach', undef, ['edit', 'problem_list'], 96);
158          $menu->add_entry('&raquo;Teacher', 'Class Performance', '?page=Teach');          $menu->add_entry('&raquo;Teacher', 'Class Performance', '?page=Teach');
# Line 80  Line 160 
160          $menu->add_entry('&raquo;Teacher', 'Problem Sets', '?page=ManageProblemSets');          $menu->add_entry('&raquo;Teacher', 'Problem Sets', '?page=ManageProblemSets');
161          $menu->add_entry('&raquo;Teacher', 'Annotation Resolve', '?page=ClassAnnotationResolve');          $menu->add_entry('&raquo;Teacher', 'Annotation Resolve', '?page=ClassAnnotationResolve');
162      }      }
     #$menu->add_category('&raquo;Admin', '?page=Admin', undef, ['edit', 'scope', '*'], 99);  
     if (FIGRules::nmpdr_mode($cgi)) {  
         $menu->add_category('Help', "$FIG_Config::nmpdr_site_url/content/help.php", 'help', undef, 98);  
         $menu->add_entry('Help', 'Searching NMPDR', "$FIG_Config::nmpdr_site_url/content/find.php");  
         $menu->add_entry('Help', 'Contact', "$FIG_Config::nmpdr_site_url/content/contactus.php");  
     } else {  
163          $menu->add_category('&raquo;Help', 'http://www.theseed.org', 'help', undef, 98);          $menu->add_category('&raquo;Help', 'http://www.theseed.org', 'help', undef, 98);
164          $menu->add_entry('&raquo;Help', 'What is the SEED', 'http://www.theseed.org/wiki/Home_of_the_SEED');          $menu->add_entry('&raquo;Help', 'What is the SEED', 'http://www.theseed.org/wiki/Home_of_the_SEED');
165          $menu->add_entry('&raquo;Help', 'HowTo use the SEED Viewer', 'http://www.theseed.org/wiki/SEED_Viewer_Tutorial');          $menu->add_entry('&raquo;Help', 'HowTo use the SEED Viewer', 'http://www.theseed.org/wiki/SEED_Viewer_Tutorial');
166          $menu->add_entry('&raquo;Help', 'Submitting Data to SEED', 'http://www.theseed.org/wiki/RAST_Tutorial');          $menu->add_entry('&raquo;Help', 'Submitting Data to SEED', 'http://www.theseed.org/wiki/RAST_Tutorial');
167          $menu->add_entry('&raquo;Help', 'Contact', 'http://www.theseed.org/wiki/Contact');  
168            # check which contact info to show
169            if (defined($FIG_Config::server_type) && ($FIG_Config::server_type eq 'MG-RAST')) {
170                $menu->add_entry('&raquo;Help', 'Contact', 'mailto:mg-rast@mcs.anl.gov', undef, ['login']);
171            } elsif (defined($FIG_Config::server_type) && ($FIG_Config::server_type eq 'RAST')) {
172                $menu->add_entry('&raquo;Help', 'Contact', 'mailto:rast@mcs.anl.gov', undef, ['login']);
173            } else {
174                $menu->add_entry('&raquo;Help', 'Contact', 'mailto:info@theseed.org');
175            }
176          $menu->add_entry('&raquo;Help', 'Register', '?page=Register');          $menu->add_entry('&raquo;Help', 'Register', '?page=Register');
177          $menu->add_entry('&raquo;Help', 'I forgot my Password', '?page=RequestNewPassword');          $menu->add_entry('&raquo;Help', 'I forgot my Password', '?page=RequestNewPassword');
178      }  
179      # initialize application      # initialize application
180      my $WebApp = WebApplication->new( { id => 'SeedViewer',      my $WebApp = WebApplication->new( { id => 'SeedViewer',
181                                          menu     => $menu,                                          menu     => $menu,
182                                          layout   => $layout,                                          layout   => $layout,
183                                          default  => 'Home',                                          default  => 'Home',
184                                                cgi => $cgi,
185                                        } );                                        } );
186      my $prefix = (FIGRules::nmpdr_mode($cgi) ? "NMPDR " : "") . "Seed Viewer - ";  
187            my $prefix = "Seed Viewer - ";
188      $WebApp->page_title_prefix($prefix);      $WebApp->page_title_prefix($prefix);
189      $WebApp->show_login_user_info(1);      $WebApp->show_login_user_info(1);
   
190      # run application      # run application
191      $WebApp->run();      $WebApp->run();
192        }
193  }  }

Legend:
Removed from v.1.20  
changed lines
  Added in v.1.32

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3