[Bio] / FigKernelPackages / ListServerScripts.pm Repository:
ViewVC logotype

Annotation of /FigKernelPackages/ListServerScripts.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (view) (download) (as text)

1 : parrello 1.1 #!/usr/bin/perl -w
2 :    
3 :     package ListServerScripts;
4 :    
5 :     use strict;
6 :     use Tracer;
7 :     use CGI;
8 :     no warnings qw(once);
9 :    
10 :     =head1 List Server Scripts
11 :    
12 :     The main method of this package will generate a web page that lists the
13 :     current server scripts. The scripts will be determined by searching the
14 :     B<$FIG_Config::bin> directory for files with an C<svr_> prefix in the name
15 :     and a C<SAS Component> identifier at the beginning of the file. If there is
16 :     also evidence of POD documentation, a link to the script will be generated
17 :     in the output.
18 :    
19 :     =head2 Constants
20 :    
21 :     =head3 MAX_LINES
22 :    
23 :     Maximum number of lines to read when searching script files.
24 :    
25 :     =cut
26 :    
27 :     use constant MAX_LINES => 50;
28 :    
29 :     =head2 Methods
30 :    
31 :     =head3 main
32 :    
33 :     ListServerScripts::main();
34 :    
35 :     Run through the server scripts and generate a web page displaying links to their
36 :     documentation.
37 :    
38 :     =cut
39 :    
40 :     sub main {
41 :     # Start with the CGI and HTML headers.
42 :     print CGI::header();
43 :     print CGI::start_html(-title => "Server Scripts List",
44 :     -style => { src => "http://servers.nmpdr.org/sapling/Html/css/ERDB.css" });
45 :     # We'll accumulate HTML output in here.
46 :     my @retVal;
47 :     # Put in the introductory text.
48 :     push @retVal, CGI::h1("Server Scripts");
49 :     push @retVal, CGI::p("All scripts read from the standard input and write to the " .
50 :     "standard output. File names are never specified on the command " .
51 :     "line. In general, they accept as input a tab-delimited file and " .
52 :     "operate on the last column of the input. This allows multiple " .
53 :     "commands to be strung together using a pipe.");
54 :     # Begin the list of scripts.
55 :     push @retVal, CGI::start_ul();
56 :     # Get the server script names.
57 :     my @scripts = sort grep { $_ =~ /^svr_/ } Tracer::OpenDir($FIG_Config::bin);
58 :     # Loop through them.
59 :     for my $script (@scripts) {
60 :     # Open the script for input.
61 :     my $ih = Open(undef, "<$FIG_Config::bin/$script");
62 :     # We'll keep the current input line in here.
63 :     my $line;
64 :     # Look for a SAS component indicator.
65 :     my $sasFound = 0;
66 :     while (! eof $ih && $ih->input_line_number() < MAX_LINES && ! $sasFound) {
67 :     $line = <$ih>;
68 :     if ($line =~ /\s+SAS\s+component/i) {
69 :     $sasFound = 1;
70 :     }
71 :     }
72 :     if ($sasFound) {
73 :     # This is one of our files. Look for a head1 line.
74 :     $line = <$ih> until (eof $ih || $line =~ /^=head1/);
75 :     if (! eof $ih) {
76 :     # We found the head1 line. We now want to find the first
77 :     # line that could be a summary.
78 :     $line = <$ih> while (! eof $ih && $line =~ /^(?:\s|=)/);
79 :     # Build the lines in this region into a summary.
80 :     my $summary = "";
81 :     until (eof $ih || $line =~ /^\s/) {
82 :     $summary .= $line;
83 :     $line = <$ih>;
84 :     }
85 :     # Create a description of this script.
86 : parrello 1.2 push @retVal, CGI::li(CGI::a({ href => "http://pubseed.theseed.org/sapling/server.cgi?pod=$script.pl"},
87 : parrello 1.1 $script) . ": $summary");
88 :     }
89 :     }
90 :     }
91 :     # Close the list of scripts.
92 :     push @retVal, CGI::end_ul();
93 :     # Output the whole thing.
94 :     print join("\n", @retVal);
95 :     # Close the page.
96 :     print CGI::end_html();
97 :     }
98 :    
99 :     1;

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3