Index: /trunk/gsdl/perllib/plugins/ConvertToPlug.pm
===================================================================
--- /trunk/gsdl/perllib/plugins/ConvertToPlug.pm	(revision 1434)
+++ /trunk/gsdl/perllib/plugins/ConvertToPlug.pm	(revision 1435)
@@ -88,12 +88,80 @@
     {
 	$self = new TEXTPlug ($class, @_);
+	$self->{'convert_to'} = "TEXT";
+	$self->{'convert_to_ext'} = "txt";
     }
     else
     {
 	$self = new HTMLPlug ($class, @_);
+	$self->{'convert_to'} = "HTML";
+	$self->{'convert_to_ext'} = "html";
     }
 
     return bless $self, $class;
 }
+
+
+
+# Run conversion utility on the input file.  Output files generated in
+# collection specific 'tmp' directory.  
+# The collection tmp area is used to convert Word, PDF etc documents into 
+# another format (such as text or HTML) suitable for reading and indexing
+
+sub tmp_area_convert_file {
+    my $self = shift (@_);
+    my ($output_ext,$input_filename, $textref) = @_;
+
+    # softlink to collection tmp dir
+    my $colname = &util::use_collection();
+    my $tmp_dirname 
+	= &util::filename_cat($ENV{'GSDLHOME'},"collect",$colname,"tmp");
+    &util::mk_dir($tmp_dirname) if (!-e $tmp_dirname);
+
+    # derive tmp filename from input filename
+    my ($tailname,$dirname,$suffix)
+	= File::Basename::fileparse($input_filename,'\..+');
+    my $tmp_filename = &util::filename_cat($tmp_dirname,"$tailname$suffix");
+
+    # Remove any white space from filename -- no risk of name collision, and
+    # makes latter conversion by utils simpler
+    $tmp_filename =~ s/\s+//g; 
+
+    &util::soft_link($input_filename,$tmp_filename);
+
+    my $output_filename 
+	= &util::filename_cat($tmp_dirname,"$tailname.$output_ext");
+    $output_filename =~ s/\s+//g; 
+
+    my $verbosity = $self->{'verbosity'};
+    if ($verbosity>0)
+    {
+	print STDERR "Converting $tailname$suffix to $self->{'convert_to'}\n";
+    }
+    
+    # run either gs2txt.pl or gs2html.pl to peform the requested conversion
+    if (system("gs2$output_ext.pl -verbose $verbosity \"$tmp_filename\"")>0)
+    {
+	print STDERR "Warning: unable to convert to $output_ext format\n";
+    }
+
+    # remove symbolic link to original file
+    &util::rm($tmp_filename);
+
+    return $output_filename;
+}
+
+
+# Remove collection specific tmp directory and all its contents.
+
+sub cleanup_tmp_area {
+    my $self = shift (@_);
+
+    my $colname = &util::use_collection();
+    my $tmp_dirname 
+	= &util::filename_cat($ENV{'GSDLHOME'},"collect",$colname,"tmp");
+    &util::rm_r($tmp_dirname);
+    &util::mk_dir($tmp_dirname);
+}
+
 
 
@@ -155,9 +223,7 @@
     $doc_obj->associate_file($filename, "doc.$doc_ext", undef, $cursection);
 
+    my $doclink = "<a href=_httpcollection_/index/assoc/[archivedir]/doc.$doc_ext>";
+    $doc_obj->add_utf8_metadata ($cursection, "srclink",  $doclink); 
     $doc_obj->add_utf8_metadata ($cursection, "srcicon",  "_icon".$doc_ext."_"); 
-    $doc_obj->add_utf8_metadata ($cursection, "srcdoc",  "doc.$doc_ext"); 
-
-#   my $doclink = '<a href=_httpcollection_/index/assoc/[archivedir]/doc.$doc_ext>';
-#   $doc_obj->add_utf8_metadata ($cursection, "srclink",  $doclink); 
     $doc_obj->add_utf8_metadata ($cursection, "/srclink", "</a>"); 
 
Index: /trunk/gsdl/perllib/plugins/HTMLPlug.pm
===================================================================
--- /trunk/gsdl/perllib/plugins/HTMLPlug.pm	(revision 1434)
+++ /trunk/gsdl/perllib/plugins/HTMLPlug.pm	(revision 1435)
@@ -38,5 +38,5 @@
 package HTMLPlug;
 
-use ConvertToBasPlug;
+use BasPlug;
 use ghtml;
 use util;
@@ -44,5 +44,5 @@
 
 sub BEGIN {
-    @ISA = ('ConvertToBasPlug');
+    @ISA = ('BasPlug');
 }
 
@@ -72,5 +72,5 @@
 sub new {
     my $class = shift (@_);
-    my $self = new ConvertToBasPlug ($class, @_);
+    my $self = new BasPlug ($class, @_);
 
     if (!parsargv::parse(\@_, 
@@ -93,7 +93,4 @@
     $self->{'dir_num'} = 0;
     $self->{'file_num'} = 0;
-
-    $self->{'convert_to'} = "HTML";
-    $self->{'convert_to_ext'} = "html";
 
     return bless $self, $class;
Index: /trunk/gsdl/perllib/plugins/TEXTPlug.pm
===================================================================
--- /trunk/gsdl/perllib/plugins/TEXTPlug.pm	(revision 1434)
+++ /trunk/gsdl/perllib/plugins/TEXTPlug.pm	(revision 1435)
@@ -29,16 +29,13 @@
 package TEXTPlug;
 
-use ConvertToBasPlug;
+use BasPlug;
 
 sub BEGIN {
-    @ISA = ('ConvertToBasPlug');
+    @ISA = ('BasPlug');
 }
 
 sub new {
     my ($class) = @_;
-    my $self = new ConvertToBasPlug ($class, @_);
-
-    $self->{'convert_to'} = "TEXT";
-    $self->{'convert_to_ext'} = "txt";
+    my $self = new BasPlug ($class, @_);
 
     return bless $self, $class;
