]> matita.cs.unibo.it Git - helm.git/blob - helm/cgi/mkindex.pl
mkindex.pl use_webeqp.pl webeq.pl webeqp.pl : helm root from environment
[helm.git] / helm / cgi / mkindex.pl
1 #!/usr/bin/perl
2
3 my $HELM_CONFIGURATION_PREFIX = $ENV{"HELM_CONFIGURATION_PREFIX"};
4 my $HELM_CONFIGURATION_PATH =
5  $HELM_CONFIGURATION_PREFIX."/local/lib/helm/configuration.pl";
6  # next require defines: $helm_dir, $html_link, $dtd_dir, $uris_dbm
7  require $HELM_CONFIGURATION_PATH;
8
9 $baseuri0 = $dirname = $uri = $ENV{"REQUEST_URI"};
10
11 $dirname =~ s/$helm_url_path//;
12 $dirname = $helm_dir.$dirname;
13
14 $baseuri0 =~ s/$helm_url_path//;
15
16 opendir(DIR, $dirname);
17 @filenames = readdir(DIR);
18 closedir(DIR);
19
20 $output = "";
21 foreach $i (@filenames) {
22    if ($i eq "..") {
23       $output .= <<EOT;
24 <img border="0" src="/icons/back.gif" alt="[BACK]"> <a href="$uri$i">Parent Directory</a>
25 EOT
26    } elsif ($i !~ /^\./) {
27       # hidden files excluded
28       (undef,undef,$mode) = stat("$dirname$i");
29       if ($mode &= 16384) {
30          # directory
31          $output .= <<EOT;
32 <img border="0" src="/icons/folder.gif" alt="[DIR]"> <a href="$uri$i">$i</a>
33 EOT
34       } else {
35          # file
36          if ($i =~ /\.(con|var|ind)\.xml$/) {
37             my $i_without_xml = $i;
38             $i_without_xml =~ s/(.*)\.xml/$1/;
39             # cic file
40             my $baseuri = "cic:".$baseuri0;
41             $output .= <<EOT;
42 <img border="0" src="/icons/generic.red.gif" alt="[DIR]"> <a
43 href="$uri$i">$i</a> <a
44 href="$getheader_url?baseurl=$style_url&stylesheet1=rootcontent.xsl&stylesheet2=annotatedpres.xsl&xmluri=$baseuri$i_without_xml">MathML</a> <a href="$getheader_url?baseurl=$style_url&stylesheet1=rootcontent.xsl&stylesheet2=content_to_html.xsl&xmluri=$baseuri$i_without_xml">HTML</a> <a href="$webeq_url?mmlurl=$getheader_url?baseurl=$style_url&stylesheet1=rootcontent.xsl&stylesheet2=annotatedpres.xsl&xmluri=$baseuri$i_without_xml">WEBEQ</a> <a href="$webeqp_url?mmlurl=$getheader_url?baseurl=$style_url&stylesheet1=rootcontent.xsl&stylesheet2=annotatedpres.xsl&xmluri=$baseuri$i_without_xml">WEBEQ PRESENTATION ONLY</a>
45 EOT
46          } elsif ($i =~ /\.(con|var|ind)\.ann\.xml$/) {
47             my $i_without_xml = $i;
48             my $i_without_ann_and_xml = $i;
49             $i_without_xml =~ s/(.*)\.xml/$1/;
50             $i_without_ann_and_xml =~ s/(.*)\.ann\.xml/$1/;
51             # cic file
52             my $baseuri = "cic:".$baseuri0;
53             $output .= <<EOT;
54 <img border="0" src="/icons/text.gif" alt="[DIR]"> <a href="$uri$i">$i</a> <a href="$getheader_url?baseurl=$style_url&stylesheet1=rootcontent.xsl&stylesheet2=annotatedpres.xsl&xmluri=$baseuri$i_without_ann_and_xml&annuri=$baseuri$i_without_xml">MathML</a> <a href="$getheader_url?baseurl=$style_url&stylesheet1=rootcontent.xsl&stylesheet2=content_to_html.xsl&xmluri=$baseuri$i_without_ann_and_xml&annuri=$baseuri$i_without_xml">HTML</a> <a href="$webeq_url?mmlurl=$getheader_url?baseurl=$style_url&stylesheet1=rootcontent.xsl&stylesheet2=annotatedpres.xsl&xmluri=$baseuri$i_without_ann_and_xml&annuri=$baseuri$i_without_xml">WEBEQ</a> <a href="$webeqp_url?mmlurl=$getheader_url?baseurl=$style_url&stylesheet1=rootcontent.xsl&stylesheet2=annotatedpres.xsl&xmluri=$baseuri$i_without_ann_and_xml&annuri=$baseuri$i_without_xml">WEBEQ PRESENTATION ONLY</a>
55 EOT
56          } elsif ($i =~ /\.theory\.xml$/) {
57             my $i_without_xml = $i;
58             $i_without_xml =~ s/(.*)\.xml/$1/;
59             # theory file
60             my $baseuri = "theory:".$baseuri0;
61             $output .= <<EOT;
62 <img border="0" src="/icons/layout.gif" alt="[DIR]"> <a
63 href="$uri$i">$i</a> <a href="$getheader_url?baseurl=$style_url&stylesheet1=theory_content.xsl&stylesheet2=theory_pres.xsl&xmluri=$baseuri$i_without_xml">MathML</a> <a href="$getheader_url?baseurl=$style_url&stylesheet1=roottheory.xsl&stylesheet2=content_to_html.xsl&xmluri=$baseuri$i_without_xml">HTML</a>
64 EOT
65          } else {
66             # other file
67             $output .= <<EOT;
68 <img border="0" src="/icons/unknown.gif" alt="[DIR]"> <a href="$uri$i">$i</a>
69 EOT
70          }
71       }
72    }
73 }
74
75 print <<EOT;
76 Content-type: text/html
77
78 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
79 "http://www.w3.org/TR/REC-html40/loose.dtd">
80 <html>
81 <head>
82 <title>Index of $uri</title>
83 </head>
84 <body bgcolor="#ffffff" text="#000000">
85 <table><tr><td bgcolor="#ffffff" class="title">
86 <font size="+3" face="Helvetica,Arial,sans-serif"><b>Index of $uri</b></font>
87 </td></tr></table>
88 <hr noshade align="left" width="80%">
89 <pre>
90 $output
91 </pre>
92 <hr noshade align="left" width="80%">
93 </body>
94 </html>
95 EOT