X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fcgi%2Fmkindexcic.pl;fp=helm%2Fcgi%2Fmkindexcic.pl;h=6f816d3271a660d4d28348ce8eae36cd5ffbf530;hb=d122e00855f9f44ac0d268e96cbe7b3dccd04db1;hp=0000000000000000000000000000000000000000;hpb=64d3512db52983e2a267bf3f4542b5cf2bad225d;p=helm.git diff --git a/helm/cgi/mkindexcic.pl b/helm/cgi/mkindexcic.pl new file mode 100755 index 000000000..6f816d327 --- /dev/null +++ b/helm/cgi/mkindexcic.pl @@ -0,0 +1,119 @@ +#!/usr/bin/perl + +# First of all, let's load HELM configuration +use Env; +my $HELM_LIB_DIR = $ENV{"HELM_LIB_DIR"}; +# this should be the only fixed constant +my $DEFAULT_HELM_LIB_DIR = "/projects/helm/on-line/local/lib/helm"; +if (defined ($HELM_LIB_DIR)) { + $HELM_LIB_PATH = $HELM_LIB_DIR."/configuration.pl"; +} else { + $HELM_LIB_PATH = $DEFAULT_HELM_LIB_DIR."/configuration.pl"; +} + +# next require defines: $helm_dir, $html_link, $dtd_dir, $uris_dbm +require $HELM_LIB_PATH; + +use URI::Escape; +use LWP::UserAgent; +use CGI; + +my $cgi = new CGI($ENV{"REQUEST_URL"}); +$uri = $cgi->param('cicuri'); +$uri =~ s/(.*)\/$/$1/; # Remove a final slash if present +$uri .= "/"; # Put a final slash +$myurl = $cgi->url(); + +$cont = ""; # modified by side-effect by &callback +my $ua = LWP::UserAgent->new; +my $request = HTTP::Request->new(GET => $getter_url."ls?format=txt&baseuri=".$uri); +my $response = $ua->request($request, \&callback); + +@filenames = split(/\n/, $cont); + +my $uridotdot = $uri; +$uridotdot =~ s/(.*)\/.+/$1/; +if ($uri ne "cic:/") { + # Let's print the link to the parent directory + $output = < +[BACK] +Parent Directory + +EOT +} + +foreach $i (@filenames) { + my ($type,$name) = split(/,/, $i); + if ($type eq "dir") { + $output .= < +[DIR] +$name + + +EOT + } elsif ($type eq "object") { + if ($name =~ /\.(con|var|ind)(\.types)?$/) { + # cic file + $output .= < +[DIR] +$name + +EOT + } elsif ($name =~ /\.(con|var|ind)\.ann$/) { + my $name_without_ann = $name; + $name_without_ann_and_xml =~ s/(.*)\.ann/$1/; + # cic file + $output .= < +[DIR] +$name + +EOT + } else { + $output .= < +[DIR] +$name + +EOT + } + } else { + $output .= < +[DIR] +$name + +EOT + } +} + +print < + + +Index of $uri + + + + +$output +
+
+ + +EOT + +#================================ + +sub callback +{ + my ($data) = @_; + $cont .= $data; +}