]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/http_getter/http_getter.pl.in
HELM_DTD_DIR now also used
[helm.git] / helm / http_getter / http_getter.pl.in
index 67475764295e11af7c71dcaa56fa64899debae7e..addd81dccc1a2213455c10188072635257dd5985 100755 (executable)
@@ -34,6 +34,10 @@ if (defined ($HELM_LIB_DIR)) {
    $HELM_LIB_PATH = $DEFAULT_HELM_LIB_DIR."/configuration.pl";
 }
 
+# Let's override the configuration file
+$styles_dir = $ENV{"HELM_STYLE_DIR"} if (defined ($ENV{"HELM_STYLE_DIR"}));
+$dtd_dir = $ENV{"HELM_DTD_DIR"} if (defined ($ENV{"HELM_DTD_DIR"}));
+
 # <ZACK>: TODO temporary, move this setting to configuration file
 # set the cache mode, may be "gzipped" or "normal"
 my $cachemode = $ENV{'HTTP_GETTER_CACHE_MODE'} || 'gzipped';
@@ -219,7 +223,7 @@ EOT
             print "DTD: $inputuri ==> ($filename)\n";
             if (stat($filename)) {
                print "Using local copy\n";
-               open(FD, $filename);
+               open(FD, $filename) or die "Cannot open $filename\n";
                $cont = "";
                while(<FD>) { $cont .= $_; }
                close(FD);
@@ -227,6 +231,20 @@ EOT
             } else {
                die "Could not find DTD!";
             }
+         } elsif ($http_method eq 'GET' and $http_path eq "/getxslt") {
+            my $filename = $inputuri;
+            $filename = $styles_dir."/".$filename;
+            print "XSLT: $inputuri ==> ($filename)\n";
+            if (stat($filename)) {
+               print "Using local copy\n";
+               open(FD, $filename) or die "Cannot open $filename\n";
+               $cont = "";
+               while(<FD>) { $cont .= $_; }
+               close(FD);
+               answer($c,$cont);
+            } else {
+               die "Could not find XSLT!";
+            }
         } elsif ($http_method eq 'GET' and $http_path eq "/conf") {
             my $quoted_html_link = $html_link;
             $quoted_html_link =~ s/&/&amp;/g;
@@ -346,7 +364,7 @@ sub download
        if ($localfname =~ /\.xml\.gz$/) {      # deflating cached file and return it
                $cont = gunzip($localfname);
        } elsif ($localfname =~ /\.xml$/) {     # just return cached file
-               open(FD, $localfname);
+               open(FD, $localfname) or die "Cannot open $localfname";
                while(<FD>) { $cont .= $_; }
                close(FD);
        } else {        # error
@@ -365,7 +383,7 @@ sub download
 # <gzip>
        print "Storing the $str file\n";
        mkdirs($filename);
-       open(FD, ">".$filename.".tmp");
+       open(FD, ">".$filename.".tmp") or die "Cannot open $filename.tmp\n";
        print FD $cont;
        close(FD);
 
@@ -378,7 +396,7 @@ sub download
                $cont = gunzip($filename);
        } elsif (($cachemode eq 'normal') and ($resourcetype eq 'gzipped')) {   # deflate cache entry
                                                                                                                                                        # and update $cont
-               open(FD, "> $basefname");
+               open(FD, "> $basefname") or die "cannot open $basefname\n";
                $cont = gunzip($filename.".tmp");
                print FD $cont;
                close(FD);