[system] / trunk / webwork / system / cgi / cgi-scripts / source.pl Repository:
ViewVC logotype

View of /trunk/webwork/system/cgi/cgi-scripts/source.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6 - (download) (as text) (annotate)
Fri Jun 15 14:29:57 2001 UTC (11 years, 11 months ago) by gage
File size: 1698 byte(s)
development version dev-1-7-01 from /ww/webwork/development 15-June-2001

    1 #!/usr/local/bin/perl
    2 ############################################################
    3 # File: source.pl
    4 # Copyright:  WeBWorK 2000  all rights reserved
    5 # Description:  This script will read, interpret, and output .html files
    6 #                    containing .pg source code
    7 ############################################################
    8 
    9 
   10 use lib '/ww/webwork/gage_system/webwork/system/lib/'; # mainWeBWorKDirectory
   11 use strict;
   12 
   13 use CGI qw(:standard);
   14 use Global;
   15 
   16 &CGI::ReadParse;
   17 my %inputs = %main::in;
   18 
   19 # get information from CGI inputs  (see also below for additional information)
   20   my $Course      = param('course');
   21 
   22 # establish environment for this script
   23   &Global::getCourseEnvironment($Course);
   24 
   25   my $htmlDirectory         = getCourseHtmlDirectory();
   26   my $htmlURL               = getCourseHtmlURL();
   27 
   28 # get the rest of the information from the CGI script
   29 my  $fileName = param('displayPath');
   30 
   31 $fileName =~ /\.([^.]+)$/;
   32 my $fileType = $1;
   33 
   34 my $headerString = <<EOT;
   35 <HTML>
   36 <BODY BGCOLOR = "#ffffff">
   37 <PRE>
   38 EOT
   39 
   40 my $footerString = <<EOT;
   41 </pre>
   42 </body>
   43 </html>
   44 EOT
   45 
   46 
   47 
   48 
   49 if ($fileType eq 'html') {
   50     my $filePath =  "${htmlDirectory}$fileName";
   51     open(INPUT, "<$filePath")||  print "content-type: text/plain\n\nCan't open $filePath\n";
   52     print "content-type: text/html\n\n";
   53     my $input ="";
   54     my $lineNumber = 0;
   55     print $headerString;
   56     #print "$filePath <br>";
   57     while (<INPUT>) {
   58         $input = $_;
   59         $input =~ s/</&lt;/g;
   60         $input =~ s/>/&gt;/g;
   61     print sprintf("%5.0d",++$lineNumber),": $input";
   62     }
   63     print $footerString;
   64   close(INPUT);
   65 } else {
   66   &Global::error("Can't handle |$fileType| filetype yet");
   67 }
   68 
   69 
   70 exit;
   71 

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9