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

Annotation of /SeedViewer/seedviewer.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.32 - (view) (download)

1 : paczian 1.1 use strict;
2 :     use warnings;
3 : paczian 1.7 no warnings 'once';
4 : paczian 1.1
5 : olson 1.32 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 : paczian 1.1 use DBMaster;
39 :     use WebApplication;
40 :     use WebMenu;
41 :     use WebLayout;
42 : parrello 1.6 use Tracer;
43 :     use FIGRules;
44 : paczian 1.5 use FIG_Config;
45 : olson 1.26 use WebConfig;
46 : paczian 1.1
47 : olson 1.32 #
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 : paczian 1.1 {
53 : olson 1.32 #
54 :     # Precompile modules. Find where we found one, and use that path
55 :     # to walk for the rest.
56 :     #
57 : paczian 1.1
58 : olson 1.32 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 {
83 :     &main($cgi);
84 :     };
85 :     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 : paczian 1.1
106 : olson 1.32 if ($@ && $@ !~ /^cgi_exit/)
107 :     {
108 :     my $error = $@;
109 :     Warn("Script error: $error") if T(SeedViewer => 0);
110 :    
111 :     print CGI::header();
112 :     print CGI::start_html();
113 :    
114 :     # print out the error
115 :     print '<pre>'.$error.'</pre>';
116 :    
117 :     print CGI::end_html();
118 :    
119 :     }
120 : paczian 1.1 }
121 :    
122 :     sub main {
123 : olson 1.32 my($cgi) = @_;
124 : parrello 1.24 ETracing($cgi);
125 :     if (FIGRules::nmpdr_mode($cgi)) {
126 :     Trace("NMPDR mode selected.") if T(3);
127 : parrello 1.23 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 : parrello 1.15 } else {
136 : olson 1.32
137 : parrello 1.24 # initialize layout
138 :     # Use the template file for the current mode-- NMPDR or SEED
139 : olson 1.26 my $templateFile = TMPL_PATH . "/SeedViewer.tmpl";
140 : parrello 1.24 Trace("Template file is $templateFile") if T(3);
141 :     my $layout = WebLayout->new($templateFile);
142 :     # Choose the body/header style sheet according to the mode.
143 :     $layout->add_css("$FIG_Config::cgi_url/Html/seedviewer.css");
144 :     $layout->add_css("$FIG_Config::cgi_url/Html/commonviewer.css");
145 : paczian 1.30 $layout->add_css("$FIG_Config::cgi_url/Html/web_app_default.css");
146 : parrello 1.24 # build menu
147 :     my $menu;
148 :     $menu = WebMenu->new();
149 : parrello 1.16 $menu->add_category('&raquo;Navigate', '?page=Home');
150 :     $menu->add_entry('&raquo;Navigate', 'Startpage', '?page=Home');
151 :     $menu->add_entry('&raquo;Navigate', 'Organisms', '?page=OrganismSelect');
152 :     $menu->add_entry('&raquo;Navigate', 'Subsystems', '?page=SubsystemSelect');
153 : paczian 1.27 $menu->add_entry('&raquo;Navigate', 'Scenarios', '?page=Scenarios');
154 : parrello 1.16 $menu->add_entry('&raquo;Navigate', 'FigFams', '?page=FigFamViewer');
155 : paczian 1.22 $menu->add_entry('&raquo;Navigate', 'BLAST Search', '?page=BlastRun');
156 : parrello 1.24 if (defined($FIG_Config::teacher_db)) {
157 :     $menu->add_category('&raquo;Teacher', '?page=Teach', undef, ['edit', 'problem_list'], 96);
158 :     $menu->add_entry('&raquo;Teacher', 'Class Performance', '?page=Teach');
159 :     $menu->add_entry('&raquo;Teacher', 'Class Management', '?page=ManageClass');
160 :     $menu->add_entry('&raquo;Teacher', 'Problem Sets', '?page=ManageProblemSets');
161 :     $menu->add_entry('&raquo;Teacher', 'Annotation Resolve', '?page=ClassAnnotationResolve');
162 :     }
163 :     $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');
165 :     $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');
167 : paczian 1.25
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 : parrello 1.24 $menu->add_entry('&raquo;Help', 'Register', '?page=Register');
177 : paczian 1.10 $menu->add_entry('&raquo;Help', 'I forgot my Password', '?page=RequestNewPassword');
178 : paczian 1.30
179 : parrello 1.24 # initialize application
180 :     my $WebApp = WebApplication->new( { id => 'SeedViewer',
181 :     menu => $menu,
182 :     layout => $layout,
183 :     default => 'Home',
184 : olson 1.32 cgi => $cgi,
185 : parrello 1.24 } );
186 : paczian 1.30
187 : parrello 1.24 my $prefix = "Seed Viewer - ";
188 :     $WebApp->page_title_prefix($prefix);
189 :     $WebApp->show_login_user_info(1);
190 :     # run application
191 :     $WebApp->run();
192 : parrello 1.6 }
193 : paczian 1.1 }

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3