Ignore:
Timestamp:
2001-06-19T14:26:54+12:00 (23 years ago)
Author:
jrm21
Message:

gsConvert now knows about rtftohtml package. wv config file is now in
etc/packages/, not etc/wv/.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/bin/script/gsConvert.pl

    r2512 r2574  
    5656    print STDERR "              or text using third-party programs.\n\n";
    5757    print STDERR "  usage: $0 [options] filename\n";
    58     print STDERR "  options:\n\t-type\tdoc|pdf|ps\n\t-output\thtml|text\n";
     58    print STDERR "  options:\n\t-type\tdoc|pdf|ps|rtf\n\t-output\thtml|text\n";
    5959    print STDERR "\t-timeout\t<max cpu seconds>\n";
    6060    exit(1);
     
    7070    # read command-line arguments
    7171    if (!parsargv::parse(\@ARGV,
    72              'type/(doc|pdf|ps)/', \$input_type,
     72             'type/(doc|pdf|ps|rtf)/', \$input_type,
    7373             'output/(html|text)/', \$output_type,
    7474             'timeout/\d+/0',\$timeout,
     
    339339
    340340    my $wv_conf = &util::filename_cat($ENV{'GSDLHOME'}, "etc",
    341                       "wv", "wvHtml.xml");
     341                      "packages", "wv", "wvHtml.xml");
    342342   
    343343    my $cmd = "";
     
    377377
    378378# Attempt to convert an RTF document to html with rtftohtml
    379 #
    380 # rtf2html isn't distributed with Greenstone because it is not
    381 # distributed under the GPL.  If you know of a better solution,
    382 # please let me know.
    383379
    384380sub rtf_to_html {
    385381    my ($input_filename, $output_filestem) = @_;
    386382
    387     # we'll give up already if using Windows
    388     return 0 if $ENV{'GSDLOS'} =~ /^windows$/i;
    389 
    390383    # formulate the command
    391     my $r_cmd = &util::filename_cat($ENV{'GSDLHOME'}, "packages", "unix",
    392                     "rtf2html", "rtf2html", "rtf2html");
    393     $r_cmd = "rtf2html" unless (-e "$r_cmd");
    394     return 0 unless (-e "$r_cmd");
    395384    $cmd = "";
    396385    if ($timeout) {$cmd = "ulimit -t $timeout;";}
    397     $cmd .= "$r_cmd";
    398     $cmd .= " \"$input_filename\" > \"$output_filestem.html\" 2>\"$output_filestem.err\"";
     386    $cmd .= "rtftohtml";
     387
     388    # it automatically uses $output_filestem.html
     389    $cmd .= " \"$input_filename\"";
     390
     391    $cmd .= " 2>\"$output_filestem.err\""
     392        unless $ENV{'GSDLOS'} =~ /^windows$/i;
     393
    399394
    400395    # execute the command
     
    404399    }
    405400
     401    # this will probably give a warning under windows...
     402    &util::rm("$output_filestem.err");
     403
    406404    # Was the conversion successful?
    407405    if (-e "$output_filestem.html") {
    408     open(TMP, "$output_filestem.html");
    409     $line = <TMP>;
    410     close(TMP);
    411     if ($line && $line =~ /DOCTYPE HTML/) {
    412         &util::rm("$output_filestem.err");
    413         return 1;
    414     } else {
    415         # An error of some sort occurred
    416         &util::rm("$output_filestem.html");
    417         &util::rm("$output_filestem.err");
    418     }
    419     }
     406    return 1;
     407    }
     408
    420409    return 0;
    421410}
Note: See TracChangeset for help on using the changeset viewer.