Index: gs3-extensions/html-to-expeditee/trunk/src/src/cgi-bin/html-to-expeditee.pl.in
===================================================================
--- gs3-extensions/html-to-expeditee/trunk/src/src/cgi-bin/html-to-expeditee.pl.in	(revision 24925)
+++ gs3-extensions/html-to-expeditee/trunk/src/src/cgi-bin/html-to-expeditee.pl.in	(revision 24926)
@@ -30,64 +30,9 @@
 
 
-sub main
+sub generate_html_form
 {
-
-#    $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::HtmlToExpediteeAction;
-    
-    # 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.");
-	}
-    }
-
-    my $fn = $gsdl_cgi->clean_param("fn");     # frame number
-
-    if (defined $fn) {
-
-	my $action = new HtmlToExpediteeAction($gsdl_cgi,$iis6_mode);
-
-	$action->do_action();
-
-
-    }
-    else {
-	
-	my $html_form = <<EOT;
+    my ($isGSDL2,$site,$collect,$cl) = @_;
+
+    my $html_form = <<EOT;
 <html>
   <head>
@@ -325,8 +270,69 @@
 EOT
 
-
-        print "Content-type:text/html\n\n";
-        print $html_form;
-
+    print "Content-type:text/html\n\n";
+    print $html_form;
+}
+
+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::HtmlToExpediteeAction;
+    
+    # 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 $fn = $gsdl_cgi->clean_param("fn");     # frame number
+
+    if (defined $fn) {
+
+	my $action = new HtmlToExpediteeAction($gsdl_cgi,$iis6_mode);
+
+	$action->do_action();
+
+    }
+    else {
+	# generate form, pre-filled out with any useful values such
+	# as the collection and classifier value 
+
+	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.");
+	    }
+	}
+
+	generate_html_form($isGSDL2,$site,$collect,$cl);
     }
 }
