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

Annotation of /FigWebServices/ErdbDocWidget.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (view) (download)

1 : parrello 1.1 #!/usr/bin/perl -w
2 :    
3 :     #
4 :     # Copyright (c) 2003-2006 University of Chicago and Fellowship
5 :     # for Interpretations of Genomes. All Rights Reserved.
6 :     #
7 :     # This file is part of the SEED Toolkit.
8 :     #
9 :     # The SEED Toolkit is free software. You can redistribute
10 :     # it and/or modify it under the terms of the SEED Toolkit
11 :     # Public License.
12 :     #
13 :     # You should have received a copy of the SEED Toolkit Public License
14 :     # along with this program; if not write to the University of Chicago
15 :     # at info@ci.uchicago.edu or the Fellowship for Interpretation of
16 :     # Genomes at veronika@thefig.info or download a copy from
17 :     # http://www.theseed.org/LICENSE.TXT.
18 :     #
19 :    
20 :     use strict;
21 :     use Tracer qw(:DEFAULT PrintLine);
22 :     use ERDB;
23 :     use ERDBPDocPage;
24 : parrello 1.2 use ERDBExtras;
25 : parrello 1.1
26 :     =head1 ErdbDocWidget Script
27 :    
28 :     This is a small script that generates the documentation widget for an [[ErdbPm]]
29 :     database. It is designed to fit inside an embedded frame. The widget appears as
30 :     a two-column table with a scrolling select control on the left and the
31 :     documentation for the selected component on the right.
32 :    
33 :     The following CGI parameters are used.
34 :    
35 :     =over 4
36 :    
37 :     =item database
38 :    
39 :     Name of the database to document.
40 :    
41 : parrello 1.4 =item xmlFileName
42 :    
43 :     Name of the XML file to document. If this option is specified, it overrides
44 :     B<database>. In this case, it is presumed the documentation is for a database
45 :     in development rather than a live database.
46 :    
47 : parrello 1.1 =item rows
48 :    
49 :     The estimated number of rows to display in the select box in order to make the
50 :     widget fit comfortably inside the frame.
51 :    
52 :     =back
53 :    
54 :     =cut
55 :    
56 :     # Get the CGI query object.
57 :     my $cgi = CGI->new();
58 :     # Start the output page.
59 :     print CGI::header();
60 :     print CGI::start_html(-title => 'ERDB Database Documenter',
61 : parrello 1.2 -style => { src => "$ERDBExtras::css_dir/ERDB.css" },
62 :     -script => { src => "$ERDBExtras::js_dir/ERDB.js" });
63 : parrello 1.1 # Insure we recover from errors.
64 :     eval {
65 :     # Get the parameters.
66 : parrello 1.3 my $database = $cgi->param('database') || 'Sapling';
67 : parrello 1.2 my $height = $cgi->param('height') || 900;
68 : parrello 1.4 my $xmlFileName = $cgi->param('xmlFileName');
69 : parrello 1.1 # Get the datanase object.
70 : parrello 1.4 my $erdb;
71 :     if ($xmlFileName) {
72 :     # Yes, get a pseudo-database object for that XML file.
73 :     $erdb = ERDB->new(undef, $xmlFileName);
74 :     } else {
75 :     # No, get the live database.
76 :     $erdb = ERDB::GetDatabase($database);
77 :     }
78 : parrello 1.1 # Get a page creator.
79 :     my $page = ERDBPDocPage->new(dbObject => $erdb);
80 :     # Create the body HTML.
81 : parrello 1.2 my $html = CGI::div({ class => 'doc' }, $page->DocPage(boxHeight => $height));
82 : parrello 1.1 # Output it.
83 :     PrintLine($html);
84 :     };
85 :    
86 :     if ($@) {
87 :     # Here we have a fatal error. Save the message.
88 :     my $errorText = "SCRIPT ERROR: $@";
89 :     # Issue a feed event.
90 :     Warn($errorText);
91 :     # Output the error message.
92 :     PrintLine CGI::pre($errorText);
93 :     }
94 :     # Close the page.
95 :     PrintLine CGI::end_html();
96 :    
97 :     1;

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3