[Bio] / RAST / rast.cgi Repository:
ViewVC logotype

Annotation of /RAST/rast.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.16 - (view) (download)

1 : paarmann 1.1 use strict;
2 :     use warnings;
3 :    
4 :     use DBMaster;
5 :     use WebApplication;
6 :     use WebMenu;
7 :     use WebLayout;
8 :     use WebConfig;
9 :    
10 : gdpusch 1.16 use CGI qw(-debug);
11 :     #use CGI::Debug;
12 :     use CGI::Carp 'fatalsToBrowser';
13 :    
14 : olson 1.12 #use IO::Handle;
15 :     #open(TICKLOG, ">/dev/pts/9") or open(TICKLOG, ">&STDERR");
16 :     #TICKLOG->autoflush(1);
17 :    
18 :     use Time::HiRes 'gettimeofday';
19 :     my $start = gettimeofday;
20 :     my $time_last;
21 : gdpusch 1.16 # sub tick {
22 :     # my($w) = @_;
23 :     # my $now = gettimeofday;
24 :     # my $t = $now - $start;
25 :     # my $tms = int(($now - $time_last) * 1000);
26 :     # $time_last = $now;
27 :     # my ($package, $filename, $line) = caller;
28 :     #
29 :     # printf TICKLOG "$$ %-40s %5d %5d %.3f\n", $filename, $line, $tms, $t;
30 :     # TICKLOG->flush();
31 :     # }
32 : paarmann 1.3
33 : olson 1.12 my $have_fcgi;
34 :     eval {
35 :     require CGI::Fast;
36 :     $have_fcgi = 1;
37 :     };
38 :    
39 :    
40 : gdpusch 1.16 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
41 : olson 1.12 # If no CGI vars, assume we are invoked as a fastcgi service.
42 : gdpusch 1.16 #-----------------------------------------------------------------------
43 : olson 1.12 my $n_requests = 0;
44 :     if ($have_fcgi && $ENV{REQUEST_METHOD} eq '')
45 :     {
46 :     #
47 :     # Precompile modules. Find where we found one, and use that path
48 :     # to walk for the rest.
49 :     #
50 :    
51 :     my $mod_path = $INC{"WebComponent/Ajax.pm"};
52 :     if ($mod_path && $mod_path =~ s,WebApplication/WebComponent/Ajax\.pm$,,)
53 :     {
54 :     local $SIG{__WARN__} = sub {};
55 :     for my $what (qw(SeedViewer RAST WebApplication))
56 :     {
57 :     for my $which (qw(WebPage WebComponent DataHandler))
58 :     {
59 :     opendir(D, "$mod_path/$what/$which") or next;
60 :     my @x = grep { /^[^.]/ } readdir(D);
61 :     for my $mod (@x)
62 :     {
63 :     $mod =~ s/\.pm$//;
64 :     my $fullmod = join("::", $what, $which, $mod);
65 :     eval " require $fullmod; ";
66 :     }
67 :     closedir(D);
68 :     }
69 :     }
70 :     }
71 :     my $max_requests = 100;
72 :     while ((my $cgi = new CGI::Fast()) &&
73 :     ($max_requests == 0 || $n_requests++ < $max_requests))
74 :     {
75 :     eval {
76 :     &main($cgi);
77 :     };
78 :     if ($@)
79 :     {
80 :     if ($@ =~ /^cgi_exit/)
81 :     {
82 :     # this is ok.
83 :     }
84 :     elsif (ref($@) ne 'ARRAY')
85 :     {
86 :     warn "code died, cgi=$cgi returning error '$@'\n";
87 :     print $cgi->header(-status => '500 error in body of cgi processing');
88 : gdpusch 1.16 print CGI::start_html();
89 :     print '<pre>'.Dumper($@).'</pre>';
90 :     print CGI::end_html();
91 : olson 1.12 }
92 :     }
93 :     endloop:
94 :     }
95 : dsouza 1.6
96 : olson 1.12 }
97 :     else
98 :     {
99 :     my $cgi = new CGI();
100 :     eval { &main($cgi); };
101 :    
102 : olson 1.13 if ($@ && $@ !~ /^cgi_exit/)
103 : olson 1.12 {
104 :     my $error = $@;
105 : gdpusch 1.16 warn "ERROR rast.cgi: '$error'";
106 :     ## Warn("Script error: $error") if T(SeedViewer => 0);
107 : olson 1.12
108 :     print CGI::header();
109 :     print CGI::start_html();
110 :    
111 : gdpusch 1.16 # print out the error
112 : olson 1.12 print '<pre>'.$error.'</pre>';
113 : dsouza 1.6
114 : olson 1.12 print CGI::end_html();
115 :     }
116 :     }
117 :    
118 :     sub main {
119 :     my($cgi) = @_;
120 : paarmann 1.1
121 : olson 1.12 # read local WebConfig because we need it here
122 :     &WebConfig::import_local_config('RAST');
123 : gdpusch 1.15
124 : gdpusch 1.16 # choose a layout
125 : olson 1.12 my $layout = WebLayout->new("$FIG_Config::fig/CGI/Html/RAST.tmpl");
126 :     $layout->add_css(TMPL_URL_PATH.'/web_app_default.css');
127 :     $layout->add_css(TMPL_URL_PATH.'/rast.css');
128 :    
129 : gdpusch 1.16 # add site meter
130 : olson 1.12 my $site_meter = $FIG_Config::site_meter;
131 :     if ($site_meter) {
132 :     $layout->add_javascript("http://s20.sitemeter.com/js/counter.js?site=s20nmpdr");
133 :     }
134 : gdpusch 1.16
135 :    
136 :     #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
137 :     # create the menu
138 :     #-----------------------------------------------------------------------
139 : olson 1.12 my $menu = WebMenu->new();
140 : gdpusch 1.15
141 :     $menu->add_category('&raquo;Home', 'rast.cgi', undef, [ 'login' ]);
142 :     $menu->add_entry('&raquo;Home', 'SeedViewer', 'seedviewer.cgi');
143 :    
144 : gdpusch 1.16
145 :     #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
146 :     #...Help Menu...
147 :     #-----------------------------------------------------------------------
148 : gdpusch 1.15 $menu->add_category('&raquo;Your Jobs', 'rast.cgi?page=Jobs', undef, [ 'login' ]);
149 :     $menu->add_entry('&raquo;Your Jobs', 'Jobs Overview', 'rast.cgi?page=Jobs');
150 :     $menu->add_entry('&raquo;Your Jobs', 'Upload New Job', 'rast.cgi?page=Upload');
151 :     $menu->add_entry('&raquo;Your Jobs', 'Private Organism Preferences', '?page=PrivateOrganismPreferences');
152 :    
153 :    
154 : gdpusch 1.16 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
155 :     #...(We have stopped accepting genomes for import into the SEED)...
156 :     #-----------------------------------------------------------------------
157 :     # $menu->add_category('&raquo;Import Control', 'rast.cgi?page=ControlCenter', undef, [ 'import' ]);
158 :     #=======================================================================
159 : gdpusch 1.15
160 : gdpusch 1.16
161 :     #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
162 :     #...Tutorials Menu...
163 :     #-----------------------------------------------------------------------
164 :     $menu->add_category('&raquo;Tutorials', undef, undef, undef, 98);
165 : gdpusch 1.15 $menu->add_entry('&raquo;Tutorials', 'Registering for RAST',
166 :     'http://blog.theseed.org/servers/presentations/t1/rast.html', '_blank');
167 :     $menu->add_entry('&raquo;Tutorials', 'Automated Assembly and RASTtk Workshop presentations',
168 :     'http://tutorial.theseed.org/', '_blank');
169 :     $menu->add_entry('&raquo;Tutorials', 'SEED and "Classic RAST" Workshop presentations',
170 :     'http://blog.theseed.org/servers/rast-workshop-presentations.html', '_blank');
171 :     $menu->add_entry('&raquo;Tutorials', 'Downloading and installing the myRAST Toolkit',
172 :     'http://blog.theseed.org/servers/installation/distribution-of-the-seed-server-packages.html', '_blank');
173 :     $menu->add_entry('&raquo;Tutorials', 'Scripting job submissions using the myRAST command-line interface',
174 :     'http://blog.theseed.org/servers/usage/the-rast-batch-interface.html', '_blank');
175 :     $menu->add_entry('&raquo;Tutorials', 'Downloading and installing the RASTtk Toolkit (Mac and Ubuntu)',
176 :     'https://github.com/TheSEED/RASTtk-Distribution/releases/', '_blank');
177 :     $menu->add_entry('&raquo;Tutorials', 'General tutorial on using the myRAST command-line interface',
178 :     'http://blog.theseed.org/servers/usage/command-line-services.html', '_blank');
179 :     $menu->add_entry('&raquo;Tutorials', 'Getting Started using IRIS',
180 :     'http://tutorial.theseed.org/IRIS.html', '_blank');
181 :     $menu->add_entry('&raquo;Tutorials', 'Getting Started using RASTtk',
182 :     'http://tutorial.theseed.org/RASTtk/RASTtk_Getting_Started.html', '_blank');
183 :     $menu->add_entry('&raquo;Tutorials', 'Other Tutorials',
184 :     'http://www.theseed.org/tutorials/', '_blank');
185 :    
186 : gdpusch 1.16
187 :     #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
188 :     #...Help Menu...
189 :     #-----------------------------------------------------------------------
190 :     $menu->add_category('&raquo;Help', undef, undef, undef, 99);
191 :     $menu->add_entry('&raquo;Help', 'What is RAST', 'http://www.nmpdr.org/FIG/wiki/view.cgi/Main/RAST', '_blank');
192 :     $menu->add_entry('&raquo;Help', 'RAST FAQ', 'http://www.nmpdr.org/FIG/wiki/view.cgi/Main/RASTFAQ', '_blank');
193 :     $menu->add_entry('&raquo;Help', 'What is the SEED', 'http://www.theseed.org/wiki/index.php/Home_of_the_SEED', '_blank');
194 :     $menu->add_entry('&raquo;Help', 'HowTo use the SEED Viewer', 'http://www.theseed.org/wiki/index.php/SEED_Viewer_Tutorial', '_blank');
195 :     $menu->add_entry('&raquo;Help', 'Contact', 'mailto:rast@mcs.anl.gov');
196 :     $menu->add_entry('&raquo;Help', 'Register', '?page=Register');
197 :     $menu->add_entry('&raquo;Help', 'I forgot my Password', '?page=RequestNewPassword');
198 :    
199 :    
200 : gdpusch 1.15 # $menu->add_category('<center>Test of <font color=red>centering</font> in categories</center>', undef, undef, undef, 100);
201 : gdpusch 1.16
202 :    
203 :     #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
204 :     # init the WebApplication
205 :     #-----------------------------------------------------------------------
206 : olson 1.12 my $WebApp = WebApplication->new( { id => 'RAST',
207 : gdpusch 1.15 menu => $menu,
208 :     layout => $layout,
209 :     cgi => $cgi,
210 :     default => 'Home',
211 :     } );
212 : olson 1.12
213 :     $WebApp->page_title_prefix('RAST Server - ');
214 : gdpusch 1.15 # $WebApp->fancy_login(1);
215 :     $WebApp->show_login_user_info(1);
216 : olson 1.12 $WebApp->run();
217 :     }

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3