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

Diff of /FigWebServices/ProcessTemplate.cgi

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1, Wed Feb 21 13:14:36 2007 UTC revision 1.2, Sat May 5 02:19:38 2007 UTC
# Line 1  Line 1 
1  #!/usr/bin/perl -w  #!/usr/bin/perl -w
2    
 BEGIN {  
     # Print the header.  
     print "CONTENT-TYPE: text/plain\n\n";  
 }  
   
3  =head1 Produce Template  =head1 Produce Template
4    
5  This script applies prompt values to a template. The template is passed in via a  This script applies prompt values to a template. The template is passed in via a
6  file name, and the template contains special tokens delimited by double brackets  file name, and the template contains special tokens delimited by double brackets
7  with a percent sign (e.g. C<[[%ask1:Method Name]]>). The data from the CGI  with a percent sign (e.g. C<[[%ask1:Method Name]]>). The data from the CGI
8  parameters is used to process the tokens, and the result is returned as a  parameters is used to process the tokens, and the result is returned as a
9  plain text web page.  downloadable file.
10    
11  This script supports the following CGI query parameters.  This script supports the following CGI query parameters.
12    
# Line 39  Line 34 
34    
35  my ($cgi, $varHash) = ScriptSetup();  my ($cgi, $varHash) = ScriptSetup();
36  eval {  eval {
37        # Get the template file name.
38        my $fileName = $cgi->param('templateFile');
39        my $fileTitle = ($fileName =~ m#-(\w+)\.# ? "NewFile.$1" : "NewFile.pm");
40        print $cgi->header(-type => 'application/octet-stream',
41                           -attachment => $fileTitle);
42        # Put us in binary mode so that the output doesn't do screwy stuff with new-lines.
43        # The resulting file will be encoded for Unix.
44        binmode(STDOUT);
45      # Extract the ask and flag parameters.      # Extract the ask and flag parameters.
46      my @names = $cgi->param;      my @names = $cgi->param;
47      my %parms = map { $_ => $cgi->param($_) } grep { $_ =~ /^(ask|flag)/ } @names;      my %parms = map { $_ => $cgi->param($_) } grep { $_ =~ /^(ask|flag)/ } @names;
# Line 50  Line 53 
53      # Denote we haven't stopped.      # Denote we haven't stopped.
54      my $going = 1;      my $going = 1;
55      # Slurp in the template.      # Slurp in the template.
     my $fileName = $cgi->param('templateFile');  
56      my @lines = Tracer::GetFile($fileName);      my @lines = Tracer::GetFile($fileName);
57      # Loop through the template lines, generating code.      # Loop through the template lines, generating code.
58      for my $line (@lines) {      for my $line (@lines) {

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3