Index: gs3-extensions/html-to-expeditee/trunk/src/perllib/cgiactions/HtmlToExpediteeAction.pm
===================================================================
--- gs3-extensions/html-to-expeditee/trunk/src/perllib/cgiactions/HtmlToExpediteeAction.pm	(revision 24924)
+++ gs3-extensions/html-to-expeditee/trunk/src/perllib/cgiactions/HtmlToExpediteeAction.pm	(revision 24924)
@@ -0,0 +1,109 @@
+###########################################################################
+#
+# HtmlToExpediteeAction.pm -- 
+# A component of the Greenstone digital library software
+# from the New Zealand Digital Library Project at the 
+# University of Waikato, New Zealand.
+#
+# Copyright (C) 2009 New Zealand Digital Library Project
+#
+# This program is free software; you can redistr   te it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+###########################################################################
+
+package HtmlToExpediteeAction;
+
+use strict;
+
+use cgiactions::baseaction;
+
+use JSON;
+
+
+BEGIN {
+#    unshift (@INC, "$ENV{'GSDLHOME'}/perllib/cpan/perl-5.8");
+}
+
+
+@HtmlToExpediteeAction::ISA = ('baseaction');
+
+
+
+# c=collect and site=xxxx implicitly handled by code
+# 'c' is handled by baseaction, site is tested for only if greenstone3 
+
+
+my $action_table =
+{ 
+    "generate-frame"     => { 'compulsory-args' => [ "json" ],
+			      'optional-args'   => [] }, 
+};
+
+
+sub new 
+{
+    my $class = shift (@_);
+    my ($gsdl_cgi,$iis6_mode) = @_;
+
+    my $self = new baseaction($action_table,$gsdl_cgi,$iis6_mode);
+
+    return bless $self, $class;
+}
+
+
+sub generate_frame
+{
+    my $self = shift @_;
+
+    my $username  = $self->{'username'};
+    my $collect   = $self->{'collect'};
+    my $gsdl_cgi  = $self->{'gsdl_cgi'};
+    my $gsdlhome  = $self->{'gsdlhome'};
+
+    my $site = $self->{'site'};
+    my $collect_dir = $gsdl_cgi->get_collection_dir($site);
+
+    my $fn = $self->{'fn'};
+
+    # no need to lock collection (??), the operation is read only
+
+    my $json_str = $gsdl_cgi->param("json");
+    # my $exp_frame_tree = decode_json($json_str);
+	
+    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");
+    }
+
+
+}
+
+
+1;
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 24923)
+++ gs3-extensions/html-to-expeditee/trunk/src/src/cgi-bin/html-to-expeditee.pl.in	(revision 24924)
@@ -46,5 +46,5 @@
     $gsdl_cgi->checked_chdir($gsdlhome);
 
-##    require cgiactions::metadataaction;
+    require cgiactions::HtmlToExpediteeAction;
     
     # Useful debug statement for seeing what packages have been included
@@ -56,5 +56,4 @@
     $gsdl_cgi->{'xml'} = 0;
 
-
     my $collect = $gsdl_cgi->clean_param("c");   
     my $cl = $gsdl_cgi->clean_param("cl");   
@@ -76,35 +75,14 @@
 	    $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");
-	}
+
+	my $action = new HtmlToExpediteeAction($gsdl_cgi,$iis6_mode);
+
+	$action->do_action();
+
 
     }
@@ -277,5 +255,6 @@
 		 });
 
-	      expFrame = htmlToExpeditee(iframeDoc.body);
+	      var expFrameTree = htmlToExpeditee(iframeDoc.body);
+	      var expFrame = JSON.stringify(expFrameTree);
 	      //alert(expFrame);
 
@@ -288,5 +267,5 @@
 		params += "&site=" + site;
    	      }
-	      params += "&fn=" + frameID;
+	      params += "&a=generate-frame&fn=" + frameID;
 	      params += "&json=" + escape(expFrame);
 
@@ -302,4 +281,5 @@
 		  // console.log("doc oid = " + docOID);
 
+		 // is the following line used ????
 		  var cl = document.getElementById("cl").value;
 		  
