Commit 27b8dc17 authored by Maxime Lefrançois's avatar Maxime Lefrançois
Browse files

corrected script so it works on saref.etsi.org

parent 09daa6fe
Loading
Loading
Loading
Loading
+0 −3
Original line number Original line Diff line number Diff line
@@ -7,10 +7,7 @@
          <h2><strong><!--#echo var="REDIRECT_STATUS" -->.</strong> That's an error.</h2>
          <h2><strong><!--#echo var="REDIRECT_STATUS" -->.</strong> That's an error.</h2>
          <p>An appropriate representation of the requested resource could not be found on this server.</p>
          <p>An appropriate representation of the requested resource could not be found on this server.</p>
          <p>Available variants:</p>
          <p>Available variants:</p>
          <!--  printenv -->

          <!--#include virtual="variants.pl" -->
          <!--#include virtual="variants.pl" -->

        </div>
        </div>
      </div>
      </div>
    </div>
    </div>
+25 −16
Original line number Original line Diff line number Diff line
###!/usr/bin/perl
#!/usr/bin/perl -w


## the next line should point to the perl.exe executable when executed on windows.
## the next line should point to the perl.exe executable when executed on windows.
## it should replace the first line
## it should replace the first line
#!C:/Perl64/bin/perl.exe
#!C:/Perl64/bin/perl.exe


# script written by: maxime.lefrancois@emse.fr
# script written by: maxime.lefrancois@emse.fr
use strict;
use warnings;
use Try::Tiny;


print "Content-type: text/html\n\n";
print "Content-type: text/html\n\n";


# foreach (sort keys %ENV) { 
#   print "$_  =  $ENV{$_}<br/>"; 
# }

my %h = ( "html" => "text/html",
my %h = ( "html" => "text/html",
  "ttl" => "text/turtle" ,
  "ttl" => "text/turtle" ,
  "rdf" => "application/rdf+xml" ,
  "rdf" => "application/rdf+xml" ,
@@ -20,14 +19,24 @@ my %h = ( "html" => "text/html",
  "nt" => "application/n-triples" ,
  "nt" => "application/n-triples" ,
  );
  );



try {
  "$ENV{\"DOCUMENT_ROOT\"}$ENV{\"REDIRECT_URL\"}" =~ /^(.*\/)([^\/]+)$/ ;
  "$ENV{\"DOCUMENT_ROOT\"}$ENV{\"REDIRECT_URL\"}" =~ /^(.*\/)([^\/]+)$/ ;
  my $DIR = $1;
  my $DIR = $1;
  my $filename = $2;
  my $filename = $2;
opendir(DIR, $1 );
  opendir(DIR, $1 ) or die "opendir() failed: $!";
@files = grep(/^$filename\.[^\.]+$/,readdir(DIR));
  my @files = grep(/^$filename\.[^\.]+$/,readdir(DIR));
  closedir(DIR);
  closedir(DIR);
foreach $file (@files) {
  foreach my $file (@files) {
    $file =~ /^$filename\.([^\.]+)$/;
    $file =~ /^$filename\.([^\.]+)$/;
  $ext = $1;
    my $ext = $1;
    print " <li><a href=\"$ENV{\"REDIRECT_URL\"}.$1\">$filename.$ext</a>, type $h{$ext}</li>\n";
    print " <li><a href=\"$ENV{\"REDIRECT_URL\"}.$1\">$filename.$ext</a>, type $h{$ext}</li>\n";
  }
  }
} catch {
  "$ENV{\"DOCUMENT_ROOT\"}$ENV{\"REDIRECT_URL\"}" =~ /^(.*\/)([^\/]+)$/ ;
  my $DIR = $1;
  my $filename = $2;
  print "<li><a href=\"$ENV{\"REDIRECT_URL\"}.html\">$filename.html</a>, type text/html (probably?)</li>\n";
  print "<li><a href=\"$ENV{\"REDIRECT_URL\"}.ttl\">$filename.ttl</a>, type text/turtle (maybe?)</li>\n";
  print "<li><a href=\"$ENV{\"REDIRECT_URL\"}.rdf\">$filename.rdf</a>, type application/rdf+xml (feeling lucky?)</li>\n";
};
 No newline at end of file