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

Annotation of /SeedViewer/seedviewer.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.36 - (view) (download)

1 : paczian 1.1 use strict;
2 :     use warnings;
3 : paczian 1.7 no warnings 'once';
4 : paczian 1.1
5 :     use DBMaster;
6 :     use WebApplication;
7 :     use WebMenu;
8 :     use WebLayout;
9 : parrello 1.6 use Tracer;
10 :     use FIGRules;
11 : paczian 1.5 use FIG_Config;
12 : olson 1.26 use WebConfig;
13 : olson 1.35 use Data::Dumper;
14 : paczian 1.1
15 : olson 1.34 my $have_fcgi;
16 : paczian 1.33 eval {
17 : olson 1.34 require CGI::Fast;
18 :     $have_fcgi = 1;
19 : paczian 1.33 };
20 :    
21 : olson 1.34 if ($have_fcgi && ! $ENV{REQUEST_METHOD})
22 : paczian 1.1 {
23 : olson 1.35
24 :     #
25 :     # Precompile modules. Find where we found one, and use that path
26 :     # to walk for the rest.
27 :     #
28 :     my $mod_path = $INC{"WebComponent/Ajax.pm"};
29 :     if ($mod_path && $mod_path =~ s,WebApplication/WebComponent/Ajax\.pm$,,)
30 :     {
31 :     local $SIG{__WARN__} = sub {};
32 :     for my $what (qw(SeedViewer RAST WebApplication))
33 :     {
34 :     for my $which (qw(WebPage WebComponent DataHandler))
35 :     {
36 :     opendir(D, "$mod_path/$what/$which") or next;
37 :     my @x = grep { /^[^.]/ } readdir(D);
38 :     for my $mod (@x)
39 :     {
40 :     $mod =~ s/\.pm$//;
41 :     my $fullmod = join("::", $what, $which, $mod);
42 :     eval " require $fullmod; ";
43 :     }
44 :     closedir(D);
45 :     }
46 :     }
47 :     }
48 :    
49 : olson 1.34 my $max_requests = $FIG_Config::fcgi_max_requests || 50;
50 :     my $n_requests = 0;
51 : paczian 1.33
52 : olson 1.34 warn "begin loop\n";
53 :     while (($max_requests == 0 || $n_requests++ < $max_requests) &&
54 :     (my $cgi = new CGI::Fast()))
55 :     {
56 :     eval {
57 :     &main($cgi);
58 :     };
59 :    
60 :     if ($@)
61 :     {
62 :     my $error = $@;
63 :     Warn("Script error: $error") if T(SeedViewer => 0);
64 :    
65 :     print CGI::header();
66 :     print CGI::start_html();
67 :    
68 :     # print out the error
69 :     print '<pre>'.$error.'</pre>';
70 :    
71 :     print CGI::end_html();
72 :     }
73 :     }
74 :     }
75 :     else
76 :     {
77 :     my $cgi = new CGI;
78 :     eval {
79 :     &main($cgi);
80 :     };
81 :     if ($@)
82 :     {
83 :     my $error = $@;
84 :     Warn("Script error: $error") if T(SeedViewer => 0);
85 :    
86 :     print CGI::header();
87 :     print CGI::start_html();
88 :    
89 :     # print out the error
90 :     print '<pre>'.$error.'</pre>';
91 :    
92 :     print CGI::end_html();
93 :     }
94 : paczian 1.1 }
95 :    
96 :     sub main {
97 : olson 1.34 my($cgi) = @_;
98 : paczian 1.33
99 :     # Initialize tracing.
100 : parrello 1.24 ETracing($cgi);
101 :     if (FIGRules::nmpdr_mode($cgi)) {
102 :     Trace("NMPDR mode selected.") if T(3);
103 : parrello 1.23 my $parms = $cgi->query_string();
104 :     if ($parms) {
105 :     $parms = "?$parms";
106 :     } else {
107 :     $parms = "?page=Home";
108 :     }
109 :     print CGI::redirect(-uri => "$FIG_Config::cgi_url/wiki/rest.cgi/NmpdrPlugin/SeedViewer$parms",
110 :     -status => 301);
111 : parrello 1.15 } else {
112 : olson 1.35 if ($FIG_Config::log_cgi)
113 :     {
114 :     if (open(CLOG, ">>", $FIG_Config::log_cgi))
115 :     {
116 : olson 1.36 for my $p (sort $cgi->param)
117 : olson 1.35 {
118 :     print CLOG Data::Dumper->dump([$cgi->params($p)], [qq(\$params{'$p'})]);
119 :     }
120 :     close(CLOG);
121 :     }
122 :     }
123 :    
124 : parrello 1.24 # initialize layout
125 :     # Use the template file for the current mode-- NMPDR or SEED
126 : olson 1.26 my $templateFile = TMPL_PATH . "/SeedViewer.tmpl";
127 : parrello 1.24 Trace("Template file is $templateFile") if T(3);
128 :     my $layout = WebLayout->new($templateFile);
129 :     # Choose the body/header style sheet according to the mode.
130 :     $layout->add_css("$FIG_Config::cgi_url/Html/seedviewer.css");
131 :     $layout->add_css("$FIG_Config::cgi_url/Html/commonviewer.css");
132 : paczian 1.30 $layout->add_css("$FIG_Config::cgi_url/Html/web_app_default.css");
133 : parrello 1.24 # build menu
134 :     my $menu;
135 :     $menu = WebMenu->new();
136 : parrello 1.16 $menu->add_category('&raquo;Navigate', '?page=Home');
137 :     $menu->add_entry('&raquo;Navigate', 'Startpage', '?page=Home');
138 :     $menu->add_entry('&raquo;Navigate', 'Organisms', '?page=OrganismSelect');
139 :     $menu->add_entry('&raquo;Navigate', 'Subsystems', '?page=SubsystemSelect');
140 : paczian 1.27 $menu->add_entry('&raquo;Navigate', 'Scenarios', '?page=Scenarios');
141 : parrello 1.16 $menu->add_entry('&raquo;Navigate', 'FigFams', '?page=FigFamViewer');
142 : olson 1.35 if ($FIG_Config::atomic_regulon_dir && -d $FIG_Config::atomic_regulon_dir)
143 :     {
144 :     $menu->add_entry('&raquo;Navigate', 'Atomic Regulons', '?page=AtomicRegulon&genome=all');
145 :     }
146 : paczian 1.22 $menu->add_entry('&raquo;Navigate', 'BLAST Search', '?page=BlastRun');
147 : parrello 1.24 if (defined($FIG_Config::teacher_db)) {
148 :     $menu->add_category('&raquo;Teacher', '?page=Teach', undef, ['edit', 'problem_list'], 96);
149 :     $menu->add_entry('&raquo;Teacher', 'Class Performance', '?page=Teach');
150 :     $menu->add_entry('&raquo;Teacher', 'Class Management', '?page=ManageClass');
151 :     $menu->add_entry('&raquo;Teacher', 'Problem Sets', '?page=ManageProblemSets');
152 :     $menu->add_entry('&raquo;Teacher', 'Annotation Resolve', '?page=ClassAnnotationResolve');
153 :     }
154 :     $menu->add_category('&raquo;Help', 'http://www.theseed.org', 'help', undef, 98);
155 : paczian 1.33 $menu->add_entry('&raquo;Help', 'What is the SEED', 'http://www.theseed.org/wiki/index.php/Home_of_the_SEED');
156 :     $menu->add_entry('&raquo;Help', 'HowTo use the SEED Viewer', 'http://www.theseed.org/wiki/index.php/SEED_Viewer_Tutorial');
157 :     $menu->add_entry('&raquo;Help', 'Submitting Data to SEED', 'http://www.theseed.org/wiki/index.php/RAST_Tutorial');
158 : paczian 1.25
159 :     # check which contact info to show
160 :     if (defined($FIG_Config::server_type) && ($FIG_Config::server_type eq 'MG-RAST')) {
161 :     $menu->add_entry('&raquo;Help', 'Contact', 'mailto:mg-rast@mcs.anl.gov', undef, ['login']);
162 :     } elsif (defined($FIG_Config::server_type) && ($FIG_Config::server_type eq 'RAST')) {
163 :     $menu->add_entry('&raquo;Help', 'Contact', 'mailto:rast@mcs.anl.gov', undef, ['login']);
164 :     } else {
165 :     $menu->add_entry('&raquo;Help', 'Contact', 'mailto:info@theseed.org');
166 :     }
167 : parrello 1.24 $menu->add_entry('&raquo;Help', 'Register', '?page=Register');
168 : paczian 1.10 $menu->add_entry('&raquo;Help', 'I forgot my Password', '?page=RequestNewPassword');
169 : paczian 1.30
170 : parrello 1.24 # initialize application
171 :     my $WebApp = WebApplication->new( { id => 'SeedViewer',
172 :     menu => $menu,
173 :     layout => $layout,
174 :     default => 'Home',
175 : olson 1.35 cgi => $cgi,
176 : parrello 1.24 } );
177 : paczian 1.30
178 : parrello 1.24 my $prefix = "Seed Viewer - ";
179 :     $WebApp->page_title_prefix($prefix);
180 :     $WebApp->show_login_user_info(1);
181 :     # run application
182 :     $WebApp->run();
183 : parrello 1.6 }
184 : paczian 1.1 }

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3