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

Annotation of /FigWebServices/ShowTableFile.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (view) (download)

1 : parrello 1.1 #!/usr/bin/perl -w
2 :    
3 :     BEGIN {
4 :     # Print the HTML header.
5 :     print "CONTENT-TYPE: text/html\n\n";
6 :     }
7 :    
8 :     =head1 Show TBL File
9 :    
10 :     This is a simple script that displays a TBL file in an HTML table.
11 :    
12 :     This script supports the following CGI query parameters.
13 :    
14 :     =over 4
15 :    
16 :     =item Trace
17 :    
18 :     Trace level and list of trace modules to turn on, space-delimited. The
19 :     default is no tracing.
20 :    
21 :     =item TF
22 :    
23 :     C<1> to trace to a file, C<0> to trace to the web page itself. The
24 :     default is C<0>.
25 :    
26 :     =item fileName
27 :    
28 :     Absolute name and path of the file to display.
29 :    
30 :     =back
31 :    
32 :     =cut
33 :    
34 :     use strict;
35 :     use Tracer;
36 :     use CGI;
37 :     use Sprout;
38 :    
39 : parrello 1.3 my ($cgi, $varHash) = Tracer::ScriptSetup();
40 : parrello 1.1 eval {
41 :     # Only allow this from the debugging form.
42 :     if (Tracer::DebugMode) {
43 :     # Compute the file name.
44 :     my $fileName = $cgi->param('fileName');
45 :     # Open the file for input.
46 :     my $handle = Open(undef, "<$fileName");
47 :     # Start collecting output.
48 :     my @retVal = ();
49 :     push @retVal, $cgi->h3({align => "center"}, "Contents of $fileName.");
50 :     # Start the display table.
51 :     push @retVal, $cgi->start_table({ border => 2, align => "center"});
52 :     # Loop through the file, reading a line at a time.
53 :     while (my @cols = Tracer::GetLine($handle)) {
54 :     # Look for URLs. We need to convert them into links or the table will
55 :     # be a real pain to read.
56 :     my @cells = map { ($_ =~ /^http:/) ? $cgi->a({ href => $_ }, "link") : $_ } @cols;
57 :     # Format the result into a table row.
58 :     push @retVal, $cgi->Tr($cgi->td(\@cells));
59 :     }
60 :     # Close the table.
61 :     push @retVal, $cgi->end_table();
62 :     # Assemble it for display.
63 :     $varHash->{results} = join("\n", @retVal, "");
64 :     } else {
65 :     $varHash->{results} = $cgi->p("Invalid use of script.");
66 :     }
67 :     };
68 :     if ($@) {
69 :     my $errorMessage = $@;
70 :     Trace("Script Error: $errorMessage") if T(0);
71 :     $varHash->{results} = $cgi->h3("Script Error: $errorMessage");
72 :     }
73 : parrello 1.3 Tracer::ScriptFinish("Html/Basic_tmpl.html", $varHash);
74 : parrello 1.1

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3