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

Annotation of /FigWebServices/frame.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (view) (download)

1 : olson 1.1
2 :     ##################################################
3 :     # includes
4 :     ##################################################
5 :     use warnings;
6 :     use strict;
7 :    
8 :     use CGI qw(:standard);
9 :     use HTML::Template;
10 :    
11 :     use FIG;
12 :     use FIG_Config;
13 :     use FIG_CGI;
14 :    
15 : olson 1.2 use FigWebServices::SeedComponents;
16 : olson 1.1
17 :     ##################################################
18 :     # handle exceptions
19 :     ##################################################
20 :    
21 :     eval {
22 :     &main();
23 :     };
24 :    
25 :     if($@) {
26 : olson 1.2 my $ex = $@;
27 : olson 1.1 print header(),start_html();
28 : olson 1.2 print STDERR "EXCEPTION: $ex\n";
29 :     print "EXCEPTION: $ex\n",end_html();
30 : olson 1.1 }
31 :    
32 :     1;
33 :    
34 :     ##################################################
35 :     # main subroutine
36 :     ##################################################
37 :    
38 :     sub main {
39 :    
40 :     # constant variables
41 : olson 1.2 use constant DOCUMENT_ROOT => "$FIG_Config::fig/CGI/Html/";
42 : olson 1.1 use constant TEMPLATE_PATH => DOCUMENT_ROOT;
43 : olson 1.2 use constant USER_DIR => "$FIG_Config::fig/var/Users/";
44 : olson 1.1
45 :     # initialize content variables
46 :     my $document_base = "./Html/";
47 : olson 1.2 my $image_base = $document_base;
48 :     # my $image_base = $document_base . "images/";
49 : olson 1.1 my $configuration = "";
50 :     my $preferences = {};
51 :    
52 :     my $title = "";
53 :     my $menu = "";
54 :     my $session = "";
55 :     my $logo = "";
56 :     my $content = "";
57 :    
58 :     # initialize fig object
59 :     my ($fig, $cgi, $user) = FIG_CGI::init(debug_save => 0,
60 :     debug_load => 0,
61 :     print_params => 0);
62 :    
63 :     # initialize params hash
64 :     my $params = { document_base => $document_base,
65 :     image_base => $image_base,
66 :     fig => $fig,
67 :     cgi => $cgi };
68 :    
69 :     # check for logged in user
70 : olson 1.2 $user = "Guest";
71 : olson 1.1 if (defined($cgi->param("user"))) {
72 :     $user = $cgi->param("user");
73 :     }
74 :     $params->{user} = $user;
75 :    
76 :     # set session html
77 :     $session = qq~
78 :     <form method='post' action='frame.cgi' name='login_form'>
79 :     <table width=100%>
80 :     <tr><td colspan=3 style="border-top: 1px solid #000088;"></td></tr>
81 :     <tr style="vertical-align: bottom;">
82 :     <td width='40px' height='28px'><b>User:</b></td><td width='100%'><input type='text' name='user' value='~ . $user . qq~' style="width: 100px;"></td><td id='login'><img src="~ . $params->{image_base} . qq~power.jpg" onclick="document.forms.login_form.submit();" class="login"></td>
83 :     </tr>
84 :     </table>
85 :     </form>
86 :     ~;
87 :    
88 : olson 1.2 # Ensure config dir and at least Guest's config file is present.
89 :    
90 :     &FIG::verify_dir(USER_DIR);
91 :    
92 :     my $user_conf = USER_DIR . $user;
93 :     if (! -f $user_conf)
94 :     {
95 :     open(FH, ">$user_conf");
96 :     print FH qq(extlinks,element,1,1,blue;intlinks,element,1,1,blue;services,element,1,1,blue;\n);
97 :     print FH qq({start_page=>"get_welcome",sort_subsystem=>"by_phylo",show_clusters_subsystem=>1}\n);
98 :     END
99 :     }
100 :    
101 : olson 1.1 # load configuration
102 :     open(FH, USER_DIR . $user) or die "Could not open configuration file";
103 :     my @conf;
104 :     while (<FH>) {
105 :     push(@conf, $_);
106 :     }
107 :     $configuration = $conf[0];
108 :     $preferences = $conf[1];
109 :    
110 :     # set background information for all forms to post
111 :     $params->{background_information} = "<input type='hidden' name='user' value='" . $user . "'>";
112 :    
113 :     # store user preferences
114 :     $params->{user_preferences} = eval($preferences);
115 :    
116 :     # process current action
117 :     unless (defined($cgi->param("action"))) {
118 : olson 1.2 $content = eval("FigWebServices::SeedComponents::Basic::" . $params->{user_preferences}->{start_page} . "(\$params)");
119 : olson 1.1 } elsif ($cgi->param("action") eq "textsearch") {
120 :     $content = "You searched for " . $cgi->param("textsearch");
121 :     } elsif ($cgi->param("action") eq "select_organism") {
122 :     $content = "You want to browse " . $cgi->param("organism");
123 :     } elsif ($cgi->param("action") eq "select_subsystem") {
124 :     $content = "You want to browse " . $cgi->param("subsystem");
125 :     }
126 :    
127 :     # generate common content
128 : olson 1.2 $title = FigWebServices::SeedComponents::Framework::get_title($params);
129 :     $logo = FigWebServices::SeedComponents::Framework::get_logo($params);
130 :     $menu = FigWebServices::SeedComponents::Framework::get_menu($params);
131 : olson 1.1
132 :     # create output template
133 :     my $template = HTML::Template->new(filename => TEMPLATE_PATH . 'frame.tmpl');
134 :    
135 :     # insert content into template
136 :     $template->param(document_base => $document_base);
137 :     $template->param(image_base => $image_base);
138 :     $template->param(configuration => $configuration);
139 :     $template->param(title => $title);
140 :     $template->param(menu => $menu);
141 :     $template->param(session => $session);
142 :     $template->param(logo => $logo);
143 :     $template->param(content => $content);
144 :    
145 :     # output the page
146 :     print header();
147 :     print $template->output();
148 :     }

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3