]> matita.cs.unibo.it Git - helm.git/blob - helm/cgi/webeq.pl
f858f7b722af696a37af60af95832abf123b0fe5
[helm.git] / helm / cgi / webeq.pl
1 #!/usr/bin/perl
2
3 require HTTP::Request;
4 require LWP::UserAgent;
5 use CGI;
6
7 $url = $ENV{"REQUEST_URI"};
8 $url =~ s/.*mmlurl=(.*)/$1/;
9
10 $content = "";
11
12 $ua = LWP::UserAgent->new;
13 $request = HTTP::Request->new(GET => "$url");
14 $response = $ua->request($request, \&callback);
15
16 $content =~ s/\r//sg;
17 $content =~ s/\n/ /sg;
18 $content =~ s/<!DOCTYPE[^>]*(.*)>/$1/sg;
19 $content =~ s/<m:/</g;
20 $content =~ s/<\/m:/<\//g;
21 $content =~ s/<math[^>]*>/<math>/sg;
22 $content =~ s/"/'/g;
23 $content =~ s/&/&amp;/g;
24
25 print <<EOT;
26 Content-type: text/html
27
28 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
29 "http://www.w3.org/TR/REC-html40/loose.dtd">
30 <html>
31 <head>
32 <title>Generato in automatico a partire da $url</title>
33 </head>
34 <body bgcolor="#ffffff" text="#000000">
35 <applet codebase="http://www.webeq.com/WebEQ/2.2/classes" code="webeq.Main"
36 +width=600 height=2000 align=middle>
37 <param name=eq value="$content">
38 <param name=color value="#cccccc">
39 <param name=parser value="mathml">
40 <param name=size value="14">
41 </applet>
42 </body>
43 </html>
44 EOT
45
46 #=========================
47
48 sub callback
49
50  my ($data) = @_;
51  $content .= $data;
52 }