Index: trunk/niupepa/perllib/plugins/NPPlug.pm
===================================================================
--- trunk/niupepa/perllib/plugins/NPPlug.pm	(revision 13309)
+++ trunk/niupepa/perllib/plugins/NPPlug.pm	(revision 13310)
@@ -46,31 +46,39 @@
 use BasPlug;
 use util;
+use strict;
+use unicode;
 
 sub BEGIN {
-    @ISA = ('BasPlug');
-}
-
-use strict;
-
-sub print_usage {
-    print STDERR "\nIncorrect options passed to NPPlug, check your collect.cfg configuration file\n";
-
-    print STDERR "\n  usage: plugin NPPlug [options]\n\n";
-    print STDERR "  options:\n";
-    print STDERR "   -create_log            Creates a log file containing info about which portions\n";
-    print STDERR "                          of papers are missing\n";
-    print STDERR "   -logfile               Path of logfile (defaults to ./log.txt)\n\n";
-}
+    @NPPlug::ISA = ('BasPlug');
+}
+
+
+my $arguments =
+    [
+     { 'name' => "create_log",
+       'desc' => "To create a log file",
+       'type' => "flag" },
+     { 'name' => "logfile",
+       'desc' => "The log file path",
+       'type' => "string",
+       'deft' => "./log.txt"}
+     ];
+
+my $options = { 'name'     => "NPPlug",
+		'desc'     => "{NPPlug.desc}",
+		'abstract' => "no",
+		'inherits' => "yes",
+		'args'     => $arguments };
 
 sub new {
-    my ($class) = @_;
-    my $self = new BasPlug ();
-
-    if (!parsargv::parse(\@_, 
-			 q^create_log^, \$self->{'create_log'},
-			 q^logfile/.*/./log.txt^, \$self->{'logfile'})) {
-	&print_usage();
-	die "\n";
-    }
+    my ($class) = shift(@_);
+
+    my ($pluginlist,$inputargs,$hashArgOptLists) = @_;
+    push(@$pluginlist, $class);
+    
+    if(defined $arguments){ push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});}
+    if(defined $options) { push(@{$hashArgOptLists->{"OptList"}},$options)};
+   
+    my $self = new BasPlug($pluginlist, $inputargs, $hashArgOptLists);
 
     $self->{'commentaries'} = {};
@@ -81,4 +89,13 @@
     return bless $self, $class;
 }
+
+
+sub get_default_process_exp {
+    my $self = shift (@_);
+    
+    # the last option is an attempt to encode the concept of an html query ...
+    return q^(?i)(\.issue)$^;
+}
+
 
 sub is_recursive {
@@ -152,5 +169,5 @@
     return 0 if $filename =~ /meta\.txt$/i;
 
-    return undef unless ($filename =~ /\.(issue|commentary)$/i && (-e $filename));
+    return undef unless ($filename =~ /\.(issue|commentary|gif)$/i && (-e $filename));
 
     $self->{'verbosity'} = $processor->{'verbosity'};
@@ -163,9 +180,37 @@
     if ($filename =~ /\.commentary$/i) {
 	# commentary
-	return $self->process_commentary ($filename, $issuekey, $dir, $file, $processor);
+	$self->{'num_processed'} 
+	  += $self->process_commentary ($filename, $issuekey, $dir, $file, $processor);
+	return 1;
+    }
+
+    if ($filename =~ /(.*)on\.gif$/i) {
+	my $root = $1;
+	# create surrogate document to store cover image (on and off) for
+	# newspaper
+
+	$issuekey =~ s/on$//;
+
+	my $doc_obj = new doc  ($dir, "indexed_doc");
+	my $cover = &util::filename_cat ($dir, $issuekey);
+
+	$self->associate_cover_images ($doc_obj, $cover, "" );
+	$doc_obj->set_OID ($issuekey);
+	$processor->process ($doc_obj);
+
+	return 0;
+    }
+    if ($filename =~ /(.*)of\.gif$/i) {
+	# block it
+	return 0;
+    }
+    if ($filename =~ /\.gif$/i) {
+	# Let some other plugin have a go
+	return undef;
     }
 
     my $numprocessed = 0;
-    $self->{'commentaries'}->{$issuekey} = 0 unless defined $self->{'commentaries'}->{$issuekey};
+    $self->{'commentaries'}->{$issuekey} = 0
+	unless defined $self->{'commentaries'}->{$issuekey};
 
     my ($abstractfile) = $file =~ /^([^\.]*)\.issue/i;
@@ -188,5 +233,9 @@
     }
 
-    return $numprocessed;
+    $self->{'num_processed'} += $numprocessed;
+
+
+
+    return 1;
 }
 
@@ -202,4 +251,9 @@
     $doc_obj->set_utf8_metadata_element ($topsection, 'abstract', $abstract) if defined $abstract;
     $self->set_main_metadata ($doc_obj, $dir);
+
+    my $com_filename = &util::filename_cat($dir,"$issuekey.commentary");
+    if (-e $com_filename) {
+	$doc_obj->set_utf8_metadata_element ($topsection, "hascom", "1");
+    }
 
     # process issue's pdf if one exists
