#!@FULL_PERL_EXE@ -w # Need to specify the full path of Perl above, e.g. for Windows something like #!C:\\Perl32\\bin\\perl -w use strict; # Set this to 1 to work around IIS 6 craziness my $iis6_mode = 0; # IIS 6: for some reason, IIS runs this script with the working directory set to the Greenstone # directory rather than the cgi-bin directory, causing lots of stuff to fail if ($iis6_mode) { # Change into cgi-bin directory chdir("cgi-bin"); } # We use require and an eval here (instead of "use") to catch any errors loading the module (for IIS) eval("require \"gsdlCGI.pm\""); if ($@) { print STDOUT "Content-type:text/plain\n\n"; print STDOUT "ERROR: $@\n"; exit 0; } sub main { # $ENV{'QUERY_STRING'} = "a=set-import-metadata&c=espresso-music&d=HASH012d6f72cde5dc48162f4a1d.1&metaname=annotation&metapos=0&metavalue=adfadfad"; # $ENV{'QUERYSTRING'} = "a=set-import-metadata&c=espresso-music&d=HASH012d6f72cde5dc48162f4a1d.1&metaname=annotation&metapos=0&metavalue=adfadfad"; # $ENV{'REQUEST_METHOD'} = "GET"; my $gsdl_cgi = new gsdlCGI(); # Load the Greenstone modules that we need to use $gsdl_cgi->setup_gsdl(); my $gsdlhome = $ENV{'GSDLHOME'}; $gsdl_cgi->checked_chdir($gsdlhome); ## require cgiactions::metadataaction; # Useful debug statement for seeing what packages have been included #### printf("%-45s%-s\n",$_,$INC{$_}) foreach (sort keys %INC); $gsdl_cgi->parse_cgi_args(); # We don't want the gsdlCGI module to return errors and warnings in XML $gsdl_cgi->{'xml'} = 0; my $collect = $gsdl_cgi->clean_param("c"); my $cl = $gsdl_cgi->clean_param("cl"); # Establish collect_dir using defining 'site' along the way if GS3 my $site = undef; my $isGSDL2 = undef; if ($gsdl_cgi->greenstone_version() == 2) { $isGSDL2 = 1; } else { $isGSDL2 = 0; # GS3 (and possible future versions) make use of 'site' $site = $gsdl_cgi->clean_param("site"); if (!defined $site) { $gsdl_cgi->generate_error("No site specified."); } $gsdl_cgi->delete("site"); } my $collect_dir = $gsdl_cgi->get_collection_dir($site); my $fn = $gsdl_cgi->clean_param("fn"); # frame number if (defined $fn) { my $json_str = $gsdl_cgi->param("json"); my $output_dir = &util::filename_cat($collect_dir,$collect,"export"); if (!-d $output_dir) { &util::mk_dir($output_dir); } my $frame_filename = &util::filename_cat($output_dir,"$fn.exp"); if (open(FOUT,">$frame_filename")) { print FOUT $json_str; close(FOUT); # write out next free frame num $gsdl_cgi->generate_message("html-to-expeditee saved frame $fn"); } else { $gsdl_cgi->generate_error("Failed to open $frame_filename for output"); } } else { my $html_form = < HTML to Expeditee Frames
Convert the collection to Expeditee frames by traversing the classifier

EOT print "Content-type:text/html\n\n"; print $html_form; } } &main();