#!/usr/bin/perl -Tw use warnings; use strict; $|++; # file: index.cgi # Herve Saint-Amand # Universitaet des Saarlandes # Tue May 13 20:09:25 2008 # When we do Moses translation of Web pages there's a little tool frame at the # top of the screen. This script takes care of printing the frameset and that # top frame. It also invokes the main script with the proper URL param. # You're most probably not interested in the code that's in here. Have a look # a translate.cgi instead. That's where the meat is. #------------------------------------------------------------------------------ # includes use CGI; use CGI::Carp qw/fatalsToBrowser/; use URI::Escape; #------------------------------------------------------------------------------ # constants, global vars (my $SELF_URL = $ENV{QUERY_STRING}) =~ s![^/]*$!!; my $TRANSLATE_CGI = 'translate.cgi'; #------------------------------------------------------------------------------ # read CGI params my %params = %{{ url => undef, frame => undef, }}; my $cgi = new CGI; foreach my $p (keys %params) { $params{$p} = $cgi->param ($p) if (defined $cgi->param ($p)); } #------------------------------------------------------------------------------ # print out print "Content-Type: text/html\n\n"; print "\n" . " \n" . " $params{url} -- Moses translation\n" . " \n" . " \n"; if (!$params{url}) { print " \n" . "

Moses Web Interface

\n" . "
\n" . " \n" . " \n" . "
\n" . " \n"; } else { # check that we have a URL and it's absolute $params{url} = "http://$params{url}" unless ($params{url} =~ m!^[a-z]+://!); my $URL = uri_escape ($params{url}); if (!$params{frame}) { print " \n" . " \n" . " \n" . " \n"; } else { print " \n" . " \n" . " Moses translation of\n" . " $params{url}\n" . " \n" . " \n"; } } print "\n"; #------------------------------------------------------------------------------