]> matita.cs.unibo.it Git - helm.git/blob - helm/cgi/webeqp.pl
Requires and Provides now fixed
[helm.git] / helm / cgi / webeqp.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 require HTTP::Request;
10 require LWP::UserAgent;
11 use CGI;
12
13 $url = $ENV{"REQUEST_URI"};
14 $url =~ s/.*mmlurl=(.*)/$1/;
15
16 $content = "";
17
18 $ua = LWP::UserAgent->new;
19 $request = HTTP::Request->new(GET => "$url");
20 $response = $ua->request($request, \&callback);
21
22 $content =~ s/\r//sg;
23 $content =~ s/\n/ /sg;
24 $content =~ s/<!DOCTYPE[^>]*>//sg;
25 $content =~ s/<\?xml[^?]*\?>//sg;
26 $content =~ s/"/'/g;
27 $content =~ s/&/&amp;/g;
28 $content =~ s/<m:/</g;
29 $content =~ s/<\/m:/<\//g;
30 $content =~ s/<math[^>]*>/<math>/sg;
31 $content =~ s/(<\/?semantics[^>]*>)/<!-- $1 -->/sg;
32 $content =~ s/(<annotation-xml)/<!-- $1/sg;
33 $content =~ s/(<\/annotation-xml>)/$1 -->/sg;
34 $content =~ s/<mo helm:xref='[^']*' xlink:href='([^']*)'>([^<]*)<\/mo>/<maction actiontype='href' other='$use_webeqp_url?uri=$1'><mo>$2<\/mo><\/maction>/sg;
35 $content =~ s/<mi helm:xref='[^']*' xlink:href='([^']*)'>([^<]*)<\/mi>/<maction actiontype='href' other='$use_webeqp_url?uri=$1'><mi>$2<\/mi><\/maction>/sg;
36 $content =~ s/helm:xref='[^']*'//sg;
37 $content =~ s/xmlns:helm='[^']*'//sg;
38 $content =~ s/xlink:href='[^']*'//sg;
39 $content =~ s/xmlns:xlink='[^']*'//sg;
40 $content =~ s/<mchar name='([^']*)' \/>/&$1;/sg;
41
42 print <<EOT;
43 Content-type: text/html
44
45 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
46 "http://www.w3.org/TR/REC-html40/loose.dtd">
47 <html>
48 <head>
49 <title>Generato in automatico a partire da $url</title>
50 </head>
51 <body bgcolor="#ffffff" text="#000000">
52 <applet codebase="http://www.webeq.com/WebEQ/2.2/classes" code="webeq.Main"
53 +width=600 height=2000 align=middle>
54 <param name=eq value="$content">
55 <param name=color value="#cccccc">
56 <param name=parser value="mathml">
57 <param name=size value="14">
58 </applet>
59 </body>
60 </html>
61 EOT
62
63 #=========================
64
65 sub callback
66
67  my ($data) = @_;
68  $content .= $data;
69 }