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